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