Commit c1ae5bbc authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

[ios] Add support for toolchain using 14.0 deployment target

Add new toolchains for using 14.0 deployment target. This will be
used by Widget extensions (which needs to have that deployment
target).

Add new gn variables to detect if a secondary toolchain exists for
"fat" build or not. This was previously done by checking whether
the current_toolchain is the default_toolchain but this is no longer
valid with toolchains used for other purposes.

Bug: 1138714
Change-Id: I7705dafd2d6273a0cc77d78e5630d5c8651ea3d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504229
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMike Pinkerton <pinkerton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822121}
parent e71649cc
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/ios/ios_sdk.gni")
# This template declares a bundle_data target that references an asset # This template declares a bundle_data target that references an asset
# catalog so that it is compiled to the asset catalog of the generated # catalog so that it is compiled to the asset catalog of the generated
# bundle. # bundle.
...@@ -46,9 +48,9 @@ template("asset_catalog") { ...@@ -46,9 +48,9 @@ template("asset_catalog") {
assert(defined(invoker.asset_type) && invoker.asset_type != "", assert(defined(invoker.asset_type) && invoker.asset_type != "",
"asset_type must be defined and not empty for $target_name") "asset_type must be defined and not empty for $target_name")
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
group(target_name) { group(target_name) {
public_deps = [ ":$target_name($default_toolchain)" ] public_deps = [ ":$target_name($primary_fat_toolchain_name)" ]
} }
} else { } else {
_copy_target_name = target_name + "__copy" _copy_target_name = target_name + "__copy"
......
...@@ -68,6 +68,16 @@ declare_args() { ...@@ -68,6 +68,16 @@ declare_args() {
target_environment = "" target_environment = ""
} }
declare_args() {
# This variable is set by the toolchain. It is set to true if the toolchain
# is a secondary toolchain as part of a "fat" build.
is_fat_secondary_toolchain = false
# This variable is set by the toolchain. It is the name of the primary
# toolchain for the fat build (could be current_toolchain).
primary_fat_toolchain_name = ""
}
if (target_environment == "") { if (target_environment == "") {
if (current_cpu == "x86" || current_cpu == "x64") { if (current_cpu == "x86" || current_cpu == "x64") {
target_environment = "simulator" target_environment = "simulator"
...@@ -108,7 +118,7 @@ if (additional_target_cpus != []) { ...@@ -108,7 +118,7 @@ if (additional_target_cpus != []) {
assert(_additional_target_cpu != target_cpu, assert(_additional_target_cpu != target_cpu,
"target_cpu must not be listed in additional_target_cpus") "target_cpu must not be listed in additional_target_cpus")
_toolchain = "//build/toolchain/mac:ios_clang_$_additional_target_cpu" _toolchain = "//build/toolchain/mac:ios_clang_${_additional_target_cpu}_fat"
foreach(_additional_toolchain, additional_toolchains) { foreach(_additional_toolchain, additional_toolchains) {
assert(_toolchain != _additional_toolchain, assert(_toolchain != _additional_toolchain,
"additional_target_cpus must not contains duplicate values") "additional_target_cpus must not contains duplicate values")
......
...@@ -602,6 +602,11 @@ template("ios_app_bundle") { ...@@ -602,6 +602,11 @@ template("ios_app_bundle") {
_output_name = invoker.output_name _output_name = invoker.output_name
} }
_primary_toolchain = current_toolchain
if (is_fat_secondary_toolchain) {
_primary_toolchain = primary_fat_toolchain_name
}
assert( assert(
!defined(invoker.bundle_extension), !defined(invoker.bundle_extension),
"bundle_extension must not be set for ios_app_bundle template for $target_name") "bundle_extension must not be set for ios_app_bundle template for $target_name")
...@@ -681,11 +686,10 @@ template("ios_app_bundle") { ...@@ -681,11 +686,10 @@ template("ios_app_bundle") {
visibility = [ ":$_arch_executable_target" ] visibility = [ ":$_arch_executable_target" ]
} }
if (current_toolchain == default_toolchain || if (!is_fat_secondary_toolchain || target_environment == "simulator") {
target_environment == "simulator") {
_generate_entitlements_target = _target_name + "_gen_entitlements" _generate_entitlements_target = _target_name + "_gen_entitlements"
_generate_entitlements_output = _generate_entitlements_output =
get_label_info(":$_generate_entitlements_target($default_toolchain)", get_label_info(":$_generate_entitlements_target($_primary_toolchain)",
"target_out_dir") + "/$_output_name.xcent" "target_out_dir") + "/$_output_name.xcent"
} }
...@@ -724,8 +728,8 @@ template("ios_app_bundle") { ...@@ -724,8 +728,8 @@ template("ios_app_bundle") {
"visibility", "visibility",
]) ])
visibility = [ ":$_lipo_executable_target($default_toolchain)" ] visibility = [ ":$_lipo_executable_target($_primary_toolchain)" ]
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
visibility += [ ":$_target_name" ] visibility += [ ":$_target_name" ]
} }
...@@ -740,7 +744,7 @@ template("ios_app_bundle") { ...@@ -740,7 +744,7 @@ template("ios_app_bundle") {
frameworks += [ "UIKit.framework" ] frameworks += [ "UIKit.framework" ]
if (target_environment == "simulator") { if (target_environment == "simulator") {
deps += [ ":$_generate_entitlements_target($default_toolchain)" ] deps += [ ":$_generate_entitlements_target($_primary_toolchain)" ]
if (!defined(inputs)) { if (!defined(inputs)) {
inputs = [] inputs = []
...@@ -759,7 +763,7 @@ template("ios_app_bundle") { ...@@ -759,7 +763,7 @@ template("ios_app_bundle") {
output_dir = "$target_out_dir/$current_cpu" output_dir = "$target_out_dir/$current_cpu"
} }
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
# For fat builds, only the default toolchain will generate an application # For fat builds, only the default toolchain will generate an application
# bundle. For the other toolchains, the template is only used for building # bundle. For the other toolchains, the template is only used for building
# the arch-specific binary, thus the default target is just a group(). # the arch-specific binary, thus the default target is just a group().
...@@ -802,7 +806,7 @@ template("ios_app_bundle") { ...@@ -802,7 +806,7 @@ template("ios_app_bundle") {
executable_name = _output_name executable_name = _output_name
} }
if (current_toolchain == default_toolchain) { if (!is_fat_secondary_toolchain) {
if (!defined(invoker.entitlements_target)) { if (!defined(invoker.entitlements_target)) {
_entitlements_path = "//build/config/ios/entitlements.plist" _entitlements_path = "//build/config/ios/entitlements.plist"
if (defined(invoker.entitlements_path)) { if (defined(invoker.entitlements_path)) {
...@@ -942,7 +946,7 @@ template("ios_app_bundle") { ...@@ -942,7 +946,7 @@ template("ios_app_bundle") {
} }
} }
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
not_needed("*") not_needed("*")
} }
} }
...@@ -1247,13 +1251,18 @@ template("ios_framework_bundle") { ...@@ -1247,13 +1251,18 @@ template("ios_framework_bundle") {
_has_public_headers = _has_public_headers =
defined(invoker.public_headers) && invoker.public_headers != [] defined(invoker.public_headers) && invoker.public_headers != []
_primary_toolchain = current_toolchain
if (is_fat_secondary_toolchain) {
_primary_toolchain = primary_fat_toolchain_name
}
# Public configs are not propagated across toolchain (see crbug.com/675224) # Public configs are not propagated across toolchain (see crbug.com/675224)
# so some configs have to be defined for both default_toolchain and all others # so some configs have to be defined for both default_toolchain and all others
# toolchains when performing a fat build. Use "get_label_info" to construct # toolchains when performing a fat build. Use "get_label_info" to construct
# the path since they need to be relative to the default_toolchain. # the path since they need to be relative to the default_toolchain.
_default_toolchain_root_out_dir = _default_toolchain_root_out_dir =
get_label_info("$_target_name($default_toolchain)", "root_out_dir") get_label_info("$_target_name($_primary_toolchain)", "root_out_dir")
_arch_shared_library_source = _target_name + "_arch_shared_library_sources" _arch_shared_library_source = _target_name + "_arch_shared_library_sources"
_arch_shared_library_target = _target_name + "_arch_shared_library" _arch_shared_library_target = _target_name + "_arch_shared_library"
...@@ -1262,7 +1271,7 @@ template("ios_framework_bundle") { ...@@ -1262,7 +1271,7 @@ template("ios_framework_bundle") {
if (_has_public_headers) { if (_has_public_headers) {
_default_toolchain_target_gen_dir = _default_toolchain_target_gen_dir =
get_label_info("$_target_name($default_toolchain)", "target_gen_dir") get_label_info("$_target_name($_primary_toolchain)", "target_gen_dir")
_framework_headers_target = _target_name + "_framework_headers" _framework_headers_target = _target_name + "_framework_headers"
...@@ -1313,7 +1322,7 @@ template("ios_framework_bundle") { ...@@ -1313,7 +1322,7 @@ template("ios_framework_bundle") {
if (!defined(deps)) { if (!defined(deps)) {
deps = [] deps = []
} }
deps += [ ":$_framework_headers_target($default_toolchain)" ] deps += [ ":$_framework_headers_target($_primary_toolchain)" ]
} }
} }
...@@ -1334,8 +1343,8 @@ template("ios_framework_bundle") { ...@@ -1334,8 +1343,8 @@ template("ios_framework_bundle") {
"visibility", "visibility",
]) ])
visibility = [ ":$_lipo_shared_library_target($default_toolchain)" ] visibility = [ ":$_lipo_shared_library_target($_primary_toolchain)" ]
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
visibility += [ visibility += [
":${_target_name}", ":${_target_name}",
":${_target_name}_signed_bundle", ":${_target_name}_signed_bundle",
...@@ -1347,7 +1356,7 @@ template("ios_framework_bundle") { ...@@ -1347,7 +1356,7 @@ template("ios_framework_bundle") {
} }
deps += [ ":$_arch_shared_library_source" ] deps += [ ":$_arch_shared_library_source" ]
if (_has_public_headers) { if (_has_public_headers) {
deps += [ ":$_framework_headers_target($default_toolchain)" ] deps += [ ":$_framework_headers_target($_primary_toolchain)" ]
} }
if (!defined(ldflags)) { if (!defined(ldflags)) {
ldflags = [] ldflags = []
...@@ -1361,7 +1370,7 @@ template("ios_framework_bundle") { ...@@ -1361,7 +1370,7 @@ template("ios_framework_bundle") {
output_dir = "$target_out_dir/$current_cpu" output_dir = "$target_out_dir/$current_cpu"
} }
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
# For fat builds, only the default toolchain will generate a framework # For fat builds, only the default toolchain will generate a framework
# bundle. For the other toolchains, the template is only used for building # bundle. For the other toolchains, the template is only used for building
# the arch-specific binary, thus the default target is just a group(). # the arch-specific binary, thus the default target is just a group().
...@@ -1382,7 +1391,7 @@ template("ios_framework_bundle") { ...@@ -1382,7 +1391,7 @@ template("ios_framework_bundle") {
"visibility", "visibility",
"testonly", "testonly",
]) ])
public_deps = [ ":$_link_target_name($default_toolchain)" ] public_deps = [ ":$_link_target_name($_primary_toolchain)" ]
if (_has_public_headers) { if (_has_public_headers) {
if (!defined(public_configs)) { if (!defined(public_configs)) {
...@@ -1398,7 +1407,7 @@ template("ios_framework_bundle") { ...@@ -1398,7 +1407,7 @@ template("ios_framework_bundle") {
group("$_target_name+bundle") { group("$_target_name+bundle") {
forward_variables_from(invoker, [ "testonly" ]) forward_variables_from(invoker, [ "testonly" ])
public_deps = [ ":$_target_name+bundle($default_toolchain)" ] public_deps = [ ":$_target_name+bundle($_primary_toolchain)" ]
} }
not_needed(invoker, "*") not_needed(invoker, "*")
...@@ -1658,7 +1667,7 @@ template("ios_xctest_bundle") { ...@@ -1658,7 +1667,7 @@ template("ios_xctest_bundle") {
# Silence "assignment had no effect" error for non-default toolchains as # Silence "assignment had no effect" error for non-default toolchains as
# following variables are only used in the expansion of the template for the # following variables are only used in the expansion of the template for the
# default toolchain. # default toolchain.
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
not_needed(invoker, "*") not_needed(invoker, "*")
} }
...@@ -1673,6 +1682,11 @@ template("ios_xctest_bundle") { ...@@ -1673,6 +1682,11 @@ template("ios_xctest_bundle") {
_arch_loadable_module_target = _target_name + "_arch_loadable_module" _arch_loadable_module_target = _target_name + "_arch_loadable_module"
_lipo_loadable_module_target = _target_name + "_loadable_module" _lipo_loadable_module_target = _target_name + "_loadable_module"
_primary_toolchain = current_toolchain
if (is_fat_secondary_toolchain) {
_primary_toolchain = primary_fat_toolchain_name
}
source_set(_arch_loadable_module_source) { source_set(_arch_loadable_module_source) {
forward_variables_from(invoker, [ "deps" ]) forward_variables_from(invoker, [ "deps" ])
...@@ -1682,8 +1696,8 @@ template("ios_xctest_bundle") { ...@@ -1682,8 +1696,8 @@ template("ios_xctest_bundle") {
loadable_module(_arch_loadable_module_target) { loadable_module(_arch_loadable_module_target) {
testonly = true testonly = true
visibility = [ ":$_lipo_loadable_module_target($default_toolchain)" ] visibility = [ ":$_lipo_loadable_module_target($_primary_toolchain)" ]
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
visibility += [ ":$_target_name" ] visibility += [ ":$_target_name" ]
} }
...@@ -1696,7 +1710,7 @@ template("ios_xctest_bundle") { ...@@ -1696,7 +1710,7 @@ template("ios_xctest_bundle") {
output_extension = "" output_extension = ""
} }
if (current_toolchain != default_toolchain) { if (is_fat_secondary_toolchain) {
# For fat builds, only the default toolchain will generate a test bundle. # For fat builds, only the default toolchain will generate a test bundle.
# For the other toolchains, the template is only used for building the # For the other toolchains, the template is only used for building the
# arch-specific binary, thus the default target is just a group(). # arch-specific binary, thus the default target is just a group().
...@@ -1888,7 +1902,7 @@ template("ios_xctest_test") { ...@@ -1888,7 +1902,7 @@ template("ios_xctest_test") {
] ]
_xctest_bundle = _xctest_target + "_bundle" _xctest_bundle = _xctest_target + "_bundle"
if (current_toolchain == default_toolchain) { if (!is_fat_secondary_toolchain) {
if (!defined(bundle_deps)) { if (!defined(bundle_deps)) {
bundle_deps = [] bundle_deps = []
} }
......
...@@ -69,6 +69,7 @@ if (current_toolchain == default_toolchain) { ...@@ -69,6 +69,7 @@ if (current_toolchain == default_toolchain) {
tool_versions = tool_versions =
exec_script("get_tool_mtime.py", exec_script("get_tool_mtime.py",
rebase_path([ rebase_path([
"//build/apple/swiftc.py",
"//build/config/ios/compile_xcassets.py", "//build/config/ios/compile_xcassets.py",
"//build/toolchain/mac/filter_libtool.py", "//build/toolchain/mac/filter_libtool.py",
"//build/toolchain/mac/linker_driver.py", "//build/toolchain/mac/linker_driver.py",
...@@ -478,8 +479,13 @@ template("mac_toolchain") { ...@@ -478,8 +479,13 @@ template("mac_toolchain") {
partial_outputs = [ "$_objects_dir/{{source_name_part}}.o" ] partial_outputs = [ "$_objects_dir/{{source_name_part}}.o" ]
} }
_env_vars = "TOOL_VERSION=${tool_versions.swiftc}"
if (is_ios && ios_sdk_developer_dir != "") {
_env_vars += " DEVELOPER_DIR=$ios_sdk_developer_dir"
}
command = command =
"$_tool -module-name {{module_name}} " + "$_env_vars $_tool -module-name {{module_name}} " +
"-object-dir $_objects_dir " + "-object-dir $_objects_dir " +
"-module-path {{target_gen_dir}}/{{module_name}}.swiftmodule " + "-module-path {{target_gen_dir}}/{{module_name}}.swiftmodule " +
"-header-path {{target_gen_dir}}/{{module_name}}.h " + "-header-path {{target_gen_dir}}/{{module_name}}.h " +
...@@ -603,6 +609,21 @@ mac_toolchain("clang_x64_v8_mips64el") { ...@@ -603,6 +609,21 @@ mac_toolchain("clang_x64_v8_mips64el") {
} }
if (is_ios) { if (is_ios) {
mac_toolchain("ios_clang_arm64") {
toolchain_args = {
current_cpu = "arm64"
current_os = "ios"
}
}
mac_toolchain("ios_clang_arm64_14_0") {
toolchain_args = {
current_cpu = "arm64"
current_os = "ios"
ios_deployment_target = "14.0"
}
}
mac_toolchain("ios_clang_arm") { mac_toolchain("ios_clang_arm") {
toolchain_args = { toolchain_args = {
current_cpu = "arm" current_cpu = "arm"
...@@ -610,10 +631,27 @@ if (is_ios) { ...@@ -610,10 +631,27 @@ if (is_ios) {
} }
} }
mac_toolchain("ios_clang_arm64") { mac_toolchain("ios_clang_arm_fat") {
toolchain_args = { toolchain_args = {
current_cpu = "arm64" current_cpu = "arm"
current_os = "ios" current_os = "ios"
is_fat_secondary_toolchain = true
primary_fat_toolchain_name = "//build/toolchain/mac:ios_clang_arm64"
}
}
mac_toolchain("ios_clang_x64") {
toolchain_args = {
current_cpu = "x64"
current_os = "ios"
}
}
mac_toolchain("ios_clang_x64_14_0") {
toolchain_args = {
current_cpu = "x64"
current_os = "ios"
ios_deployment_target = "14.0"
} }
} }
...@@ -624,10 +662,12 @@ if (is_ios) { ...@@ -624,10 +662,12 @@ if (is_ios) {
} }
} }
mac_toolchain("ios_clang_x64") { mac_toolchain("ios_clang_x86_fat") {
toolchain_args = { toolchain_args = {
current_cpu = "x64" current_cpu = "x86"
current_os = "ios" current_os = "ios"
is_fat_secondary_toolchain = true
primary_fat_toolchain_name = "//build/toolchain/mac:ios_clang_x64"
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment