xref: /aosp_15_r20/external/angle/build/config/apple/mobile_config.gni (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2024 The Chromium Authors
2*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
3*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file.
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
6*8975f5c5SAndroid Build Coastguard Worker  # Configure the environment for which to build. Could be either "device",
7*8975f5c5SAndroid Build Coastguard Worker  # "simulator" or "catalyst". Must be specified.
8*8975f5c5SAndroid Build Coastguard Worker  target_environment = ""
9*8975f5c5SAndroid Build Coastguard Worker
10*8975f5c5SAndroid Build Coastguard Worker  # Control whether codesiging is enabled (ignored for simulator builds).
11*8975f5c5SAndroid Build Coastguard Worker  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
12*8975f5c5SAndroid Build Coastguard Worker  ios_enable_code_signing = true
13*8975f5c5SAndroid Build Coastguard Worker
14*8975f5c5SAndroid Build Coastguard Worker  # Explicitly select the identity to use for codesigning. If defined, must
15*8975f5c5SAndroid Build Coastguard Worker  # be set to a non-empty string that will be passed to codesigning. Can be
16*8975f5c5SAndroid Build Coastguard Worker  # left unspecified if ios_code_signing_identity_description is used instead.
17*8975f5c5SAndroid Build Coastguard Worker  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
18*8975f5c5SAndroid Build Coastguard Worker  ios_code_signing_identity = ""
19*8975f5c5SAndroid Build Coastguard Worker
20*8975f5c5SAndroid Build Coastguard Worker  # Pattern used to select the identity to use for codesigning. If defined,
21*8975f5c5SAndroid Build Coastguard Worker  # must be a substring of the description of exactly one of the identities by
22*8975f5c5SAndroid Build Coastguard Worker  # `security find-identity -v -p codesigning`.
23*8975f5c5SAndroid Build Coastguard Worker  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
24*8975f5c5SAndroid Build Coastguard Worker  ios_code_signing_identity_description = "Apple Development"
25*8975f5c5SAndroid Build Coastguard Worker
26*8975f5c5SAndroid Build Coastguard Worker  # Prefix for CFBundleIdentifier property of iOS bundles (correspond to the
27*8975f5c5SAndroid Build Coastguard Worker  # "Organization Identifier" in Xcode). Code signing will fail if no mobile
28*8975f5c5SAndroid Build Coastguard Worker  # provisioning for the selected code signing identify support that prefix.
29*8975f5c5SAndroid Build Coastguard Worker  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
30*8975f5c5SAndroid Build Coastguard Worker  ios_app_bundle_id_prefix = "org.chromium.ost"
31*8975f5c5SAndroid Build Coastguard Worker
32*8975f5c5SAndroid Build Coastguard Worker  # Paths to the mobileprovision files for the chosen code signing
33*8975f5c5SAndroid Build Coastguard Worker  # identity description and app bundle id prefix.
34*8975f5c5SAndroid Build Coastguard Worker  # TODO(crbug.com/378918882): Prefix with apple_mobile_ instead of ios_.
35*8975f5c5SAndroid Build Coastguard Worker  ios_mobileprovision_files = []
36*8975f5c5SAndroid Build Coastguard Worker}
37*8975f5c5SAndroid Build Coastguard Worker
38*8975f5c5SAndroid Build Coastguard Worker# As entitlements are tied to a specific bundle identifier, all the
39*8975f5c5SAndroid Build Coastguard Worker# test applications share the same identifier. This simplifies adding
40*8975f5c5SAndroid Build Coastguard Worker# new test application (since there is no need to investigate which
41*8975f5c5SAndroid Build Coastguard Worker# entitlements they need, nor to wait for the mobile provision with
42*8975f5c5SAndroid Build Coastguard Worker# those entitlements to be generated by Apple and then deployed to the
43*8975f5c5SAndroid Build Coastguard Worker# infrastructure, ...). The drawback is that only one test application
44*8975f5c5SAndroid Build Coastguard Worker# can be installed at a time on a device/simulator (as the bundle
45*8975f5c5SAndroid Build Coastguard Worker# identifier uniquely identify an application).
46*8975f5c5SAndroid Build Coastguard Worker#
47*8975f5c5SAndroid Build Coastguard Worker# This variable corresponds to the test bundle identifier.
48*8975f5c5SAndroid Build Coastguard Workershared_bundle_id_for_test_apps =
49*8975f5c5SAndroid Build Coastguard Worker    "$ios_app_bundle_id_prefix.chrome.unittests.dev"
50*8975f5c5SAndroid Build Coastguard Worker
51*8975f5c5SAndroid Build Coastguard Worker# This file is included on all platforms, but the automatic configuration of
52*8975f5c5SAndroid Build Coastguard Worker# the variables can only be executed if building for ios or watchos (as they
53*8975f5c5SAndroid Build Coastguard Worker# either have no meaning or depend on tools that are only available on macOS).
54*8975f5c5SAndroid Build Coastguard Workerif (is_ios || is_watchos) {
55*8975f5c5SAndroid Build Coastguard Worker  # Check that target_environment is set to a supported value.
56*8975f5c5SAndroid Build Coastguard Worker  _target_environments = [
57*8975f5c5SAndroid Build Coastguard Worker    "simulator",
58*8975f5c5SAndroid Build Coastguard Worker    "device",
59*8975f5c5SAndroid Build Coastguard Worker  ]
60*8975f5c5SAndroid Build Coastguard Worker  if (is_ios) {
61*8975f5c5SAndroid Build Coastguard Worker    _target_environments += [ "catalyst" ]
62*8975f5c5SAndroid Build Coastguard Worker  }
63*8975f5c5SAndroid Build Coastguard Worker  assert(filter_include([ target_environment ], _target_environments) != [],
64*8975f5c5SAndroid Build Coastguard Worker         "target_environment must be in $_target_environments: " +
65*8975f5c5SAndroid Build Coastguard Worker             "$target_environment")
66*8975f5c5SAndroid Build Coastguard Worker
67*8975f5c5SAndroid Build Coastguard Worker  if (target_environment == "device" && ios_enable_code_signing) {
68*8975f5c5SAndroid Build Coastguard Worker    # If codesigning is enabled, user must configure either a codesigning
69*8975f5c5SAndroid Build Coastguard Worker    # identity or a filter to automatically select the codesigning identity.
70*8975f5c5SAndroid Build Coastguard Worker    assert(ios_code_signing_identity == "" ||
71*8975f5c5SAndroid Build Coastguard Worker               ios_code_signing_identity_description == "",
72*8975f5c5SAndroid Build Coastguard Worker           "You should either specify the precise identity to use with " +
73*8975f5c5SAndroid Build Coastguard Worker               "ios_code_signing_identity or let the code select an identity " +
74*8975f5c5SAndroid Build Coastguard Worker               "automatically (via find_signing_identity.py which use the " +
75*8975f5c5SAndroid Build Coastguard Worker               "variable ios_code_signing_identity_description to set the " +
76*8975f5c5SAndroid Build Coastguard Worker               "pattern to match the identity to use).")
77*8975f5c5SAndroid Build Coastguard Worker
78*8975f5c5SAndroid Build Coastguard Worker    # Automatically select a codesigning identity if no identity is configured.
79*8975f5c5SAndroid Build Coastguard Worker    # This only applies to device build as simulator builds are not signed.
80*8975f5c5SAndroid Build Coastguard Worker    if (ios_code_signing_identity == "") {
81*8975f5c5SAndroid Build Coastguard Worker      find_signing_identity_args = []
82*8975f5c5SAndroid Build Coastguard Worker      if (ios_code_signing_identity_description != "") {
83*8975f5c5SAndroid Build Coastguard Worker        find_signing_identity_args = [
84*8975f5c5SAndroid Build Coastguard Worker          "--matching-pattern",
85*8975f5c5SAndroid Build Coastguard Worker          ios_code_signing_identity_description,
86*8975f5c5SAndroid Build Coastguard Worker        ]
87*8975f5c5SAndroid Build Coastguard Worker      }
88*8975f5c5SAndroid Build Coastguard Worker      ios_code_signing_identity =
89*8975f5c5SAndroid Build Coastguard Worker          exec_script("//build/config/apple/find_signing_identity.py",
90*8975f5c5SAndroid Build Coastguard Worker                      find_signing_identity_args,
91*8975f5c5SAndroid Build Coastguard Worker                      "trim string")
92*8975f5c5SAndroid Build Coastguard Worker    }
93*8975f5c5SAndroid Build Coastguard Worker  }
94*8975f5c5SAndroid Build Coastguard Worker}
95