chromium/remoting/host/it2me/BUILD.gn

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

import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//remoting/remoting_locales.gni")
import("//remoting/remoting_options.gni")
import("//remoting/remoting_version.gni")

if (is_win) {
  import("//remoting/host/predefines_win.gni")
}
if (is_mac) {
  import("//build/config/mac/rules.gni")
  import("//third_party/icu/config.gni")
}

source_set("constants") {
  sources = [
    "it2me_constants.cc",
    "it2me_constants.h",
  ]
  deps = [ "//remoting/host/native_messaging" ]
}

source_set("helpers") {
  sources = [
    "it2me_helpers.cc",
    "it2me_helpers.h",
  ]
  deps = [
    ":constants",
    "//base",
    "//remoting/base:name_value_map",
  ]
}

source_set("common") {
  sources = [
    "it2me_confirmation_dialog.h",
    "it2me_confirmation_dialog_proxy.cc",
    "it2me_confirmation_dialog_proxy.h",
    "it2me_host.cc",
    "it2me_host.h",
    "it2me_native_messaging_host.cc",
    "it2me_native_messaging_host.h",
    "reconnect_params.cc",
    "reconnect_params.h",
  ]

  deps = [ "//remoting/base:session_policies" ]

  if (is_linux) {
    sources += [ "it2me_confirmation_dialog_linux.cc" ]
  }

  if (is_chromeos_ash) {
    sources += [ "it2me_confirmation_dialog_chromeos.cc" ]
  }

  if (is_mac) {
    sources += [ "it2me_confirmation_dialog_mac.mm" ]
  }

  if (is_win) {
    sources += [ "it2me_confirmation_dialog_win.cc" ]
  }

  configs += [
    "//build/config/compiler:wexit_time_destructors",
    "//remoting/build/config:version",
  ]

  public_deps = [
    ":constants",
    ":helpers",
  ]

  deps += [
    "//base:i18n",
    "//build:chromeos_buildflags",
    "//components/policy:policy_code_generate",
    "//components/webrtc:thread_wrapper",
    "//extensions/browser/api/messaging:native_messaging",
    "//google_apis:google_apis",
    "//mojo/core/embedder",
    "//net",
    "//remoting/base",
    "//remoting/base:authorization",
    "//remoting/host:common",
    "//remoting/host/base",
    "//remoting/host/native_messaging:native_messaging",
    "//remoting/proto/ftl/v1:ftl_messages",
    "//remoting/protocol",
    "//remoting/resources",
    "//remoting/signaling",
    "//services/network/public/cpp:cpp",
  ]

  if (is_linux) {
    deps += [
      "//build/config/linux/gtk",
      "//ui/base:base",

      # GTK pulls pangoft2, which requires HarfBuzz symbols. When linking
      # our own HarfBuzz avoid mixing symbols from system HarfBuzz and
      # our own through the indirect dependency to harfbuzz-ng here.
      "//remoting/host/linux:wayland",
      "//third_party:freetype_harfbuzz",
    ]
  }
  if (is_chromeos_ash) {
    deps += [
      "//chromeos/ui/vector_icons",
      "//remoting/host/chromeos",
      "//remoting/host/chromeos:features",
      "//remoting/host/chromeos:host_event_reporter_impl",
      "//ui/message_center",
      "//ui/message_center/public/cpp",
    ]
  }
  if (is_mac) {
    deps += [ "//ui/base:base" ]
  }
  if (is_win) {
    deps += [
      "//remoting/host/win",
      "//remoting/host/win:elevated_native_messaging_host",
    ]
  }
}

if (is_chromeos) {
  source_set("chrome_os_host") {
    sources = [
      "it2me_native_messaging_host_allowed_origins.cc",
      "it2me_native_messaging_host_allowed_origins.h",
    ]

    if (is_chromeos_lacros) {
      sources += [
        "it2me_native_messaging_host_lacros.cc",
        "it2me_native_messaging_host_lacros.h",
      ]
      deps = [
        ":constants",
        ":helpers",
        "//base",
        "//chromeos/crosapi/mojom",
        "//chromeos/lacros",
        "//extensions/browser/api/messaging:native_messaging",
        "//google_apis:google_apis",
        "//remoting/host/native_messaging",
        "//remoting/protocol:errors",
      ]
    } else {
      sources += [
        "it2me_native_messaging_host_ash.cc",
        "it2me_native_messaging_host_ash.h",
        "it2me_native_messaging_host_chromeos.cc",
        "it2me_native_messaging_host_chromeos.h",
      ]

      deps = [
        ":common",
        "//extensions/browser/api/messaging:native_messaging",
        "//remoting/base:base",
        "//remoting/host:common",
        "//remoting/host/chromeos:browser_interop",
        "//remoting/host/chromeos:enterprise_support",
        "//remoting/host/chromeos:features",
        "//remoting/host/mojom:mojom",
        "//remoting/host/native_messaging",
        "//skia",
      ]

      public_deps = [ ":constants" ]

      if (use_ozone) {
        deps += [ "//ui/ozone" ]
      }
    }
  }
}

