chromium/remoting/host/installer/win/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")
import("//remoting/host/installer/win/generate_clsids.gni")
import("//remoting/host/installer/win/wix_path.gni")

action("remoting_me2me_host_archive") {
  script = "//remoting/host/installer/build-installer-archive.py"

  sources = [
    # Used by build-installer-archive.py.
    "//build/zip_helpers.py",
  ]

  deps = [
    "//remoting/host:remoting_native_messaging_manifests",
    "//remoting/host:remoting_start_host",
    "//remoting/host/installer:credits",
    "//remoting/host/it2me:remote_assistance_host",
    "//remoting/host/it2me:remote_assistance_host_uiaccess",
    "//remoting/host/remote_open_url",
    "//remoting/host/webauthn:remote_webauthn",
    "//remoting/host/win:remoting_core",
    "//remoting/host/win:remoting_desktop",
    "//remoting/host/win:remoting_me2me_host",
    "//remoting/host/win:remoting_native_messaging_host",
    "//third_party/icu:icudata",
  ]

  public_deps = [ "//remoting/host/security_key:remote_security_key" ]

  if (target_cpu == "x86") {
    _output = "$root_out_dir/remoting-me2me-host-$target_os.zip"
  } else {
    _output = "$root_out_dir/remoting-me2me-host-$target_os-unsupported.zip"
  }

  outputs = [ _output ]
  if (is_chrome_branded) {
    _branding = "Chrome"
  } else {
    _branding = "Chromium"
  }

  if (is_official_build) {
    _official_build = "1"
  } else {
    _official_build = "0"
  }

  # Due to GN build issue http://crbug.com/633650, we need to actively set
  # inputs parameter to tell GN to depend on these files. So change to each
  # following files will trigger this target to be rebuilt.
  # TODO(zijiehe): Remove inputs parameter once bug 633650 has been
  # addressed.
  inputs = [
    "$root_out_dir/remote_assistance_host.exe",
    "$root_out_dir/remote_assistance_host_uiaccess.exe",
    "$root_out_dir/remote_open_url.exe",
    "$root_out_dir/remote_security_key.exe",
    "$root_out_dir/remote_webauthn.exe",
    "$root_out_dir/remoting_core.dll",
    "$root_out_dir/remoting_desktop.exe",
    "$root_out_dir/remoting_host.exe",
    "$root_out_dir/remoting_native_messaging_host.exe",
    "$root_out_dir/remoting_start_host.exe",
    "$root_gen_dir/remoting/CREDITS.txt",
    "$root_out_dir/remoting/com.google.chrome.remote_assistance.json",
    "$root_out_dir/remoting/com.google.chrome.remote_assistance-firefox.json",
    "$root_out_dir/remoting/com.google.chrome.remote_desktop.json",
    "$root_out_dir/remoting/com.google.chrome.remote_desktop-firefox.json",
    "$root_out_dir/remoting/com.google.chrome.remote_webauthn.json",
    "$root_out_dir/icudtl.dat",
  ]

  _generated_files = rebase_path(inputs, root_build_dir)
  _generated_files +=
      [ rebase_path("//remoting/resources/chromoting.ico", root_build_dir) ]

  # Inputs that should not be part of _generated_files.
  inputs += [
    "chromoting.wxs",
    "parameters.json",
  ]

  # _generated_dst_files must contain the same files in the same order as
  # _generated_files, otherwise the Windows MSI will not be built correctly.
  _generated_dst_files = [
    "files/remote_assistance_host.exe",
    "files/remote_assistance_host_uiaccess.exe",
    "files/remote_open_url.exe",
    "files/remote_security_key.exe",
    "files/remote_webauthn.exe",
    "files/remoting_core.dll",
    "files/remoting_desktop.exe",
    "files/remoting_host.exe",
    "files/remoting_native_messaging_host.exe",
    "files/remoting_start_host.exe",
    "files/CREDITS.txt",
    "files/com.google.chrome.remote_assistance.json",
    "files/com.google.chrome.remote_assistance-firefox.json",
    "files/com.google.chrome.remote_desktop.json",
    "files/com.google.chrome.remote_desktop-firefox.json",
    "files/com.google.chrome.remote_webauthn.json",
    "files/icudtl.dat",
    "files/chromoting.ico",
  ]

  args = [
           rebase_path("$root_gen_dir/remoting_installation", root_build_dir),
           rebase_path(_output, root_build_dir),
           "--source-file-roots",
           rebase_path("//remoting/host/installer/win", root_build_dir),
           "--source-files",
           rebase_path("//remoting/host/installer/win/chromoting.wxs",
                       root_build_dir),
           rebase_path("//remoting/host/installer/win/parameters.json",
                       root_build_dir),

           # Input files
           "--generated-files",
         ] + _generated_files +
         [
           # Position of files in zip file
           "--generated-files-dst",
         ] + _generated_dst_files +
         [
           # Defs
           "--defs",
           "BRANDING=$_branding",
           "RDP_DESKTOP_SESSION_CLSID={$rdp_desktop_session_clsid}",
           "VERSION=$chrome_version_full",
           "OFFICIAL_BUILD=$_official_build",
         ]
}

# We do not release a 64 bits binary. So to avoid any potential
# misunderstanding, we only build 32 bits MSI file.
# TODO(yuweih): Replace the remoting_wix_path check with is_chrome_branded once
# everyone is able to use their Google machines again, or remove the check
# altogether if we decide to build the MSI with non-official builders.
if (remoting_wix_path != "" && !is_component_build && target_cpu == "x86") {
  # The script uses "ia32" instead of "x86".
  msi_script_arch = "ia32"

  action("remoting_host_installation") {
    deps = [ "//remoting/host:remoting_me2me_host_archive" ]
    script = "//remoting/tools/zip2msi.py"
    outputs = [ "$root_out_dir/chromoting.msi" ]
    args = [
      "--wix_path",
      remoting_wix_path,
      "--intermediate_dir",
      rebase_path("$root_gen_dir/remoting_installation", root_build_dir),
      "--target_arch",
      msi_script_arch,
      rebase_path("$root_out_dir/remoting-me2me-host-$current_os.zip",
                  root_build_dir),
      rebase_path(outputs[0], root_build_dir),
    ]
  }
} else {
  group("remoting_host_installation") {
    # We still want to build host archive under other configurations.
    deps = [ "//remoting/host:remoting_me2me_host_archive" ]
  }
}