• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2024 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/features.gni")  # For `use_blink`
6
7declare_args() {
8  # Configure the environment for which to build. Could be either "device",
9  # "simulator" or "catalyst". Must be specified.
10  target_environment = ""
11
12  # Valid values: "iphoneos" (default), "tvos", "watchos".
13  # Indicates the kind of iOS or iOS-based platform that is being targeted.
14  # Note that this value is available only when is_ios is also true (i.e. it
15  # cannot be used with the host toolchain).
16  target_platform = "iphoneos"
17
18  # Control whether codesiging is enabled (ignored for simulator builds).
19  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
20  ios_enable_code_signing = true
21
22  # Explicitly select the identity to use for codesigning. If defined, must
23  # be set to a non-empty string that will be passed to codesigning. Can be
24  # left unspecified if ios_code_signing_identity_description is used instead.
25  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
26  ios_code_signing_identity = ""
27
28  # Pattern used to select the identity to use for codesigning. If defined,
29  # must be a substring of the description of exactly one of the identities by
30  # `security find-identity -v -p codesigning`.
31  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
32  ios_code_signing_identity_description = "Apple Development"
33
34  # Prefix for CFBundleIdentifier property of iOS bundles (correspond to the
35  # "Organization Identifier" in Xcode). Code signing will fail if no mobile
36  # provisioning for the selected code signing identify support that prefix.
37  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
38  ios_app_bundle_id_prefix = "org.chromium.ost"
39
40  # Suffix for CFBundleIdentifier property of iOS Chrome signed bundles
41  # (main bundle and extensions). Code signing will fail if no mobile
42  # provisioning for the selected code signing identify support that suffix.
43  # For extension, the suffix will be added before the extension identifier.
44  # The suffix is not added to test applications.
45  # No dot is added before the suffix, so add one if needed.
46  apple_mobile_app_bundle_id_suffix = ".dev"
47
48  # Paths to the mobileprovision files for the chosen code signing
49  # identity description and app bundle id prefix.
50  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
51  ios_mobileprovision_files = []
52}
53
54# As entitlements are tied to a specific bundle identifier, all the
55# test applications share the same identifier. This simplifies adding
56# new test application (since there is no need to investigate which
57# entitlements they need, nor to wait for the mobile provision with
58# those entitlements to be generated by Apple and then deployed to the
59# infrastructure, ...). The drawback is that only one test application
60# can be installed at a time on a device/simulator (as the bundle
61# identifier uniquely identify an application).
62#
63# This variable corresponds to the test bundle identifier.
64shared_bundle_id_for_test_apps =
65    "$ios_app_bundle_id_prefix.chrome.unittests.dev"
66
67# This file is included on all platforms, but the automatic configuration of
68# the variables can only be executed if building for ios or watchos (as they
69# either have no meaning or depend on tools that are only available on macOS).
70if (is_ios || is_watchos) {
71  # Check that target_platform and target_environment are set to supported
72  # values.
73  _target_platforms = []
74  if (is_ios) {
75    _target_platforms += [
76      "iphoneos",
77      "tvos",
78    ]
79  } else if (is_watchos) {
80    _target_platforms += [
81      "iphoneos",
82      "watchos",
83    ]
84  }
85  assert(filter_include([ target_platform ], _target_platforms) != [],
86         "target_platform '$target_platform' does not match a target value: " +
87             "$_target_platforms")
88  _target_environments = [
89    "simulator",
90    "device",
91  ]
92  if (is_ios && target_platform == "iphoneos") {
93    _target_environments += [ "catalyst" ]
94  }
95  assert(filter_include([ target_environment ], _target_environments) != [],
96         "target_environment must be in $_target_environments: " +
97             "$target_environment")
98
99  if (target_environment == "device" && ios_enable_code_signing) {
100    # If codesigning is enabled, user must configure either a codesigning
101    # identity or a filter to automatically select the codesigning identity.
102    assert(ios_code_signing_identity == "" ||
103               ios_code_signing_identity_description == "",
104           "You should either specify the precise identity to use with " +
105               "ios_code_signing_identity or let the code select an identity " +
106               "automatically (via find_signing_identity.py which use the " +
107               "variable ios_code_signing_identity_description to set the " +
108               "pattern to match the identity to use).")
109
110    # Automatically select a codesigning identity if no identity is configured.
111    # This only applies to device build as simulator builds are not signed.
112    if (ios_code_signing_identity == "") {
113      find_signing_identity_args = []
114      if (ios_code_signing_identity_description != "") {
115        find_signing_identity_args = [
116          "--matching-pattern",
117          ios_code_signing_identity_description,
118        ]
119      }
120      ios_code_signing_identity =
121          exec_script("//build/config/apple/find_signing_identity.py",
122                      find_signing_identity_args,
123                      "trim string")
124    }
125  }
126
127  # Sanity check: tvOS builds require `use_blink`.
128  if (target_platform == "tvos") {
129    assert(use_blink, "tvOS builds require use_blink=true")
130  }
131}
132