• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("$build_root/config/mac/mac_sdk_overrides.gni")
15import("$build_root/toolchain/toolchain.gni")
16
17declare_args() {
18  mac_deployment_target = "10.13.0"
19
20  mac_min_system_version = "10.13.0"
21
22  # Path to a specific version of the Mac SDK, not including a slash at the end.
23  # If empty, the path to the lowest version greater than or equal to
24  # mac_sdk_min is used.
25  mac_sdk_path = ""
26
27  # The SDK name as accepted by xcodebuild.
28  mac_sdk_name = "macosx"
29}
30
31# Check that the version of macOS SDK used is the one requested when building
32# a version of Chrome shipped to the users. Disable the check if building for
33# iOS as the version macOS SDK used is not relevant for the tool build for the
34# host (they are not shipped) --- this is required as Chrome on iOS is usually
35# build with the latest version of Xcode that may not ship with the version of
36# the macOS SDK used to build Chrome on mac.
37_verify_sdk = is_official_build && target_os != "ios"
38
39find_sdk_args = [ "--print_sdk_path" ]
40if (!use_system_xcode) {
41  find_sdk_args += [
42    "--developer_dir",
43    hermetic_xcode_path,
44  ]
45}
46if (_verify_sdk) {
47  find_sdk_args += [
48    "--verify",
49    mac_sdk_min,
50    "--sdk_path=" + mac_sdk_path,
51  ]
52} else {
53  find_sdk_args += [ mac_sdk_min ]
54}
55
56# The tool will print the SDK path on the first line, and the version on the
57# second line.
58find_sdk_lines =
59    exec_script("$build_root/misc/mac/find_sdk.py", find_sdk_args, "list lines")
60
61mac_sdk_version = find_sdk_lines[1]
62if (mac_sdk_path == "") {
63  mac_sdk_path = find_sdk_lines[0]
64}
65
66script_name = "$build_root/config/mac/sdk_info.py"
67sdk_info_args = []
68if (!use_system_xcode) {
69  sdk_info_args += [
70    "--developer_dir",
71    hermetic_xcode_path,
72  ]
73}
74sdk_info_args += [ mac_sdk_name ]
75
76_mac_sdk_result = exec_script(script_name, sdk_info_args, "scope")
77xcode_version = _mac_sdk_result.xcode_version
78xcode_build = _mac_sdk_result.xcode_build
79machine_os_build = _mac_sdk_result.machine_os_build
80xcode_version_int = _mac_sdk_result.xcode_version_int
81
82if (mac_sdk_version != mac_sdk_min &&
83    exec_script("$build_root/misc/mac/check_return_value.py",
84                [
85                  "test",
86                  xcode_version,
87                  "-ge",
88                  "0730",
89                ],
90                "value") != 1) {
91  print(
92      "********************************************************************************")
93  print(
94      " WARNING: The Mac OS X SDK is incompatible with the version of Xcode. To fix,")
95  print(
96      "          either upgrade Xcode to the latest version or install the Mac OS X")
97  print(
98      "          $mac_sdk_min SDK. For more information, see https://crbug.com/620127.")
99  print()
100  print(" Current SDK Version:   $mac_sdk_version")
101  print(" Current Xcode Version: $xcode_version ($xcode_build)")
102  print(
103      "********************************************************************************")
104  assert(false, "SDK is incompatible with Xcode")
105}
106