chromium/chrome/updater/win/BUILD.gn

# Copyright 2019 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/util/process_version.gni")
import("//chrome/process_version_rc_template.gni")
import("//chrome/updater/branding.gni")
import("//chrome/updater/zip.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")

# This target builds the updater executable, its installer, and unittests.
group("win") {
  deps = [
    ":signing",
    ":updater",
    ":updater_zip",
    "//chrome/updater/win/installer",
  ]
}

config("wrl_strict") {
  # This definition is used in <wrl/module.h> to specify that only COM
  # support is provided by WRL, and thus, avoid a dependency on WinRT, which
  # is not available in Windows 7.
  defines = [ "__WRL_CLASSIC_COM_STRICT__" ]
}

source_set("updater_executable") {
  sources = [
    "main.cc",
    "updater.rc",
  ]

  deps = [
    "//chrome/updater:base",
    "//chrome/updater/win/ui/resources",
  ]

  public_configs = [ "//build/config/win:windowed" ]
  public_deps = [ "//build/win:default_exe_manifest" ]

  data_deps = [ ":uninstall.cmd" ]
}

executable("updater") {
  deps = [
    ":updater_executable",
    ":version_resources",
    "//chrome/updater:constants_prod",
  ]
}

executable("updater_test") {
  deps = [
    ":updater_executable",
    ":version_resources_test",
    "//chrome/updater:constants_test",
  ]
}

copy("signing") {
  sources = [
    "$root_out_dir/msi_custom_action.dll",
    "$root_out_dir/tag.exe",
    "//chrome/tools/build/win/resedit.py",
    "//third_party/lzma_sdk/bin/win64/7zr.exe",
    "signing/enterprise_standalone_installer.wxs.xml",
    "signing/msi_from_standalone.py",
    "signing/sign.py",
  ]

  deps = [
    "//chrome/updater/tools:tag",
    "//chrome/updater/win/installer:msi_custom_action",
  ]

  outputs = [ "$root_out_dir/UpdaterSigning/{{source_file_part}}" ]
}

artifact_zip("updater_zip") {
  output = "$root_build_dir/updater.zip"
  inputs =
      [
        "$root_build_dir/UpdaterSetup.exe",
        "$root_build_dir/UpdaterSetup_test.exe",
        "$root_build_dir/qualification_app.exe",
        "$root_build_dir/${updater_product_full_name}Util.exe",
        "$root_gen_dir/chrome/updater/app/server/win/updater_idl.h",
        "$root_gen_dir/chrome/updater/app/server/win/updater_internal_idl.h",
      ] + get_target_outputs(":signing")
  deps = [
    ":signing",
    "//chrome/updater/app/server/win:updater_idl",
    "//chrome/updater/app/server/win:updater_internal_idl",
    "//chrome/updater/test/qualification_app",
    "//chrome/updater/tools:${updater_product_full_name}Util",
    "//chrome/updater/win/installer",
    "//chrome/updater/win/installer:installer_test",
  ]
  if (is_chrome_branded) {
    inputs += [
      "$root_build_dir/GoogleUpdateAdmx.zip",
      "$root_build_dir/GoogleCloudManagementAdmx.zip",
    ]
    deps += [
      "//chrome/updater/enterprise/win/google:GoogleCloudManagementAdmxZip",
      "//chrome/updater/enterprise/win/google:GoogleUpdateAdmxZip",
    ]
  }
}

process_version("uninstall.cmd") {
  template_file = "setup/uninstall.cmd"
  output = "$target_gen_dir/uninstall.cmd"
  process_only = true
  extra_args = [
    "-e",
    "PRODUCT_FULLNAME=\"$updater_product_full_name\"",
    "-e",
    "COMPANY_SHORTNAME=\"$updater_company_short_name\"",
  ]
}

template("updater_process_version_rc_template") {
  # `process_version_rc_template` invokes `process_version` with the default
  # template rc file which is at //chrome/app/chrome_version.rc.version.
  process_version_rc_template(target_name) {
    _internal_name = "$updater_product_full_display_name"
    if (invoker.suffix != "") {
      _internal_name += invoker.suffix
    }
    _internal_name += " ($current_cpu)"
    if (is_debug) {
      _internal_name += " (debug)"
    }
    extra_args = [
      "-e",
      "PRODUCT_FULLNAME=\"$updater_product_full_display_name\"",
      "-e",
      "INTERNAL_NAME=\"$_internal_name\"",
      "-e",
      "ORIGINAL_FILENAME=\"${invoker.original_filename}\"",
      "-e",
      "PRODUCT_SHORTNAME=\"$updater_product_full_name\"",
    ]
    output = "$target_gen_dir/${invoker.rc}"
  }
}

updater_process_version_rc_template("version_resources") {
  suffix = ""
  original_filename = "updater.exe"
  rc = "updater_exe.rc"
}

updater_process_version_rc_template("version_resources_test") {
  suffix = " (test)"
  original_filename = "updater_test.exe"
  rc = "updater_test_exe.rc"
}