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 12# Allow Android builds on macOS 13assert(current_os == "mac" || current_toolchain == default_toolchain || 14 target_os == "android") 15 16declare_args() { 17 # The following two variables control the minimum supported version for 18 # macOS: 19 # 20 # This variable affects how Chromium is compiled and corresponds to the 21 # `MACOSX_DEPLOYMENT_TARGET` define. Changing this controls which symbols 22 # the macOS SDK marks as available (via `__builtin_available` and 23 # `@available`) and deprecated (producing a warning if called). Modifying 24 # this variable often requires additional code changes to handle differences 25 # in availability and deprecation, which is why it is often changed 26 # separately from `mac_min_system_version` when dropping support for older 27 # macOSes. 28 mac_deployment_target = "11.0" 29 30 # The value of the `LSMinimumSystemVersion` in `Info.plist` files. This value 31 # controls the minimum OS version that may launch the application, and OS 32 # releases older than this will refuse to launch the application. When 33 # dropping support for older macOSes, this variable is often changed before 34 # `mac_deployment_target` to increase the system requirement without changing 35 # how Chromium is compiled. This must be greater than or equal to the 36 # `mac_deployment_target` version. 37 mac_min_system_version = "11.0" 38 39 # Path to a specific version of the Mac SDK, not including a slash at the end. 40 # If empty, the path to the lowest version greater than or equal to 41 # `mac_sdk_min` is used. 42 mac_sdk_path = "" 43 44 # The SDK name as accepted by `xcodebuild`. 45 mac_sdk_name = "macosx" 46 47 # The SDK version used when making official builds. This is a single exact 48 # version, not a minimum. If this version isn't available official builds 49 # will fail. 50 mac_sdk_official_version = "15.1" 51 52 # The SDK build version used when making official builds. This is a single 53 # exact version found at "System/Library/CoreServices/SystemVersion.plist" 54 # inside the SDK. 55 mac_sdk_official_build_version = "24B75" 56 57 # Production builds should use hermetic Xcode. If you want to do production 58 # builds with system Xcode to test new SDKs, set this. 59 # Don't set this on any bots. 60 mac_allow_system_xcode_for_official_builds_for_testing = false 61} 62 63# Check that the version of macOS SDK used is the one requested when building 64# a version of Chrome shipped to the users. Disable the check if building for 65# iOS as the version macOS SDK used is not relevant for the tool build for the 66# host (they are not shipped) --- this is required as Chrome on iOS is usually 67# build with the latest version of Xcode that may not ship with the version of 68# the macOS SDK used to build Chrome on mac. 69# TODO(crbug.com/40479759): the check for target_os should be replaced by a 70# check that current_toolchain is default_toolchain, and the file should 71# assert that current_os is "mac" once this file is no longer included by 72# iOS toolchains. 73if (is_chrome_branded && is_official_build && target_os != "ios") { 74 assert(!use_system_xcode || 75 mac_allow_system_xcode_for_official_builds_for_testing, 76 "official branded builds should use hermetic xcode") 77} 78 79# The path to the hermetic install of Xcode. Only relevant when 80# use_system_xcode = false. 81if (!use_system_xcode) { 82 _hermetic_xcode_path = "//build/mac_files/xcode_binaries" 83} 84 85script_name = "//build/config/apple/sdk_info.py" 86sdk_info_args = [] 87if (!use_system_xcode) { 88 sdk_info_args += [ 89 "--developer_dir", 90 rebase_path(_hermetic_xcode_path, "", root_build_dir), 91 ] 92} 93 94# Building crashpard requires some files that are part of the macOS SDK 95# (and shipped inside Xcode.app) into the application. When using the 96# system installation of Xcode, those files are outside of the checkout. 97# Using absolute path works with gn, however the distributed build system 98# requires that all paths are relative to the checkout. This is faked by 99# using symbolic links to the SDK inside of Xcode. Additionally, each build 100# directory may use a distinct version of Xcode (e.g. to build with beta), 101# so the symlink needs to be present in the $root_build_dir. However, when 102# doing that, we need to list inputs pointing to file in $root_build_dir, 103# and gn requires all files in $root_build_dir to be listed as outputs of 104# another target. 105# 106# To fulfill all of those requirements, we 1. create symlinks pointing to 107# the SDK files in Xcode, 2. declare a target listing the files as outputs 108# (the target is a script that does nothing, it only pretends to create 109# the files but they already exists). 110# 111# This works, but results in some files in $root_build_dir being links to 112# files outside of the build directory. Running `ninja -t clean` will try 113# to delete those files breaking Xcode installation. The recommendation is 114# to use `gn clean` or `ninja -t cleandead` instead. 115# 116# This variable controls whether we create the symlink and the workaround 117# is needed or not. See https://crbug.com/336382863#comment16 for details. 118mac_use_xcode_symlinks = use_system_xcode && use_remoteexec 119 120# RBE requires paths relative to source directory. When using system 121# Xcode, this is done by creating symbolic links in root_build_dir. 122if (mac_use_xcode_symlinks) { 123 sdk_info_args += [ 124 "--get_sdk_info", 125 "--create_symlink_at", 126 "sdk/xcode_links", 127 "--root_build_dir", 128 root_build_dir, 129 ] 130} 131sdk_info_args += [ mac_sdk_name ] 132 133_mac_sdk_result = exec_script(script_name, sdk_info_args, "scope") 134xcode_version = _mac_sdk_result.xcode_version 135xcode_build = _mac_sdk_result.xcode_build 136if (mac_sdk_path == "" && use_system_xcode && use_remoteexec) { 137 mac_sdk_path = _mac_sdk_result.sdk_path 138} 139 140if (use_system_xcode) { 141 # The tool will print the SDK path on the first line, and the version on the 142 # second line. 143 find_sdk_args = [ 144 "--print_sdk_path", 145 "--print_bin_path", 146 "--print_sdk_build", 147 mac_sdk_min, 148 ] 149 find_sdk_lines = 150 exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines") 151 mac_sdk_version = find_sdk_lines[3] 152 mac_sdk_build_version = find_sdk_lines[2] 153 if (mac_sdk_path == "") { 154 mac_sdk_path = find_sdk_lines[0] 155 mac_bin_path = find_sdk_lines[1] 156 } else { 157 mac_bin_path = find_sdk_lines[1] 158 } 159} else { 160 mac_sdk_version = mac_sdk_official_version 161 mac_sdk_build_version = mac_sdk_official_build_version 162 _dev = _hermetic_xcode_path + "/Contents/Developer" 163 _sdk = "MacOSX${mac_sdk_version}.sdk" 164 mac_sdk_path = _dev + "/Platforms/MacOSX.platform/Developer/SDKs/$_sdk" 165 mac_bin_path = _dev + "/Toolchains/XcodeDefault.xctoolchain/usr/bin/" 166 167 # If we're using hermetic Xcode, then we want the paths to be relative so that 168 # generated ninja files are independent of the directory location. 169 # TODO(thakis): Do this at the uses of this variable instead. 170 mac_bin_path = rebase_path(mac_bin_path, root_build_dir) 171} 172 173_sdk_root = rebase_path(mac_sdk_path, root_build_dir) 174mac_sdk_logs = [ "mac_sdk_path=${_sdk_root}" ] 175