if (!is_chromeos_ash && enable_remoting_host) {
  source_set("main_headers") {
    sources = [ "it2me_native_messaging_host_main.h" ]
    deps = [ "//remoting/host:host_main_headers" ]
  }

  source_set("main") {
    configs += [
      "//build/config/compiler:wexit_time_destructors",
      "//remoting/build/config:host_implementation",
      "//remoting/build/config:version",
    ]
    sources = [ "it2me_native_messaging_host_main.cc" ]
    deps = [
      ":common",
      ":main_headers",
      "//mojo/core/embedder",
      "//net",
      "//remoting/base",
      "//remoting/base:breakpad",
      "//remoting/host",
      "//remoting/host:resources",
      "//remoting/host:settings",
      "//remoting/host/base",
      "//remoting/host/native_messaging",
      "//remoting/proto",
      "//third_party/webrtc_overrides:webrtc_component",
      "//ui/gfx",
    ]

    if (is_linux) {
      deps += [ "//remoting/host/linux:wayland" ]
    }
    if (is_linux && remoting_use_x11) {
      defines = [ "REMOTING_USE_X11" ]
      deps += [
        "//build/config/linux/gtk",
        "//ui/events/platform/x11",
        "//ui/gtk:gtk_config",
      ]
    }

    if (is_mac) {
      deps += [ "//remoting/host/mac:permission_checking" ]
    }
  }

  if (is_win) {
    executable("remote_assistance_host") {
      configs += [ "//build/config/compiler:wexit_time_destructors" ]

      deps = [
        ":main_headers",
        "//remoting/host/win:dpi_aware_exe_manifest",
        "//remoting/host/win:remoting_core",
        "//remoting/host/win:remoting_windows_resources",
      ]

      sources = [
        "$root_gen_dir/remoting/version.rc",
        "it2me_native_messaging_host_entry_point.cc",
      ]

      defines = host_predefines +
                [ "REMOTING_HOST_BINARY=BINARY_REMOTE_ASSISTANCE_HOST" ]

      ldflags = [
        # "/NODEFAULTLIB", TODO(zijiehe): Why IgnoreAllDefaultLibraries: true in
        # GYP does not take effect?
        "comctl32.lib",
      ]
    }

    executable("remote_assistance_host_uiaccess") {
      configs += [ "//build/config/compiler:wexit_time_destructors" ]

      deps = [
        ":main_headers",
        "//remoting/host/win:remoting_core",
        "//remoting/host/win:remoting_windows_resources",
      ]

      sources = [
        "$root_gen_dir/remoting/version.rc",
        "it2me_native_messaging_host_entry_point.cc",
      ]

      defines = host_predefines +
                [ "REMOTING_HOST_BINARY=BINARY_HOST_IT2ME_UIACCESS" ]

      ldflags = [
        # "/NODEFAULTLIB", TODO(zijiehe): Why IgnoreAllDefaultLibraries: true in
        # GYP does not take effect?
        "comctl32.lib",
      ]

      # uiAccess requires a signed build to work correctly, so only enable the
      # manifest flag when the binary will be properly signed.
      if (is_official_build) {
        deps += [ "//remoting/host/win:dpi_aware_uiaccess_exe_manifest" ]
      } else {
        deps += [ "//remoting/host/win:dpi_aware_exe_manifest" ]
      }
    }
  } else {
    if (is_mac) {
      app_target_type = "mac_app_bundle"

      bundle_data("remote_assistance_host_icons") {
        sources = [
          "//remoting/host/mac/remoting_host.icns",
          "//remoting/resources/chromoting128.png",
        ]

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

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

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

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

          public_deps = [ "//third_party/icu:icudata" ]
        }
      }
    } else {
      app_target_type = "executable"
    }

    target(app_target_type, "remote_assistance_host") {
      if (is_mac) {
        info_plist = "remote_assistance_host-Info.plist"
        extra_substitutions = [
          "BUNDLE_ID=$remote_assistance_host_bundle_id",
          "VERSION_FULL=$remoting_version_full",
          "VERSION_SHORT=$remoting_version_short",
          "MACOSX_DEPLOYMENT_TARGET=10.15",
        ]
      }
      configs += [
        "//build/config/compiler:wexit_time_destructors",
        "//remoting/build/config:version",
      ]

      sources = [ "it2me_native_messaging_host_entry_point.cc" ]

      deps = [ ":main_headers" ]
      if (is_mac) {
        deps += [ ":main" ]
      } else {
        deps += [ "//remoting/host:remoting_core" ]
      }

      if (is_mac) {
        foreach(locale, remoting_locales_with_underscores) {
          deps += [
            ":remote_assistance_host_strings_${locale}_bundle_data",
            "//remoting/host/mac:remoting_host_locale_${locale}_bundle_data",
          ]
        }
        deps += [
          ":remote_assistance_host_icons",
          "//remoting/host:remoting_infoplist_strings",
          "//remoting/resources:copy_locales",
        ]
        if (icu_use_data_file) {
          deps += [ ":remote_assistance_host_resources" ]
        }
      }
    }
  }
}