1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94

build / config / apple / mobile_config.gni [blame]

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

declare_args() {
  # Configure the environment for which to build. Could be either "device",
  # "simulator" or "catalyst". Must be specified.
  target_environment = ""

  # Control whether codesiging is enabled (ignored for simulator builds).
  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
  ios_enable_code_signing = true

  # Explicitly select the identity to use for codesigning. If defined, must
  # be set to a non-empty string that will be passed to codesigning. Can be
  # left unspecified if ios_code_signing_identity_description is used instead.
  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
  ios_code_signing_identity = ""

  # Pattern used to select the identity to use for codesigning. If defined,
  # must be a substring of the description of exactly one of the identities by
  # `security find-identity -v -p codesigning`.
  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
  ios_code_signing_identity_description = "Apple Development"

  # Prefix for CFBundleIdentifier property of iOS bundles (correspond to the
  # "Organization Identifier" in Xcode). Code signing will fail if no mobile
  # provisioning for the selected code signing identify support that prefix.
  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
  ios_app_bundle_id_prefix = "org.chromium.ost"

  # Paths to the mobileprovision files for the chosen code signing
  # identity description and app bundle id prefix.
  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
  ios_mobileprovision_files = []
}

# As entitlements are tied to a specific bundle identifier, all the
# test applications share the same identifier. This simplifies adding
# new test application (since there is no need to investigate which
# entitlements they need, nor to wait for the mobile provision with
# those entitlements to be generated by Apple and then deployed to the
# infrastructure, ...). The drawback is that only one test application
# can be installed at a time on a device/simulator (as the bundle
# identifier uniquely identify an application).
#
# This variable corresponds to the test bundle identifier.
shared_bundle_id_for_test_apps =
    "$ios_app_bundle_id_prefix.chrome.unittests.dev"

# This file is included on all platforms, but the automatic configuration of
# the variables can only be executed if building for ios or watchos (as they
# either have no meaning or depend on tools that are only available on macOS).
if (is_ios || is_watchos) {
  # Check that target_environment is set to a supported value.
  _target_environments = [
    "simulator",
    "device",
  ]
  if (is_ios) {
    _target_environments += [ "catalyst" ]
  }
  assert(filter_include([ target_environment ], _target_environments) != [],
         "target_environment must be in $_target_environments: " +
             "$target_environment")

  if (target_environment == "device" && ios_enable_code_signing) {
    # If codesigning is enabled, user must configure either a codesigning
    # identity or a filter to automatically select the codesigning identity.
    assert(ios_code_signing_identity == "" ||
               ios_code_signing_identity_description == "",
           "You should either specify the precise identity to use with " +
               "ios_code_signing_identity or let the code select an identity " +
               "automatically (via find_signing_identity.py which use the " +
               "variable ios_code_signing_identity_description to set the " +
               "pattern to match the identity to use).")

    # Automatically select a codesigning identity if no identity is configured.
    # This only applies to device build as simulator builds are not signed.
    if (ios_code_signing_identity == "") {
      find_signing_identity_args = []
      if (ios_code_signing_identity_description != "") {
        find_signing_identity_args = [
          "--matching-pattern",
          ios_code_signing_identity_description,
        ]
      }
      ios_code_signing_identity =
          exec_script("//build/config/apple/find_signing_identity.py",
                      find_signing_identity_args,
                      "trim string")
    }
  }
}