chromium/remoting/host/mac/BUILD.gn

# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//remoting/build/config/remoting_build.gni")

if (icu_use_data_file) {
  bundle_data("icu_data") {
    sources = [ "$root_out_dir/icudtl.dat" ]

    outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]

    public_deps = [ "//third_party/icu:icudata" ]
  }
}

source_set("constants") {
  defines = [
    "HOST_BUNDLE_NAME=\"" + me2me_host_bundle_name + "\"",
    "HOST_LEGACY_BUNDLE_NAME=\"" + me2me_host_legacy_bundle_name + "\"",
  ]

  sources = [
    "constants_mac.cc",
    "constants_mac.h",
  ]

  deps = [ "//remoting/host:remoting_version" ]
}

source_set("permission_checking") {
  sources = [
    "permission_checker.cc",
    "permission_checker.h",
    "permission_process_utils.cc",
    "permission_process_utils.h",
    "permission_utils.h",
    "permission_utils.mm",
    "permission_wizard.h",
    "permission_wizard.mm",
  ]

  public_deps = [ "//base" ]

  deps = [
    ":constants",
    "//remoting/host:remoting_version",
    "//remoting/resources",
    "//ui/base:base",
  ]

  frameworks = [ "AVFoundation.framework" ]
}

executable("remoting_me2me_host_service") {
  sources = [ "host_service_main.cc" ]
  configs += [ "//remoting/build/config:version" ]
  deps = [
    ":constants",
    "//base",
    "//remoting/base",
    "//remoting/host:remoting_version",
    "//remoting/host/base",
  ]
}

bundle_data("remoting_me2me_host_service_bundle_data") {
  sources = [ "$root_out_dir/remoting_me2me_host_service" ]
  outputs = [ "{{bundle_executable_dir}}/{{source_file_part}}" ]
  public_deps = [ ":remoting_me2me_host_service" ]
}

# remoting_me2me_host-InfoPlist.strings
foreach(locale, remoting_locales_with_underscores) {
  bundle_data("remoting_me2me_host_strings_${locale}_bundle_data") {
    sources = [ "$root_gen_dir/remoting/host/remoting_me2me_host-InfoPlist.strings/$locale.lproj/InfoPlist.strings" ]
    outputs = [ "{{bundle_resources_dir}}/$locale.lproj/{{source_file_part}}" ]
    deps = [ "//remoting/host:remoting_infoplist_strings" ]
  }
}

bundle_data("remoting_host_resources") {
  sources = [
    "$root_gen_dir/remoting/CREDITS.txt",
    "remoting_host.icns",
  ]

  outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]

  public_deps = [ "//remoting/host/installer:credits" ]
}

target("mac_app_bundle", "remoting_me2me_host") {
  configs += [ "//remoting/build/config:version" ]
  info_plist = "remoting_me2me_host-Info.plist"
  extra_substitutions = [
    "BUNDLE_ID=$host_bundle_id",
    "VERSION_FULL=$remoting_version_full",
    "VERSION_SHORT=$remoting_version_short",
    "MACOSX_DEPLOYMENT_TARGET=10.15",
  ]

  # TODO(joedow): Re-enable or replace with Crashpad: crbug.com/637884.
  # if (is_chrome_branded && is_official_build) {
  #   defines = [ "REMOTING_ENABLE_BREAKPAD" ]
  # }

  deps = [
    ":permission_checking",
    "//remoting/base:breakpad",
    "//remoting/host:entry_point",
    "//remoting/host/installer:credits",
    "//remoting/resources",
  ]

  foreach(locale, remoting_locales_with_underscores) {
    deps += [
      ":remoting_host_locale_${locale}_bundle_data",
      ":remoting_me2me_host_strings_${locale}_bundle_data",
    ]
  }
  deps += [
    ":remoting_host_resources",
    ":remoting_me2me_host_service_bundle_data",
    "//remoting/host:remoting_infoplist_strings",
    "//remoting/resources:copy_locales",
  ]

  if (icu_use_data_file) {
    deps += [ ":icu_data" ]
  }
}

foreach(locale, remoting_locales_with_underscores) {
  bundle_data("remoting_host_locale_${locale}_bundle_data") {
    sources = [ "$root_build_dir/remoting/resources/$locale.lproj/locale.pak" ]
    outputs = [ "{{bundle_resources_dir}}/$locale.lproj/{{source_file_part}}" ]
    deps = [ "//remoting/resources:copy_locales" ]
  }
}

# native_messaging_host-InfoPlist.strings
foreach(locale, remoting_locales_with_underscores) {
  bundle_data("native_messaging_host_strings_${locale}_bundle_data") {
    sources = [ "$root_gen_dir/remoting/host/native_messaging_host-InfoPlist.strings/$locale.lproj/InfoPlist.strings" ]
    outputs = [ "{{bundle_resources_dir}}/$locale.lproj/{{source_file_part}}" ]
    deps = [ "//remoting/host:remoting_infoplist_strings" ]
  }
}

bundle_data("remoting_native_messaging_host_resources") {
  sources = [
    "remoting_host.icns",

    # This image is used to badge the lock icon in the authentication dialogs,
    # used for elevating privileges to set up the host. The exact filename is
    # required by base::mac::GetAuthorizationRightsWithPrompt().
    # It needs to exist as a file on disk and not just something in a
    # resource bundle because that's the interface that Authorization Services
    # uses. Also, Authorization Services can't deal with .icns files.
    "//remoting/resources/product_logo_32.png",
  ]
  outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]

  if (icu_use_data_file) {
    deps = [ ":icu_data" ]
  }
}

target("mac_app_bundle", "remoting_native_messaging_host") {
  output_name = "native_messaging_host"
  info_plist = "../setup/native_messaging_host-Info.plist"
  configs += [ "//build/config/compiler:wexit_time_destructors" ]
  extra_substitutions = [
    "BUNDLE_ID=$native_messaging_host_bundle_id",
    "VERSION_FULL=$remoting_version_full",
    "VERSION_SHORT=$remoting_version_short",
    "MACOSX_DEPLOYMENT_TARGET=10.15",
    "HOST_NAME=$host_name",
  ]

  sources = [ "../setup/me2me_native_messaging_host_entry_point.cc" ]

  deps = [
    ":remoting_native_messaging_host_resources",
    "//remoting/host:remoting_infoplist_strings",
    "//remoting/host/setup:native_messaging_host_main",
    "//remoting/host/setup:native_messaging_host_main_headers",
  ]
  foreach(locale, remoting_locales_with_underscores) {
    deps += [
      ":native_messaging_host_strings_${locale}_bundle_data",
      "//remoting/host/mac:remoting_host_locale_${locale}_bundle_data",
    ]
  }
  deps += [ "//remoting/resources:copy_locales" ]

  # The |major|, |build| and |patch| versions are inherited from Chrome.
  # Since Chrome's |minor| version is always '0', we replace it with a
  # Chromoting-specific patch version.
  defines =
      [ "VERSION=" + "$chrome_version_major" + "." + "$remoting_version_patch" +
        "." + "$chrome_version_build" + "." + "$chrome_version_patch" ]
}