• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 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/chrome_build.gni")
6import("//build/config/gclient_args.gni")
7import("//build/config/mac/mac_sdk_overrides.gni")
8import("//build/toolchain/goma.gni")
9import("//build/toolchain/rbe.gni")
10import("//build/toolchain/siso.gni")
11import("//build/toolchain/toolchain.gni")
12
13assert(
14    current_os == "mac" || current_toolchain == default_toolchain ||
15    (current_os == "ios" && current_toolchain == "${default_toolchain}_blink"))
16
17declare_args() {
18  # The following two variables control the minimum supported version for
19  # macOS:
20  #
21  # This variable affects how Chromium is compiled and corresponds to the
22  # `MACOSX_DEPLOYMENT_TARGET` define. Changing this controls which symbols
23  # the macOS SDK marks as available (via `__builtin_available` and
24  # `@available`) and deprecated (producing a warning if called). Modifying
25  # this variable often requires additional code changes to handle differences
26  # in availability and deprecation, which is why it is often changed
27  # separately from `mac_min_system_version` when dropping support for older
28  # macOSes.
29  mac_deployment_target = "10.15"
30
31  # The value of the `LSMinimumSystemVersion` in `Info.plist` files. This value
32  # controls the minimum OS version that may launch the application, and OS
33  # releases older than this will refuse to launch the application. When
34  # dropping support for older macOSes, this variable is often changed before
35  # `mac_deployment_target` to increase the system requirement without changing
36  # how Chromium is compiled. This must be greater than or equal to the
37  # `mac_deployment_target` version.
38  mac_min_system_version = "10.15"
39
40  # Path to a specific version of the Mac SDK, not including a slash at the end.
41  # If empty, the path to the lowest version greater than or equal to
42  # `mac_sdk_min` is used.
43  mac_sdk_path = ""
44
45  # The SDK name as accepted by `xcodebuild`.
46  mac_sdk_name = "macosx"
47
48  # The SDK version used when making official builds. This is a single exact
49  # version, not a minimum. If this version isn't available official builds
50  # will fail.
51  mac_sdk_official_version = "14.0"
52
53  # The SDK build version used when making official builds.  This is a single
54  # exact version found at "System/Library/CoreServices/SystemVersion.plist"
55  # inside the SDK.
56  mac_sdk_official_build_version = "23A334"
57
58  # Production builds should use hermetic Xcode. If you want to do production
59  # builds with system Xcode to test new SDKs, set this.
60  # Don't set this on any bots.
61  mac_allow_system_xcode_for_official_builds_for_testing = false
62}
63
64# Check that the version of macOS SDK used is the one requested when building
65# a version of Chrome shipped to the users. Disable the check if building for
66# iOS as the version macOS SDK used is not relevant for the tool build for the
67# host (they are not shipped) --- this is required as Chrome on iOS is usually
68# build with the latest version of Xcode that may not ship with the version of
69# the macOS SDK used to build Chrome on mac.
70# TODO(crbug.com/635745): the check for target_os should be replaced by a
71# check that current_toolchain is default_toolchain, and the file should
72# assert that current_os is "mac" once this file is no longer included by
73# iOS toolchains.
74if (is_chrome_branded && is_official_build && target_os != "ios") {
75  assert(!use_system_xcode ||
76             mac_allow_system_xcode_for_official_builds_for_testing,
77         "official branded builds should use hermetic xcode")
78}
79
80# The path to the hermetic install of Xcode. Only relevant when
81# use_system_xcode = false.
82if (!use_system_xcode) {
83  _hermetic_xcode_path = "//build/mac_files/xcode_binaries"
84}
85
86script_name = "//build/config/apple/sdk_info.py"
87sdk_info_args = []
88if (!use_system_xcode) {
89  sdk_info_args += [
90    "--developer_dir",
91    rebase_path(_hermetic_xcode_path, "", root_build_dir),
92  ]
93}
94
95# Goma RBE requires paths relative to source directory. When using system
96# Xcode, this is done by creating symbolic links in root_build_dir.
97if (use_system_xcode && (use_goma || use_remoteexec || use_siso)) {
98  sdk_info_args += [
99    "--get_sdk_info",
100    "--create_symlink_at",
101    "sdk/xcode_links",
102    "--root_build_dir",
103    root_build_dir,
104  ]
105}
106sdk_info_args += [ mac_sdk_name ]
107
108_mac_sdk_result = exec_script(script_name, sdk_info_args, "scope")
109xcode_version = _mac_sdk_result.xcode_version
110xcode_build = _mac_sdk_result.xcode_build
111if (mac_sdk_path == "" && use_system_xcode &&
112    (use_goma || use_remoteexec || use_siso)) {
113  mac_sdk_path = _mac_sdk_result.sdk_path
114}
115
116if (use_system_xcode) {
117  # The tool will print the SDK path on the first line, and the version on the
118  # second line.
119  find_sdk_args = [
120    "--print_sdk_path",
121    "--print_bin_path",
122    "--print_sdk_build",
123    mac_sdk_min,
124  ]
125  find_sdk_lines =
126      exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines")
127  mac_sdk_version = find_sdk_lines[3]
128  mac_sdk_build_version = find_sdk_lines[2]
129  if (mac_sdk_path == "") {
130    mac_sdk_path = find_sdk_lines[0]
131    mac_bin_path = find_sdk_lines[1]
132  } else {
133    mac_bin_path = find_sdk_lines[1]
134  }
135} else {
136  mac_sdk_version = mac_sdk_official_version
137  mac_sdk_build_version = mac_sdk_official_build_version
138  _dev = _hermetic_xcode_path + "/Contents/Developer"
139  _sdk = "MacOSX${mac_sdk_version}.sdk"
140  mac_sdk_path = _dev + "/Platforms/MacOSX.platform/Developer/SDKs/$_sdk"
141  mac_bin_path = _dev + "/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
142
143  # If we're using hermetic Xcode, then we want the paths to be relative so that
144  # generated ninja files are independent of the directory location.
145  # TODO(thakis): Do this at the uses of this variable instead.
146  mac_bin_path = rebase_path(mac_bin_path, root_build_dir)
147}
148