• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2015 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/ios/config.gni")
6import("//build/config/ios/ios_sdk_overrides.gni")
7import("//build/toolchain/goma.gni")
8import("//build/toolchain/rbe.gni")
9import("//build/toolchain/siso.gni")
10import("//build/toolchain/toolchain.gni")
11import("//build_overrides/build.gni")
12
13assert(current_os == "ios")
14assert(use_system_xcode, "Hermetic xcode doesn't work for ios.")
15
16declare_args() {
17  # SDK path to use. When empty this will use the default SDK based on the
18  # value of target_environment.
19  ios_bin_path = ""
20  ios_sdk_path = ""
21  ios_sdk_name = ""
22  ios_sdk_version = ""
23  ios_sdk_platform = ""
24  ios_sdk_platform_path = ""
25  ios_toolchains_path = ""
26  xcode_version = ""
27  xcode_version_int = 0
28  xcode_build = ""
29  machine_os_build = ""
30
31  # Set DEVELOPER_DIR while running sdk_info.py.
32  ios_sdk_developer_dir = ""
33
34  # Control whether codesiging is enabled (ignored for simulator builds).
35  ios_enable_code_signing = true
36
37  # Explicitly select the identity to use for codesigning. If defined, must
38  # be set to a non-empty string that will be passed to codesigning. Can be
39  # left unspecified if ios_code_signing_identity_description is used instead.
40  ios_code_signing_identity = ""
41
42  # Pattern used to select the identity to use for codesigning. If defined,
43  # must be a substring of the description of exactly one of the identities by
44  # `security find-identity -v -p codesigning`.
45  ios_code_signing_identity_description = "Apple Development"
46
47  # Prefix for CFBundleIdentifier property of iOS bundles (correspond to the
48  # "Organization Identifier" in Xcode). Code signing will fail if no mobile
49  # provisioning for the selected code signing identify support that prefix.
50  ios_app_bundle_id_prefix = "org.chromium.ost"
51
52  # Paths to the mobileprovision files for the chosen code signing
53  # identity description and app bundle id prefix.
54  ios_mobileprovision_files = []
55
56  # Set to true if building an app extension.
57  ios_is_app_extension = false
58}
59
60# If codesigning is enabled, use must configure either a codesigning identity
61# or a filter to automatically select the codesigning identity.
62if (target_environment == "device" && ios_enable_code_signing) {
63  assert(ios_code_signing_identity == "" ||
64             ios_code_signing_identity_description == "",
65         "You should either specify the precise identity to use with " +
66             "ios_code_signing_identity or let the code select an identity " +
67             "automatically (via find_signing_identity.py which use the " +
68             "variable ios_code_signing_identity_description to set the " +
69             "pattern to match the identity to use).")
70}
71
72if (ios_sdk_path == "") {
73  # Compute default target.
74  if (target_environment == "simulator") {
75    ios_sdk_name = "iphonesimulator"
76    ios_sdk_platform = "iPhoneSimulator"
77  } else if (target_environment == "device") {
78    ios_sdk_name = "iphoneos"
79    ios_sdk_platform = "iPhoneOS"
80  } else if (target_environment == "catalyst") {
81    ios_sdk_name = "macosx"
82    ios_sdk_platform = "MacOSX"
83  } else {
84    assert(false, "unsupported environment: $target_environment")
85  }
86
87  ios_sdk_info_args = [
88    "--get_sdk_info",
89    "--get_machine_info",
90  ]
91  ios_sdk_info_args += [ ios_sdk_name ]
92  if (ios_sdk_developer_dir != "") {
93    ios_sdk_info_args += [
94      "--developer_dir",
95      ios_sdk_developer_dir,
96    ]
97  }
98  if (use_system_xcode && (use_goma || use_remoteexec || use_siso)) {
99    ios_sdk_info_args += [
100      "--create_symlink_at",
101      "sdk/xcode_links",
102      "--root_build_dir",
103      root_build_dir,
104    ]
105  }
106  script_name = "//build/config/apple/sdk_info.py"
107  _ios_sdk_result = exec_script(script_name, ios_sdk_info_args, "scope")
108  ios_bin_path =
109      rebase_path("${_ios_sdk_result.toolchains_path}/usr/bin/", root_build_dir)
110  ios_sdk_path = _ios_sdk_result.sdk_path
111  ios_sdk_platform_path = _ios_sdk_result.sdk_platform_path
112  ios_sdk_version = _ios_sdk_result.sdk_version
113  ios_sdk_build = _ios_sdk_result.sdk_build
114  ios_toolchains_path = _ios_sdk_result.toolchains_path
115  xcode_version = _ios_sdk_result.xcode_version
116  xcode_version_int = _ios_sdk_result.xcode_version_int
117  xcode_build = _ios_sdk_result.xcode_build
118  machine_os_build = _ios_sdk_result.machine_os_build
119  if (target_environment == "simulator") {
120    # This is weird, but Xcode sets DTPlatformBuild to an empty field for
121    # simulator builds.
122    ios_platform_build = ""
123  } else {
124    ios_platform_build = ios_sdk_build
125  }
126}
127
128if (target_environment == "device" && ios_enable_code_signing) {
129  # Automatically select a codesigning identity if no identity is configured.
130  # This only applies to device build as simulator builds are not signed.
131  if (ios_code_signing_identity == "") {
132    find_signing_identity_args = []
133    if (ios_code_signing_identity_description != "") {
134      find_signing_identity_args = [
135        "--matching-pattern",
136        ios_code_signing_identity_description,
137      ]
138    }
139    ios_code_signing_identity = exec_script("find_signing_identity.py",
140                                            find_signing_identity_args,
141                                            "trim string")
142  }
143}
144
145# As entitlements are tied to a specific bundle identifier, all the
146# test application on iOS share the same identifier. This simplify
147# adding new test application (since there is no need to investigate
148# which entitlements they need, nor to wait for the mobile provision
149# with those entitlements to be generated by Apple and then deployed
150# to the infrastructure, ...). The drawback is that since only one
151# test application can be installed at a time on a device/simulator
152# (as the bundle identifier uniquely identify an application for iOS).
153#
154# This variable corresponds to the test bundle identifier.
155shared_bundle_id_for_test_apps =
156    "$ios_app_bundle_id_prefix.chrome.unittests.dev"
157