ios_sdk.gni (5043B)
1 # Copyright 2015 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 5 import("//chromium/build/config/apple/mobile_config.gni") 6 import("//chromium/build/config/ios/ios_sdk_overrides.gni") 7 import("//chromium/build/toolchain/rbe.gni") 8 import("//chromium/build/toolchain/siso.gni") 9 import("//chromium/build/toolchain/toolchain.gni") 10 import("//build_overrides/build.gni") 11 12 assert(current_os == "ios") 13 assert(use_system_xcode, "Hermetic xcode doesn't work for ios.") 14 15 declare_args() { 16 # SDK path to use. When empty this will use the default SDK based on the 17 # value of target_environment. 18 ios_bin_path = "" 19 ios_sdk_path = "" 20 ios_sdk_name = "" 21 ios_sdk_version = "" 22 ios_sdk_platform = "" 23 ios_sdk_platform_path = "" 24 ios_toolchains_path = "" 25 xcode_version = "" 26 xcode_version_int = 0 27 xcode_build = "" 28 machine_os_build = "" 29 30 # Set DEVELOPER_DIR while running sdk_info.py. 31 ios_sdk_developer_dir = "" 32 33 # Set to true if building an app extension. 34 ios_is_app_extension = false 35 } 36 37 # Building XCTests requires copying XCTRunner.app which is part of the iOS 38 # SDK (and shipped inside Xcode.app) into the application. When using the 39 # system installation of Xcode, those files are outside of the checkout. 40 # Using absolute path works with gn, however the distributed build system 41 # requires that all paths are relative to the checkout. This is faked by 42 # using symbolic links to the SDK inside of Xcode. Additionally, each build 43 # directory may use a distinct version of Xcode (e.g. to build with beta), 44 # so the symlink needs to be present in the $root_build_dir. However, when 45 # doing that, we need to list inputs pointing to file in $root_build_dir, 46 # and gn requires all files in $root_build_dir to be listed as outputs of 47 # another target. 48 # 49 # To fulfill all of those requirements, we 1. create symlinks pointing to 50 # the SDK files in Xcode, 2. declare a target listing the files as outputs 51 # (the target is a script that does nothing, it only pretends to create 52 # the files but they already exists). 53 # 54 # This works, but results in some files in $root_build_dir being links to 55 # files outside of the build directory. Running `ninja -t clean` will try 56 # to delete those files breaking Xcode installation. The recommendation is 57 # to use `gn clean` or `ninja -t cleandead` instead. 58 # 59 # This variable controls whether we create the symlink and the workaround 60 # is needed or not. See https://crbug.com/336382863#comment16 for details. 61 ios_use_xcode_symlinks = 62 ios_sdk_path == "" && use_system_xcode && use_remoteexec 63 64 if (ios_sdk_path == "") { 65 # Compute default target. 66 if (target_platform == "iphoneos") { 67 if (target_environment == "simulator") { 68 ios_sdk_name = "iphonesimulator" 69 ios_sdk_platform = "iPhoneSimulator" 70 } else if (target_environment == "device") { 71 ios_sdk_name = "iphoneos" 72 ios_sdk_platform = "iPhoneOS" 73 } else if (target_environment == "catalyst") { 74 ios_sdk_name = "macosx" 75 ios_sdk_platform = "MacOSX" 76 } else { 77 assert(false, "unsupported target_environment=$target_environment") 78 } 79 } else if (target_platform == "tvos") { 80 if (target_environment == "simulator") { 81 ios_sdk_name = "appletvsimulator" 82 ios_sdk_platform = "AppleTVSimulator" 83 } else if (target_environment == "device") { 84 ios_sdk_name = "appletvos" 85 ios_sdk_platform = "AppleTVOS" 86 } else { 87 assert(false, "unsupported target_environment=$target_environment") 88 } 89 } else { 90 assert(false, "unsupported target_platform=$target_platform") 91 } 92 93 ios_sdk_info_args = [ 94 "--get_sdk_info", 95 "--get_machine_info", 96 ] 97 ios_sdk_info_args += [ ios_sdk_name ] 98 if (ios_sdk_developer_dir != "") { 99 ios_sdk_info_args += [ 100 "--developer_dir", 101 ios_sdk_developer_dir, 102 ] 103 } 104 if (ios_use_xcode_symlinks) { 105 ios_sdk_info_args += [ 106 "--create_symlink_at", 107 "sdk/xcode_links", 108 "--root_build_dir", 109 root_build_dir, 110 ] 111 } 112 script_name = "//chromium/build/config/apple/sdk_info.py" 113 _ios_sdk_result = exec_script(script_name, ios_sdk_info_args, "scope") 114 ios_bin_path = 115 rebase_path("${_ios_sdk_result.toolchains_path}/usr/bin/", root_build_dir) 116 ios_sdk_path = _ios_sdk_result.sdk_path 117 ios_sdk_platform_path = _ios_sdk_result.sdk_platform_path 118 ios_sdk_version = _ios_sdk_result.sdk_version 119 ios_sdk_build = _ios_sdk_result.sdk_build 120 ios_toolchains_path = _ios_sdk_result.toolchains_path 121 xcode_version = _ios_sdk_result.xcode_version 122 xcode_version_int = _ios_sdk_result.xcode_version_int 123 xcode_build = _ios_sdk_result.xcode_build 124 machine_os_build = _ios_sdk_result.machine_os_build 125 if (target_environment == "simulator") { 126 # This is weird, but Xcode sets DTPlatformBuild to an empty field for 127 # simulator builds. 128 ios_platform_build = "" 129 } else { 130 ios_platform_build = ios_sdk_build 131 } 132 } 133 134 _sdk_root = rebase_path(ios_sdk_path, root_build_dir) 135 ios_sdk_logs = [ "ios_sdk_path=${_sdk_root}" ]