| # Copyright 2015 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/apple/mobile_config.gni") |
| import("//build/config/ios/ios_sdk_overrides.gni") |
| import("//build/toolchain/rbe.gni") |
| import("//build/toolchain/siso.gni") |
| import("//build/toolchain/toolchain.gni") |
| import("//build_overrides/build.gni") |
| |
| assert(current_os == "ios") |
| assert(use_system_xcode, "Hermetic xcode doesn't work for ios.") |
| |
| declare_args() { |
| # SDK path to use. When empty this will use the default SDK based on the |
| # value of target_environment. |
| ios_bin_path = "" |
| ios_sdk_path = "" |
| ios_sdk_name = "" |
| ios_sdk_version = "" |
| ios_sdk_platform = "" |
| ios_sdk_platform_path = "" |
| ios_toolchains_path = "" |
| xcode_version = "" |
| xcode_version_int = 0 |
| xcode_build = "" |
| machine_os_build = "" |
| |
| # Set DEVELOPER_DIR while running sdk_info.py. |
| ios_sdk_developer_dir = "" |
| |
| # Set to true if building an app extension. |
| ios_is_app_extension = false |
| |
| # Set to `target_platform` to generate Xcode project with the |
| # corresponding platform SDK. |
| target_xcode_platform = target_platform |
| } |
| |
| # Building XCTests requires copying XCTRunner.app which is part of the iOS |
| # SDK (and shipped inside Xcode.app) into the application. When using the |
| # system installation of Xcode, those files are outside of the checkout. |
| # Using absolute path works with gn, however the distributed build system |
| # requires that all paths are relative to the checkout. This is faked by |
| # using symbolic links to the SDK inside of Xcode. Additionally, each build |
| # directory may use a distinct version of Xcode (e.g. to build with beta), |
| # so the symlink needs to be present in the $root_build_dir. However, when |
| # doing that, we need to list inputs pointing to file in $root_build_dir, |
| # and gn requires all files in $root_build_dir to be listed as outputs of |
| # another target. |
| # |
| # To fulfill all of those requirements, we 1. create symlinks pointing to |
| # the SDK files in Xcode, 2. declare a target listing the files as outputs |
| # (the target is a script that does nothing, it only pretends to create |
| # the files but they already exists). |
| # |
| # This works, but results in some files in $root_build_dir being links to |
| # files outside of the build directory. Running `ninja -t clean` will try |
| # to delete those files breaking Xcode installation. The recommendation is |
| # to use `gn clean` or `ninja -t cleandead` instead. |
| # |
| # This variable controls whether we create the symlink and the workaround |
| # is needed or not. See https://crbug.com/336382863#comment16 for details. |
| ios_use_xcode_symlinks = |
| ios_sdk_path == "" && use_system_xcode && use_remoteexec |
| |
| if (ios_sdk_path == "") { |
| # Compute default target. |
| if (target_platform == "iphoneos") { |
| if (target_environment == "simulator") { |
| ios_sdk_name = "iphonesimulator" |
| ios_sdk_platform = "iPhoneSimulator" |
| } else if (target_environment == "device") { |
| ios_sdk_name = "iphoneos" |
| ios_sdk_platform = "iPhoneOS" |
| } else if (target_environment == "catalyst") { |
| ios_sdk_name = "macosx" |
| ios_sdk_platform = "MacOSX" |
| } else { |
| assert(false, "unsupported target_environment=$target_environment") |
| } |
| } else if (target_platform == "tvos") { |
| if (target_environment == "simulator") { |
| ios_sdk_name = "appletvsimulator" |
| ios_sdk_platform = "AppleTVSimulator" |
| } else if (target_environment == "device") { |
| ios_sdk_name = "appletvos" |
| ios_sdk_platform = "AppleTVOS" |
| } else { |
| assert(false, "unsupported target_environment=$target_environment") |
| } |
| } else { |
| assert(false, "unsupported target_platform=$target_platform") |
| } |
| |
| ios_sdk_info_args = [ |
| "--get_sdk_info", |
| "--get_machine_info", |
| ] |
| ios_sdk_info_args += [ ios_sdk_name ] |
| if (ios_sdk_developer_dir != "") { |
| ios_sdk_info_args += [ |
| "--developer_dir", |
| ios_sdk_developer_dir, |
| ] |
| } |
| if (ios_use_xcode_symlinks) { |
| ios_sdk_info_args += [ |
| "--create_symlink_at", |
| "sdk/xcode_links", |
| "--root_build_dir", |
| root_build_dir, |
| ] |
| } |
| script_name = "//build/config/apple/sdk_info.py" |
| _ios_sdk_result = exec_script(script_name, ios_sdk_info_args, "scope") |
| ios_bin_path = |
| rebase_path("${_ios_sdk_result.toolchains_path}/usr/bin/", root_build_dir) |
| ios_sdk_path = _ios_sdk_result.sdk_path |
| ios_sdk_platform_path = _ios_sdk_result.sdk_platform_path |
| ios_sdk_version = _ios_sdk_result.sdk_version |
| ios_sdk_build = _ios_sdk_result.sdk_build |
| ios_toolchains_path = _ios_sdk_result.toolchains_path |
| xcode_version = _ios_sdk_result.xcode_version |
| xcode_version_int = _ios_sdk_result.xcode_version_int |
| xcode_build = _ios_sdk_result.xcode_build |
| machine_os_build = _ios_sdk_result.machine_os_build |
| if (target_environment == "simulator") { |
| # This is weird, but Xcode sets DTPlatformBuild to an empty field for |
| # simulator builds. |
| ios_platform_build = "" |
| } else { |
| ios_platform_build = ios_sdk_build |
| } |
| } |
| |
| _sdk_root = rebase_path(ios_sdk_path, root_build_dir) |
| ios_sdk_logs = [ "ios_sdk_path=${_sdk_root}" ] |