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