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