chromium/chrome/installer/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("//build/config/features.gni")
import("//build/config/mac/mac_sdk.gni")
import("//build/util/branding.gni")
import("//chrome/browser/buildflags.gni")
import("//chrome/process_version_rc_template.gni")
import("//chrome/version.gni")
import("//testing/test.gni")
import("mac_signing_sources.gni")

if (is_chrome_branded) {
  import("//third_party/widevine/scripts/widevine_signing_sources.gni")
}

group("mac") {
  public_deps = [ ":copies" ]
}

_packaging_dir = "$root_out_dir/$chrome_product_full_name Packaging"

process_version_rc_template("sign_config") {
  visibility = [ ":copy_signing" ]

  process_only = true

  template_file = "signing/build_props_config.py.in"

  output = "$_packaging_dir/signing/build_props_config.py"

  _full_target_name = get_label_info(target_name, "label_no_toolchain")
  _file_path = rebase_path(template_file)

  _local_chrome_branded = "False"
  if (is_chrome_branded) {
    _local_chrome_branded = "True"
  }
  _enable_updater = "False"
  if (enable_updater) {
    _enable_updater = "True"
  }

  extra_args = [
    "-e",
    "GEN_HEADER=\"THIS FILE IS AUTOMATICALLY GENERATED BY $_full_target_name.\n\"",
    "-e",
    "IS_CHROME_BRANDED=$_local_chrome_branded",
    "-e",
    "ENABLE_UPDATER=$_enable_updater",
  ]
}

copy("copy_signing") {
  visibility = [ ":copies" ]

  deps = [ ":sign_config" ]

  sources = mac_signing_sources

  if (is_chrome_branded) {
    sources += [ "internal/internal_config.py" ]
  }

  outputs = [ "$_packaging_dir/signing/{{source_file_part}}" ]
}

if (is_chrome_branded) {
  copy("copy_widevine_signing") {
    visibility = [ ":copies" ]

    sources = rebase_path(widevine_signing_sources,
                          "",
                          "//third_party/widevine/scripts")

    outputs = [ "$_packaging_dir/widevine/{{source_file_part}}" ]
  }
}

copy("copies") {
  visibility = [ ":mac" ]

  deps = [
    ":copy_signing",
    "//chrome:entitlements",
    "//chrome/installer/mac/third_party/bsdiff:goobsdiff",
    "//chrome/installer/mac/third_party/bsdiff:goobspatch",
    "//chrome/installer/mac/third_party/xz:lzma_decompress",
    "//chrome/installer/mac/third_party/xz:xz",
    "//chrome/installer/mac/third_party/xz:xzdec",
  ]

  sources = [
    "$root_gen_dir/chrome/app-entitlements.plist",
    "$root_out_dir/goobsdiff",
    "$root_out_dir/goobspatch",
    "$root_out_dir/liblzma_decompress.dylib",
    "$root_out_dir/xz",
    "$root_out_dir/xzdec",
    "//chrome/app/helper-gpu-entitlements.plist",
    "//chrome/app/helper-plugin-entitlements.plist",
    "//chrome/app/helper-renderer-entitlements.plist",
    "dirdiffer.sh",
    "dirpatcher.sh",
    "dmgdiffer.sh",
    "pkg-dmg",
    "pkg_postinstall.in",
    "sign_chrome.py",
    "universalizer.py",
  ]

  if (is_chrome_branded) {
    deps += [ ":copy_widevine_signing" ]
    sources += [
      "//chrome/app/theme/google_chrome/mac/app_beta.icns",
      "//chrome/app/theme/google_chrome/mac/app_canary.icns",
      "//chrome/app/theme/google_chrome/mac/app_dev.icns",
      "//chrome/app/theme/google_chrome/mac/document_beta.icns",
      "//chrome/app/theme/google_chrome/mac/document_canary.icns",
      "//chrome/app/theme/google_chrome/mac/document_dev.icns",
      "internal/Google_Chrome.765bb3620a0f7a33500da39b20122b1cec41140f.provisionprofile",
      "internal/Google_Chrome_Beta.765bb3620a0f7a33500da39b20122b1cec41140f.provisionprofile",
      "internal/Google_Chrome_Canary.765bb3620a0f7a33500da39b20122b1cec41140f.provisionprofile",
      "internal/Google_Chrome_Dev.765bb3620a0f7a33500da39b20122b1cec41140f.provisionprofile",
      "internal/chrome_beta_dmg_dsstore",
      "internal/chrome_beta_dmg_icon.icns",
      "internal/chrome_canary_dmg_dsstore",
      "internal/chrome_canary_dmg_icon.icns",
      "internal/chrome_dev_dmg_dsstore",
      "internal/chrome_dev_dmg_icon.icns",
      "internal/chrome_dmg_background.png",
      "internal/chrome_dmg_dsstore",
      "internal/chrome_dmg_icon.icns",
      "keystone_install.sh",

      # Provision profiles for staging signing.
      "internal/Google_Chrome.39364a56fb7fe353d10e70d38db822e5182cc420.provisionprofile",
      "internal/Google_Chrome_Beta.39364a56fb7fe353d10e70d38db822e5182cc420.provisionprofile",
      "internal/Google_Chrome_Canary.39364a56fb7fe353d10e70d38db822e5182cc420.provisionprofile",
      "internal/Google_Chrome_Dev.39364a56fb7fe353d10e70d38db822e5182cc420.provisionprofile",
    ]
  }

  outputs = [ "$_packaging_dir/{{source_file_part}}" ]
}

script_test("mac_signing_tests") {
  script = "//testing/scripts/run_isolated_script_test.py"

  args = [ "@WrappedPath(" + rebase_path(
               "//chrome/installer/mac/signing/run_mac_signing_tests.py",
               root_build_dir) + ")" ]

  data = mac_signing_sources + [
           "signing/commands_test.py",
           "signing/driver_test.py",
           "signing/model_test.py",
           "signing/modification_test.py",
           "signing/notarize_test.py",
           "signing/parts_test.py",
           "signing/pipeline_test.py",
           "signing/run_mac_signing_tests.py",
           "signing/signing_test.py",
           "signing/test_config.py",
           "//third_party/catapult/third_party/typ/",
         ]

  if (is_chrome_branded) {
    data += [ "internal/internal_invoker_test.py" ]
  }
}