Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: build/config/ios/rules.gni

Issue 2219323002: [iOS] Refactor build/config/ios/rules.gni. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@always-use-lipo
Patch Set: Workaround for crbug.com/637065. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/ios/rules.gni
diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni
index 5a9b20999961ed7d292bef6c81c09b03b28348cb..e21779fd43e9392e175a1324de811be6fb956d34 100644
--- a/build/config/ios/rules.gni
+++ b/build/config/ios/rules.gni
@@ -6,11 +6,253 @@ import("//build/config/ios/ios_sdk.gni")
import("//build/config/mac/base_rules.gni")
import("//build/config/mac/symbols.gni")
-_is_secondary_build =
- additional_toolchains != [] && current_toolchain != default_toolchain
+# Control whether an intermediate source_set is used when building executables
+# and shared_libraries for ios_app_bundle and ios_framework_bundle. This is a
+# temporary flag that will be removed once scoped_nsobject_unittest{_arc}.mm
+# tests are passing with this flag set to true (see crbug.com/637065)
+_use_intermediate_source_set = false
-_code_signing_script_path = "//build/config/ios/codesign.py"
-_default_entitlements_path = "//build/config/ios/entitlements.plist"
+# Invokes lipo on multiple arch-specific binaries to create a fat binary.
+#
+# Arguments
+#
+# arch_binary_target
+# name of the target generating the arch-specific binaries, they must
+# be named $target_out_dir/$toolchain_cpu/$arch_binary_output.
+#
+# arch_binary_output
+# (optional, defaults to the name of $arch_binary_target) base name of
+# the arch-specific binary generated by arch_binary_target.
+#
+# output_name
+# (optional, defaults to $target_name) base name of the target output,
+# the full path will be $target_out_dir/$output_name.
+#
+# configs
+# (optional) a list of configurations, this is used to check whether
+# the binary should be stripped, when "enable_stripping" is true.
+#
+template("lipo_binary") {
+ assert(defined(invoker.arch_binary_target),
+ "arch_binary_target must be defined for $target_name")
+
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _all_target_cpu = [ current_cpu ] + additional_target_cpus
+ _all_toolchains = [ current_toolchain ] + additional_toolchains
+
+ _arch_binary_target = invoker.arch_binary_target
+ _arch_binary_output = get_label_info(_arch_binary_target, "name")
+ if (defined(invoker.arch_binary_output)) {
+ _arch_binary_output = invoker.arch_binary_output
+ }
+
+ action(_target_name) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "arch_binary_output",
+ "arch_binary_target",
+ "configs",
+ "output_name",
+ ])
+
+ script = "//build/toolchain/mac/linker_driver.py"
+
+ outputs = [
+ "$target_out_dir/$_output_name",
+ ]
+
+ deps = []
+ _index = 0
+ inputs = []
+ foreach(_cpu, _all_target_cpu) {
+ _toolchain = _all_toolchains[_index]
+ _index = _index + 1
+
+ inputs +=
+ [ get_label_info("$_arch_binary_target($_toolchain)",
+ "target_out_dir") + "/$_cpu/$_arch_binary_output" ]
+
+ deps += [ "$_arch_binary_target($_toolchain)" ]
+ }
+
+ args = [
+ "xcrun",
+ "lipo",
+ "-create",
+ "-output",
+ rebase_path("$target_out_dir/$_output_name", root_build_dir),
+ ] + rebase_path(inputs, root_build_dir)
+
+ if (enable_dsyms) {
+ _dsyms_output_dir = "$root_out_dir/$_output_name.dSYM"
+ outputs += [
+ "$_dsyms_output_dir/",
+ "$_dsyms_output_dir/Contents/Info.plist",
+ "$_dsyms_output_dir/Contents/Resources/DWARF/$_output_name",
+ ]
+ args += [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ]
+ }
+
+ if (enable_stripping) {
+ # Check whether //build/config/mac:strip_all has been removed from the
+ # configs variables (as this is how stripping is disabled for a single
+ # target).
+ _strip_all_in_config = false
+ if (defined(invoker.configs)) {
+ foreach(_config, invoker.configs) {
+ if (_config == "//build/config/mac:strip_all") {
+ _strip_all_in_config = true
+ }
+ }
+ }
+
+ if (_strip_all_in_config) {
+ args += [ "-Wcrl,strip,-x,-S" ]
+ if (save_unstripped_output) {
+ outputs += [ "$root_out_dir/$_output_name.unstripped" ]
+ args += [ "-Wcrl,unstripped," +
+ rebase_path("$root_out_dir/.", root_build_dir) ]
+ }
+ }
+ }
+ }
+}
+
+# Wrapper around create_bundle taking care of code signature settings.
+#
+# Arguments
+#
+# product_type
+# string, product type for the generated Xcode project.
+#
+# bundle_extension
+# string, extension of the bundle, used to generate bundle name.
+#
+# bundle_binary_target
+# string, label of the target generating the bundle main binary.
+#
+# bundle_binary_output
+# (optional) string, base name of the binary generated by the
+# bundle_binary_target target, defaults to the target name.
+#
+# extra_system_frameworks
+# (optional) list of system framework to copy to the bundle.
+#
+# enable_code_signing
+# (optional) boolean, control whether code signing is enabled or not,
+# default to ios_enable_code_signing if not defined.
+#
+template("create_signed_bundle") {
+ assert(defined(invoker.product_type),
+ "product_type must be defined for $target_name")
+ assert(defined(invoker.bundle_extension),
+ "bundle_extension must be defined for $target_name")
+ assert(defined(invoker.bundle_binary_target),
+ "bundle_binary_target must be defined for $target_name")
+
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _bundle_binary_target = invoker.bundle_binary_target
+ _bundle_binary_output = get_label_info(_bundle_binary_target, "name")
+ if (defined(invoker.bundle_binary_output)) {
+ _bundle_binary_output = invoker.bundle_binary_output
+ }
+
+ _bundle_extension = invoker.bundle_extension
+ _bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension"
+
+ _entitlements_path = "//build/config/ios/entitlements.plist"
+ if (defined(invoker.entitlements_path)) {
+ _entitlements_path = invoker.entitlements_path
+ }
+
+ _enable_code_signing = ios_enable_code_signing
+ if (defined(invoker.enable_code_signing)) {
+ _enable_code_signing = invoker.enable_code_signing
+ }
+
+ create_bundle(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ "product_type",
+ "public_configs",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
+
+ bundle_root_dir = _bundle_root_dir
+ bundle_resources_dir = _bundle_root_dir
+ bundle_executable_dir = _bundle_root_dir
+ bundle_plugins_dir = "$_bundle_root_dir/PlugIns"
+
+ if (!defined(public_deps)) {
+ public_deps = []
+ }
+ public_deps += [ _bundle_binary_target ]
+
+ if (defined(invoker.bundle_deps)) {
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += invoker.bundle_deps
+ }
+
+ code_signing_script = "//build/config/ios/codesign.py"
+ code_signing_sources = [
+ _entitlements_path,
+ get_label_info(_bundle_binary_target, "target_out_dir") +
+ "/$_bundle_binary_output",
+ ]
+ code_signing_outputs = [ "$_bundle_root_dir/$_output_name" ]
+ if (_enable_code_signing) {
+ code_signing_outputs +=
+ [ "$_bundle_root_dir/_CodeSignature/CodeResources" ]
+ }
+ if (ios_code_signing_identity != "" && ios_sdk_name != "iphonesimulator") {
+ code_signing_outputs += [ "$_bundle_root_dir/embedded.mobileprovision" ]
+ }
+
+ if (defined(invoker.extra_system_frameworks)) {
+ foreach(_framework, invoker.extra_system_frameworks) {
+ code_signing_outputs += [ "$bundle_root_dir/Frameworks/" +
+ get_path_info(_framework, "file") ]
+ }
+ }
+
+ code_signing_args = [
+ "code-sign-bundle",
+ "-t=" + ios_sdk_name,
+ "-i=" + ios_code_signing_identity,
+ "-e=" + rebase_path(_entitlements_path, root_build_dir),
+ "-b=" + rebase_path("$target_out_dir/$_output_name", root_build_dir),
+ rebase_path(bundle_root_dir, root_build_dir),
+ ]
+ if (!_enable_code_signing) {
+ code_signing_args += [ "--disable-code-signature" ]
+ }
+ if (defined(invoker.extra_system_frameworks)) {
+ # All framework in extra_system_frameworks are expected to be
+ # system framework and the path to be already system absolute
+ # so do not use rebase_path here.
+ foreach(_framework, invoker.extra_system_frameworks) {
+ code_signing_args += [ "-F=" + _framework ]
+ }
+ }
+ }
+}
# Generates Info.plist files for Mac apps and frameworks.
#
@@ -117,6 +359,10 @@ template("ios_info_plist") {
# default to "com.apple.product-type.application". Should generally
# not be overridden.
#
+# enable_code_signing
+# (optional) boolean, control whether code signing is enabled or not,
+# default to ios_enable_code_signing if not defined.
+#
# For more information, see "gn help executable".
template("ios_app_bundle") {
_output_name = target_name
@@ -125,74 +371,19 @@ template("ios_app_bundle") {
_output_name = invoker.output_name
}
- # This template expands to multiple targets with some differences between
- # the the different build configuration.
- #
- # For a thin build (i.e. when additional_target_cpus is an empty list),
- # it compiles the final application binary with an "executable" target,
- # performs variable expansions on the Info.plist, defines some "bundle_data"
- # target to pack Info.plist and the executable into the .app bundle, and
- # finally a "create_bundle" target that packs everything the bundle. If the
- # bundle needs to be signed, then the binary is copied into the bundle by
- # the "create_bundle" target and the intermediate "bundle_data" target is
- # not generated.
- #
- # For a multi-architecture build (aka fat-build), the template expands to
- # a simple "executable" target for non-default toolchain. This is because
- # the real application bundle will contains a single binary that supports
- # all the architectures and creating a separate .app bundle for every
- # architecture would be a waste of time.
- #
- # The target for the default toolchain of a multi-architecture build will
- # build the executable for current_cpu in a temporary location. The real
- # fat binary will be created by "lipo" command from all those "executable"
- # target (including those of the non-default toolchains). This additional
- # target has the same role as the "executable" target of a thin build.
- #
- # The rest of the build, including the codesigning step, are the same for
- # thin and fat builds.
-
- _executable_extra_deps = []
- _executable_extra_inputs = []
- _executable_extra_ldflags = []
-
- # Embeds the entitlements file if building for simulator. This is optional
- # with Xcode 7 or older but required with Xcode 8. This is not necessary for
- # device build as the entitlement is embedded via the codesigning step.
- if (use_ios_simulator) {
- _generate_entitlements_target = _target_name + "_gen_entitlements"
- _generate_entitlements_target_with_toolchain_suffix =
- "$_generate_entitlements_target($default_toolchain)"
-
- _generate_entitlements_output =
- get_label_info(_generate_entitlements_target_with_toolchain_suffix,
- "target_gen_dir") + "/$_output_name.xcent"
-
- _executable_extra_inputs += [ _generate_entitlements_output ]
- _executable_extra_deps +=
- [ ":$_generate_entitlements_target_with_toolchain_suffix" ]
- _executable_extra_ldflags += [
- "-Xlinker",
- "-sectcreate",
- "-Xlinker",
- "__TEXT",
- "-Xlinker",
- "__entitlements",
- "-Xlinker",
- rebase_path(_generate_entitlements_output, root_build_dir),
- ]
- }
+ _arch_executable_source = _target_name + "_arch_executable_sources"
+ _arch_executable_target = _target_name + "_arch_executable"
+ _lipo_executable_target = _target_name + "_executable"
- if (_is_secondary_build) {
- # For the non-default toolchain of a fat-build, the template expands to a
- # single "executable" target that creates "$root_out_dir/$_output_name".
- executable(_target_name) {
+ if (_use_intermediate_source_set) {
+ source_set(_arch_executable_source) {
forward_variables_from(invoker,
"*",
[
"bundle_deps",
"bundle_deps_filter",
"bundle_extension",
+ "enable_code_signing",
"entitlements_path",
"extra_substitutions",
"extra_system_frameworks",
@@ -200,80 +391,144 @@ template("ios_app_bundle") {
"info_plist_target",
"output_name",
"product_type",
+ "visibility",
])
- if (defined(visibility)) {
- visibility += [ ":*($default_toolchain)" ]
- }
+ visibility = [ ":$_arch_executable_target" ]
+ }
+ } else {
+ assert(_arch_executable_source != "",
+ "mark _arch_executable_source as used")
+ }
- if (!defined(deps)) {
- deps = []
- }
- deps += _executable_extra_deps
+ if (use_ios_simulator) {
+ _generate_entitlements_target = _target_name + "_gen_entitlements"
+ _generate_entitlements_output =
+ get_label_info(":$_generate_entitlements_target($default_toolchain)",
+ "target_out_dir") + "/$_output_name.xcent"
+ }
- if (!defined(ldflags)) {
- ldflags = []
- }
- ldflags += _executable_extra_ldflags
+ executable(_arch_executable_target) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "bundle_extension",
+ "enable_code_signing",
+ "entitlements_path",
+ "extra_substitutions",
+ "extra_system_frameworks",
+ "info_plist",
+ "info_plist_target",
+ "output_name",
+ "product_type",
+ "sources",
+ "visibility",
+ ])
+ if (!_use_intermediate_source_set) {
+ forward_variables_from(invoker, [ "sources" ])
+ }
+
+ visibility = [ ":$_lipo_executable_target($default_toolchain)" ]
+ if (current_toolchain != default_toolchain) {
+ visibility += [ ":$_target_name" ]
+ }
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ if (_use_intermediate_source_set) {
+ deps += [ ":$_arch_executable_source" ]
+ }
+
+ if (!defined(libs)) {
+ libs = []
+ }
+ libs += [ "UIKit.framework" ]
+
+ if (use_ios_simulator) {
+ deps += [ ":$_generate_entitlements_target($default_toolchain)" ]
if (!defined(inputs)) {
inputs = []
}
- inputs += _executable_extra_inputs
+ inputs += [ _generate_entitlements_output ]
- output_name = _output_name
- if (!defined(libs)) {
- libs = []
+ if (!defined(ldflags)) {
+ ldflags = []
}
- libs += [ "UIKit.framework" ]
+ ldflags += [
+ "-Xlinker",
+ "-sectcreate",
+ "-Xlinker",
+ "__TEXT",
+ "-Xlinker",
+ "__entitlements",
+ "-Xlinker",
+ rebase_path(_generate_entitlements_output, root_build_dir),
+ ]
+ }
+
+ output_name = _output_name
+ output_prefix_override = true
+ output_dir = "$target_out_dir/$current_cpu"
+ }
+
+ if (current_toolchain != default_toolchain) {
+ # For fat builds, only the default toolchain will generate an application
+ # bundle. For the other toolchains, the template is only used for building
+ # the arch-specific binary, thus the default target is just a group().
+
+ group(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "testonly",
+ ])
+ public_deps = [
+ ":$_arch_executable_target",
+ ]
}
} else {
- # This is either a thin build or the default toolchain of a fat-build.
- # The template will expand in many different target ($target_name is the
- # create_bundle target) used as input to the create_bundle target.
- _generate_info_plist = target_name + "_generate_info_plist"
- _bundle_data_info_plist = target_name + "_bundle_data_info_plist"
+ lipo_binary(_lipo_executable_target) {
+ forward_variables_from(invoker,
+ [
+ "configs",
+ "testonly",
+ ])
- _entitlements_path = _default_entitlements_path
- if (defined(invoker.entitlements_path)) {
- _entitlements_path = invoker.entitlements_path
+ visibility = [ ":$_target_name" ]
+ output_name = _output_name
+ arch_binary_target = ":$_arch_executable_target"
+ arch_binary_output = _output_name
}
+ _generate_info_plist = target_name + "_generate_info_plist"
ios_info_plist(_generate_info_plist) {
- visibility = [ ":$_bundle_data_info_plist" ]
- if (use_ios_simulator) {
- visibility += [ ":$_generate_entitlements_target" ]
- }
- executable_name = _output_name
forward_variables_from(invoker,
[
"extra_substitutions",
"info_plist",
"info_plist_target",
])
- }
- bundle_data(_bundle_data_info_plist) {
- visibility = [ ":$_target_name" ]
- forward_variables_from(invoker, [ "testonly" ])
- sources = get_target_outputs(":$_generate_info_plist")
- outputs = [
- "{{bundle_root_dir}}/Info.plist",
- ]
- public_deps = [
- ":$_generate_info_plist",
- ]
+ executable_name = _output_name
}
if (use_ios_simulator) {
+ _entitlements_path = "//build/config/ios/entitlements.plist"
+ if (defined(invoker.entitlements_path)) {
+ _entitlements_path = invoker.entitlements_path
+ }
+
action(_generate_entitlements_target) {
- _gen_info_plist_target = ":$_generate_info_plist"
- _gen_info_plist_outputs = get_target_outputs(_gen_info_plist_target)
+ _gen_info_plist_outputs = get_target_outputs(":$_generate_info_plist")
_info_plist_path = _gen_info_plist_outputs[0]
- script = _code_signing_script_path
+ script = "//build/config/ios/codesign.py"
deps = [
- _gen_info_plist_target,
+ ":$_generate_info_plist",
]
sources = [
_entitlements_path,
@@ -290,150 +545,44 @@ template("ios_app_bundle") {
}
}
- _link_executable = _target_name + "_arch_executable"
- _lipo_executable = _target_name + "_executable"
-
- _link_executable_visibility = [ ":$_lipo_executable" ]
- _lipo_executable_visibility = [ ":$_target_name" ]
-
- executable(_link_executable) {
- forward_variables_from(invoker,
- "*",
- [
- "bundle_deps",
- "bundle_deps_filter",
- "bundle_extension",
- "data_deps",
- "entitlements_path",
- "extra_substitutions",
- "extra_system_frameworks",
- "info_plist",
- "info_plist_target",
- "output_name",
- "product_type",
- "visibility",
- ])
-
- visibility = _link_executable_visibility
-
- output_name = _output_name
- output_prefix_override = true
- output_dir = "$target_out_dir/$current_cpu"
-
- if (!defined(deps)) {
- deps = []
- }
- deps += _executable_extra_deps
-
- if (!defined(ldflags)) {
- ldflags = []
- }
- ldflags += _executable_extra_ldflags
-
- if (!defined(inputs)) {
- inputs = []
- }
- inputs += _executable_extra_inputs
-
- if (!defined(libs)) {
- libs = []
- }
- libs += [ "UIKit.framework" ]
- }
-
- # Create the multi-architecture binary from all the single architecture
- # binaries using "lipo". This target exists for the default toolchain
- # of a fat-build only and depends on the expansion of "ios_app_bundle"
- # for the other toolchains (i.e. a single "executable" target).
- #
- # This action only happens once per "ios_app_bundle" template (for the
- # main toolchain).
- action(_lipo_executable) {
+ _bundle_data_info_plist = target_name + "_bundle_data_info_plist"
+ bundle_data(_bundle_data_info_plist) {
forward_variables_from(invoker, [ "testonly" ])
- visibility = _lipo_executable_visibility
- script = "//build/toolchain/mac/linker_driver.py"
+
+ sources = get_target_outputs(":$_generate_info_plist")
outputs = [
- "$target_out_dir/$_output_name",
- ]
- inputs = [
- "$target_out_dir/$current_cpu/$_output_name",
+ "{{bundle_root_dir}}/Info.plist",
]
- deps = [
- ":$_link_executable",
+ public_deps = [
+ ":$_generate_info_plist",
]
- foreach(_additional_toolchain, additional_toolchains) {
- _additional_toolchain_target = "$_target_name($_additional_toolchain)"
- deps += [ ":$_additional_toolchain_target" ]
- inputs += [ get_label_info(_additional_toolchain_target,
- "root_out_dir") + "/$_output_name" ]
- }
- args = [
- "xcrun",
- "lipo",
- "-create",
- "-output",
- rebase_path(outputs[0], root_build_dir),
- ] + rebase_path(inputs, root_build_dir)
-
- if (enable_dsyms) {
- _dsyms_dir = "$root_out_dir/$_output_name.dSYM/"
- outputs += [
- "$_dsyms_dir/",
- "$_dsyms_dir/Contents/Info.plist",
- "$_dsyms_dir/Contents/Resources/DWARF/$_output_name",
- ]
- args +=
- [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ]
- }
-
- if (enable_stripping) {
- # Check whether //build/config/mac:strip_all has been removed from
- # the configs variable (as this is how stripping is disabled for a
- # single target).
- _strip_all_in_config = false
- if (defined(invoker.configs)) {
- foreach(_config, invoker.configs) {
- if (_config == "//build/config/mac:strip_all") {
- _strip_all_in_config = true
- }
- }
- }
-
- if (_strip_all_in_config) {
- args += [ "-Wcrl,strip,-x,-S" ]
-
- if (save_unstripped_output) {
- outputs += [ outputs[0] + ".unstripped" ]
- args += [ "-Wcrl,unstripped," +
- rebase_path(get_path_info(outputs[0], "dir"),
- root_build_dir) ]
- }
- }
- }
}
- create_bundle(target_name) {
+ create_signed_bundle(_target_name) {
forward_variables_from(invoker,
[
- "bundle_deps_filter",
+ "bundle_deps",
+ "bundle_extension",
"data_deps",
"deps",
+ "enable_code_signing",
+ "entitlements_path",
+ "extra_system_frameworks",
+ "product_type",
+ "public_configs",
"public_deps",
"testonly",
"visibility",
])
- if (!defined(deps)) {
- deps = []
- }
- deps += [ ":$_bundle_data_info_plist" ]
- if (!defined(public_deps)) {
- public_deps = []
- }
- public_deps += [ ":$_lipo_executable" ]
- if (defined(invoker.bundle_deps)) {
- deps += invoker.bundle_deps
+ output_name = _output_name
+ bundle_binary_target = ":$_lipo_executable_target"
+ bundle_binary_output = _output_name
+
+ if (!defined(bundle_deps)) {
+ bundle_deps = []
}
+ bundle_deps += [ ":$_bundle_data_info_plist" ]
if (use_ios_simulator) {
if (!defined(data_deps)) {
@@ -442,102 +591,15 @@ template("ios_app_bundle") {
data_deps += [ "//testing/iossim" ]
}
- if (defined(invoker.product_type)) {
- product_type = invoker.product_type
- } else {
+ if (!defined(product_type)) {
product_type = "com.apple.product-type.application"
}
- if (defined(invoker.bundle_extension)) {
- _bundle_extension = invoker.bundle_extension
- } else {
- _bundle_extension = ".app"
- }
-
- bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension"
- bundle_resources_dir = bundle_root_dir
- bundle_executable_dir = bundle_root_dir
- bundle_plugins_dir = "$bundle_root_dir/PlugIns"
-
- code_signing_script = _code_signing_script_path
- code_signing_sources = [
- _entitlements_path,
- "$target_out_dir/$_output_name",
- ]
- code_signing_outputs = [ "$bundle_root_dir/$_output_name" ]
- if (ios_enable_code_signing) {
- code_signing_outputs +=
- [ "$bundle_root_dir/_CodeSignature/CodeResources" ]
- }
- if (ios_code_signing_identity != "") {
- code_signing_outputs += [ "$bundle_root_dir/embedded.mobileprovision" ]
- }
- if (defined(invoker.extra_system_frameworks)) {
- foreach(_framework, invoker.extra_system_frameworks) {
- code_signing_outputs += [ "$bundle_root_dir/Frameworks/" +
- get_path_info(_framework, "file") ]
- }
- }
- code_signing_args = [
- "code-sign-bundle",
- "-t=" + ios_sdk_name,
- "-i=" + ios_code_signing_identity,
- "-e=" + rebase_path(_entitlements_path, root_build_dir),
- "-b=" + rebase_path("$target_out_dir/$_output_name", root_build_dir),
- rebase_path(bundle_root_dir, root_build_dir),
- ]
- if (defined(invoker.extra_system_frameworks)) {
- # All framework in extra_system_frameworks are expected to be
- # system framework and the path to be already system absolute
- # so do not use rebase_path here.
- foreach(_framework, invoker.extra_system_frameworks) {
- code_signing_args += [ "-F=" + _framework ]
- }
- }
- if (!ios_enable_code_signing) {
- code_signing_args += [ "--disable-code-signature" ]
+ if (!defined(bundle_extension)) {
+ bundle_extension = ".app"
}
}
}
-
- # TODO(crbug.com/395883): ensure those variables are marked as used to
- # avoid errors while running "gn gen".
- if (defined(invoker.entitlements_path)) {
- assert(invoker.entitlements_path != "",
- "mark invoker.entitlements_path as used")
- }
- if (defined(invoker.bundle_extension)) {
- assert(invoker.bundle_extension != "",
- "mark invoker.bundle_extension as used")
- }
- if (defined(invoker.bundle_extension)) {
- assert(invoker.bundle_extension != "",
- "mark invoker.bundle_extension as used")
- }
- if (defined(invoker.entitlements_path)) {
- assert(invoker.entitlements_path != "",
- "mark invoker.entitlements_path as used")
- }
- if (defined(invoker.extra_substitutions)) {
- assert(invoker.extra_substitutions != [],
- "mark invoker.extra_substitutions as used")
- }
- if (defined(invoker.info_plist)) {
- assert(invoker.info_plist != "", "mark invoker.info_plist as used")
- }
- if (defined(invoker.info_plist_target)) {
- assert(invoker.info_plist_target != "",
- "mark invoker.info_plist_target as used")
- }
- if (defined(invoker.product_type)) {
- assert(invoker.product_type != "", "mark product_type as used")
- }
- if (defined(invoker.bundle_deps)) {
- assert(invoker.bundle_deps != [], "mark bundle_deps as used")
- }
- if (defined(invoker.bundle_deps_filter)) {
- assert(invoker.bundle_deps_filter != [], "mark bundle_deps_filter as used")
- }
}
set_defaults("ios_app_bundle") {
@@ -717,12 +779,6 @@ template("bundle_data_strings") {
# (optional) string, name of the generated framework without the
# .framework suffix. If omitted, defaults to target_name.
#
-# framework_version:
-# (optional) string, version of the framework. Typically this is a
-# single letter, like "A". If omitted, the Versions/ subdirectory
-# structure will not be created, and build output will go directly
-# into the framework subdirectory.
-#
# public_headers:
# (optional) list of paths to header file that needs to be copied
# into the framework bundle Headers subdirectory. If omitted or
@@ -732,6 +788,10 @@ template("bundle_data_strings") {
# (optional) list of files. Needs to be defined and non-empty if
# public_headers is defined and non-empty.
#
+# enable_code_signing
+# (optional) boolean, control whether code signing is enabled or not,
+# default to ios_enable_code_signing if not defined.
+#
# This template provides two targets for the resulting framework bundle. The
# link-time behavior varies depending on which of the two targets below is
# added as a dependency:
@@ -814,41 +874,73 @@ template("ios_framework_bundle") {
_headers_map_config = _target_name + "_headers_map"
}
- # The expansion of the template is different for fat and thin builds. For
- # thin build (and default toolchain of a fat build), the template expands
- # to a "shared_library" target to create the bundle shared library and a
- # "create_bundle" target (the main target) to create the bundle structure.
- #
- # For a fat build, the template just expands to the "shared_library" target
- # for the non-default toolchain, while the final library is created using
- # "lipo" in the expansion of the template for the default toolchain.
- #
- # The "$target_name+link" group for the non-default toolchain depends on the
- # target of the same name from the default toolchain as this is the target
- # that defines the real framework bundle (it will support the current cpu
- # as it is a fat framework).
-
- if (_is_secondary_build) {
- shared_library(_target_name) {
+ _arch_shared_library_source = _target_name + "_arch_shared_library_sources"
+ _arch_shared_library_target = _target_name + "_arch_shared_library"
+ _lipo_shared_library_target = _target_name + "_shared_library"
+
+ if (_use_intermediate_source_set) {
+ source_set(_arch_shared_library_source) {
forward_variables_from(invoker,
"*",
[
- "assert_no_deps",
"bundle_deps",
+ "bundle_deps_filter",
"data_deps",
"enable_code_signing",
"info_plist",
"info_plist_target",
"output_name",
+ "visibility",
])
- if (defined(visibility)) {
- visibility += [ ":${_target_name}_shared_library($default_toolchain)" ]
+
+ visibility = [ ":$_arch_shared_library_target" ]
+
+ if (_has_public_headers) {
+ configs += [
+ ":$_framework_headers_config($default_toolchain)",
+ ":$_headers_map_config($default_toolchain)",
+ ]
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_framework_headers_target($default_toolchain)" ]
}
- output_name = _output_name
- output_prefix_override = true
- output_extension = ""
- output_dir = "$target_out_dir/$_target_name"
+ }
+ } else {
+ assert(_arch_shared_library_source != "",
+ "mark _arch_shared_library_source as used")
+ }
+
+ shared_library(_arch_shared_library_target) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "data_deps",
+ "enable_code_signing",
+ "info_plist",
+ "info_plist_target",
+ "output_name",
+ "sources",
+ "visibility",
+ ])
+ if (!_use_intermediate_source_set) {
+ forward_variables_from(invoker, [ "sources" ])
+ }
+ visibility = [ ":$_lipo_shared_library_target($default_toolchain)" ]
+ if (current_toolchain != default_toolchain) {
+ visibility += [ ":$_target_name" ]
+ }
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ if (_use_intermediate_source_set) {
+ deps += [ ":$_arch_shared_library_source" ]
+ } else {
if (_has_public_headers) {
configs += [
":$_framework_headers_config($default_toolchain)",
@@ -862,6 +954,28 @@ template("ios_framework_bundle") {
}
}
+ output_extension = ""
+ output_name = _output_name
+ output_prefix_override = true
+ output_dir = "$target_out_dir/$current_cpu"
+ }
+
+ if (current_toolchain != default_toolchain) {
+ # For fat builds, only the default toolchain will generate a framework
+ # bundle. For the other toolchains, the template is only used for building
+ # the arch-specific binary, thus the default target is just a group().
+
+ group(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "testonly",
+ ])
+ public_deps = [
+ ":$_arch_shared_library_target",
+ ]
+ }
+
group(_target_name + "+link") {
forward_variables_from(invoker,
[
@@ -879,8 +993,7 @@ template("ios_framework_bundle") {
} else {
if (_has_public_headers) {
_public_headers = invoker.public_headers
- _framework_name = _output_name + ".framework"
- _framework_root = "$root_out_dir/$_framework_name"
+ _framework_root = "$root_out_dir/$_output_name.framework"
_header_map_filename = "$target_gen_dir/$_output_name.headers.hmap"
@@ -936,7 +1049,7 @@ template("ios_framework_bundle") {
include_dirs = [ _header_map_filename ]
ldflags = [
"-install_name",
- "@rpath/$_framework_name/$_output_name",
+ "@rpath/$_output_name.framework/$_output_name",
]
}
@@ -957,132 +1070,30 @@ template("ios_framework_bundle") {
}
}
- # If the framework is unversioned, the final _target_name will be the
- # create_bundle(_framework_target), otherwise an action with the name
- # _target_name will depends on the the create_bundle() in order to prepare
- # the versioned directory structure.
- _framework_target = _target_name
- _framework_name = _output_name + ".framework"
- _framework_root_dir = "$root_out_dir/$_framework_name"
- if (defined(invoker.framework_version) && invoker.framework_version != "") {
- _framework_version = invoker.framework_version
- _framework_root_dir += "/Versions/$_framework_version"
- _framework_target = _target_name + "_create_bundle"
- }
-
- _link_shared_library_target = target_name + "_arch_shared_library"
- _lipo_shared_library_target = target_name + "_shared_library"
-
- _lipo_shared_library_visibility = [ ":$_framework_target" ]
- _link_shared_library_visibility = [ ":$_lipo_shared_library_target" ]
-
- _arch_shared_library_dir = "$target_out_dir/$_link_shared_library_target"
- _shared_library_dir = "$target_out_dir/$_lipo_shared_library_target"
-
- shared_library(_link_shared_library_target) {
+ lipo_binary(_lipo_shared_library_target) {
forward_variables_from(invoker,
- "*",
[
- "assert_no_deps",
- "bundle_deps",
- "data_deps",
- "enable_code_signing",
- "info_plist",
- "info_plist_target",
- "output_name",
- "visibility",
+ "configs",
+ "testonly",
])
- visibility = _link_shared_library_visibility
- output_name = _output_name
- output_prefix_override = true
- output_extension = ""
- output_dir = _arch_shared_library_dir
- if (_has_public_headers) {
- configs += [ ":$_headers_map_config($default_toolchain)" ]
-
- if (!defined(deps)) {
- deps = []
- }
- deps += [ ":$_framework_headers_target($default_toolchain)" ]
- }
- }
-
- action(_lipo_shared_library_target) {
- forward_variables_from(invoker, [ "testonly" ])
- visibility = _lipo_shared_library_visibility
- script = "//build/toolchain/mac/linker_driver.py"
- outputs = [
- "$_shared_library_dir/$_output_name",
- ]
- inputs = [
- "$_arch_shared_library_dir/$_output_name",
- ]
- deps = [
- ":$_link_shared_library_target",
- ]
- foreach(_additional_toolchain, additional_toolchains) {
- _additional_toolchain_target = "$_target_name($_additional_toolchain)"
- deps += [ ":$_additional_toolchain_target" ]
- inputs += [ get_label_info(_additional_toolchain_target,
- "target_out_dir") + "/$_output_name" ]
- }
- args = [
- "xcrun",
- "lipo",
- "-create",
- "-output",
- rebase_path(outputs[0], root_build_dir),
- ] + rebase_path(inputs, root_build_dir)
-
- if (enable_dsyms) {
- _dsyms_dir = "$root_out_dir/$_output_name.dSYM/"
- outputs += [
- "$_dsyms_dir/",
- "$_dsyms_dir/Contents/Info.plist",
- "$_dsyms_dir/Contents/Resources/DWARF/$_output_name",
- ]
- args +=
- [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ]
- }
-
- if (enable_stripping) {
- # Check whether //build/config/mac:strip_all has been removed from
- # the configs variable (as this is how stripping is disabled for a
- # single target).
- _strip_all_in_config = false
- if (defined(invoker.configs)) {
- foreach(_config, invoker.configs) {
- if (_config == "//build/config/mac:strip_all") {
- _strip_all_in_config = true
- }
- }
- }
-
- if (_strip_all_in_config) {
- args += [ "-Wcrl,strip,-x,-S" ]
-
- if (save_unstripped_output) {
- outputs += [ outputs[0] + ".unstripped" ]
- args += [ "-Wcrl,unstripped," +
- rebase_path(get_path_info(outputs[0], "dir"),
- root_build_dir) ]
- }
- }
- }
+ visibility = [ ":$_target_name" ]
+ output_name = _output_name
+ arch_binary_target = ":$_arch_shared_library_target"
+ arch_binary_output = _output_name
}
_framework_public_config = _target_name + "_public_config"
config(_framework_public_config) {
# TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
# and include_dirs to avoid duplicate values on the command-line.
- visibility = [ ":$_framework_target" ]
+ visibility = [ ":$_target_name" ]
ldflags = [
"-F",
rebase_path("$root_out_dir/.", root_build_dir),
]
lib_dirs = [ root_out_dir ]
- libs = [ _framework_name ]
+ libs = [ "$_output_name.framework" ]
}
_info_plist_target = _target_name + "_info_plist"
@@ -1110,104 +1121,30 @@ template("ios_framework_bundle") {
]
}
- create_bundle(_framework_target) {
+ create_signed_bundle(_target_name) {
forward_variables_from(invoker,
[
+ "bundle_deps",
"data_deps",
"deps",
+ "enable_code_signing",
"public_configs",
"public_deps",
"testonly",
+ "visibility",
])
- if (defined(_framework_version)) {
- visibility = [ ":$_target_name" ]
- } else {
- if (defined(invoker.visibility)) {
- visibility = invoker.visibility
- visibility += [ ":$_target_name+link" ]
- }
- }
-
- if (!defined(deps)) {
- deps = []
- }
- deps += [ ":$_info_plist_bundle" ]
-
- if (defined(invoker.bundle_deps)) {
- if (!defined(deps)) {
- deps = []
- }
- deps += invoker.bundle_deps
- }
+ product_type = "com.apple.product-type.framework"
+ bundle_extension = ".framework"
- bundle_root_dir = _framework_root_dir
- bundle_resources_dir = _framework_root_dir
- bundle_executable_dir = _framework_root_dir
+ output_name = _output_name
+ bundle_binary_target = ":$_lipo_shared_library_target"
+ bundle_binary_output = _output_name
if (!defined(deps)) {
deps = []
}
- deps += [ ":$_lipo_shared_library_target" ]
-
- _entitlements_path = _default_entitlements_path
- if (defined(invoker.entitlements_path)) {
- _entitlements_path = invoker.entitlements_path
- }
-
- _ios_enable_code_signing = ios_enable_code_signing
- if (defined(invoker.enable_code_signing)) {
- _ios_enable_code_signing = invoker.enable_code_signing
- }
-
- code_signing_script = _code_signing_script_path
- code_signing_sources = [
- _entitlements_path,
- "$_shared_library_dir/$_output_name",
- ]
- code_signing_outputs = [ "$bundle_root_dir/$_output_name" ]
- if (_ios_enable_code_signing) {
- code_signing_outputs +=
- [ "$bundle_root_dir/_CodeSignature/CodeResources" ]
- }
- if (ios_code_signing_identity != "") {
- code_signing_outputs += [ "$bundle_root_dir/embedded.mobileprovision" ]
- }
- code_signing_args = [
- "code-sign-bundle",
- "-t=" + ios_sdk_name,
- "-i=" + ios_code_signing_identity,
- "-e=" + rebase_path(_entitlements_path, root_build_dir),
- "-b=" +
- rebase_path("$_shared_library_dir/$_output_name", root_build_dir),
- rebase_path(bundle_root_dir, root_build_dir),
- ]
- if (!_ios_enable_code_signing) {
- code_signing_args += [ "--disable-code-signature" ]
- }
- }
-
- if (defined(_framework_version)) {
- action(_target_name) {
- forward_variables_from(invoker, [ "testonly" ])
-
- if (defined(invoker.visibility)) {
- visibility = invoker.visibility
- visibility += [ ":$_target_name+link" ]
- }
-
- script = "//build/config/mac/package_framework.py"
- outputs = [
- "$root_out_dir/$_framework_name/Versions/Current",
- ]
- args = [
- "$_framework_name",
- "$_framework_version",
- ]
- public_deps = [
- ":$_framework_target",
- ]
- }
+ deps += [ ":$_info_plist_bundle" ]
}
group(_target_name + "+link") {
@@ -1272,16 +1209,39 @@ template("ios_xctest_test") {
_host_target = _target_name + "_host"
_host_output = _output_name + "_host"
- if (_is_secondary_build) {
- loadable_module(_xctest_target) {
- visibility = [ ":${_xctest_target}_loadable_module($default_toolchain)" ]
- sources = [
- "//build/config/ios/xctest_shell.mm",
- ]
- configs += [ "//build/config/ios:xctest_config" ]
+ _xctest_arch_loadable_module_target = _xctest_target + "_arch_loadable_module"
+ _xctest_lipo_loadable_module_target = _xctest_target + "_loadable_module"
- output_name = _xctest_output
- output_extension = ""
+ loadable_module(_xctest_arch_loadable_module_target) {
+ visibility = [ ":$_xctest_lipo_loadable_module_target($default_toolchain)" ]
+ if (current_toolchain != default_toolchain) {
+ visibility += [ ":$_target_name" ]
+ }
+
+ sources = [
+ "//build/config/ios/xctest_shell.mm",
+ ]
+ configs += [ "//build/config/ios:xctest_config" ]
+
+ output_dir = "$target_out_dir/$current_cpu"
+ output_name = _xctest_output
+ output_prefix_override = true
+ output_extension = ""
+ }
+
+ if (current_toolchain != default_toolchain) {
+ # For fat builds, only the default toolchain will generate a test bundle.
+ # For the other toolchains, the template is only used for building the
+ # arch-specific binary, thus the default target is just a group().
+ group(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "testonly",
+ ])
+ public_deps = [
+ ":$_xctest_arch_loadable_module_target",
+ ]
}
} else {
_xctest_info_plist_target = _xctest_target + "_info_plist"
@@ -1303,129 +1263,34 @@ template("ios_xctest_test") {
]
}
- _xctest_loadable_module_target = _xctest_target + "_arch_loadable_module"
- _xctest_lipo_loadable_module_target = _xctest_target + "_loadable_module"
-
- _xctest_loadable_module_visibility =
- [ ":$_xctest_lipo_loadable_module_target" ]
- _xctest_lipo_loadable_module_visibility = [ ":$_xctest_target" ]
-
- loadable_module(_xctest_loadable_module_target) {
- visibility = _xctest_loadable_module_visibility
- sources = [
- "//build/config/ios/xctest_shell.mm",
- ]
- configs += [ "//build/config/ios:xctest_config" ]
+ lipo_binary(_xctest_lipo_loadable_module_target) {
+ forward_variables_from(invoker,
+ [
+ "configs",
+ "testonly",
+ ])
- output_dir = "$target_out_dir/$current_cpu"
+ visibility = [ ":$_xctest_target" ]
output_name = _xctest_output
- output_prefix_override = true
- output_extension = ""
- }
-
- action(_xctest_lipo_loadable_module_target) {
- visibility = _xctest_lipo_loadable_module_visibility
- script = "//build/toolchain/mac/linker_driver.py"
- outputs = [
- "$target_out_dir/$_xctest_output",
- ]
- inputs = [
- "$target_out_dir/$current_cpu/$_xctest_output",
- ]
- deps = [
- ":$_xctest_loadable_module_target",
- ]
- foreach(_additional_toolchain, additional_toolchains) {
- _additional_toolchain_target = "$_target_name($_additional_toolchain)"
- deps += [ ":$_additional_toolchain_target" ]
- inputs += [ get_label_info(_additional_toolchain_target,
- "root_out_dir") + "/$_xctest_output" ]
- }
- args = [
- "xcrun",
- "lipo",
- "-create",
- "-output",
- rebase_path(outputs[0], root_build_dir),
- ] + rebase_path(inputs, root_build_dir)
-
- if (enable_dsyms) {
- _dsyms_dir = "$root_out_dir/$_output_name.dSYM/"
- outputs += [
- "$_dsyms_dir/",
- "$_dsyms_dir/Contents/Info.plist",
- "$_dsyms_dir/Contents/Resources/DWARF/$_output_name",
- ]
- args +=
- [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ]
- }
-
- if (enable_stripping) {
- # Check whether //build/config/mac:strip_all has been removed from
- # the configs variable (as this is how stripping is disabled for a
- # single target).
- _strip_all_in_config = false
- if (defined(invoker.configs)) {
- foreach(_config, invoker.configs) {
- if (_config == "//build/config/mac:strip_all") {
- _strip_all_in_config = true
- }
- }
- }
-
- if (_strip_all_in_config) {
- args += [ "-Wcrl,strip,-x,-S" ]
-
- if (save_unstripped_output) {
- outputs += [ outputs[0] + ".unstripped" ]
- args += [ "-Wcrl,unstripped," +
- rebase_path(get_path_info(outputs[0], "dir"),
- root_build_dir) ]
- }
- }
- }
+ arch_binary_target = ":$_xctest_arch_loadable_module_target"
+ arch_binary_output = _xctest_output
}
_xctest_bundle = _xctest_target + "_bundle"
-
- create_bundle(_xctest_target) {
+ create_signed_bundle(_xctest_target) {
+ forward_variables_from(invoker, [ "enable_code_signing" ])
visibility = [ ":$_xctest_bundle" ]
+
product_type = "com.apple.product-type.bundle.unit-test"
- deps = [
- ":$_xctest_info_plist_bundle",
- ":$_xctest_lipo_loadable_module_target",
- ]
- bundle_root_dir = "$root_out_dir/$_xctest_output.xctest"
+ bundle_extension = ".xctest"
- _entitlements_path = _default_entitlements_path
- if (defined(invoker.entitlements_path)) {
- _entitlements_path = invoker.entitlements_path
- }
+ output_name = _xctest_output
+ bundle_binary_target = ":$_xctest_lipo_loadable_module_target"
+ bundle_binary_output = _xctest_output
- code_signing_script = _code_signing_script_path
- code_signing_sources = [
- _entitlements_path,
- "$target_out_dir/$_xctest_output",
- ]
- code_signing_outputs = [ "$bundle_root_dir/$_xctest_output" ]
- if (ios_enable_code_signing) {
- code_signing_outputs +=
- [ "$bundle_root_dir/_CodeSignature/CodeResources" ]
- }
- if (ios_code_signing_identity != "") {
- code_signing_outputs += [ "$bundle_root_dir/embedded.mobileprovision" ]
- }
- code_signing_args = [
- "code-sign-bundle",
- "-t=" + ios_sdk_name,
- "-i=" + ios_code_signing_identity,
- "-e=" + rebase_path(_entitlements_path, root_build_dir),
- "-b=" + rebase_path("$target_out_dir/$_xctest_output", root_build_dir),
- rebase_path(bundle_root_dir, root_build_dir),
+ deps = [
+ ":$_xctest_info_plist_bundle",
]
- if (!ios_enable_code_signing) {
- code_signing_args += [ "--disable-code-signature" ]
- }
}
bundle_data(_xctest_bundle) {
@@ -1461,7 +1326,7 @@ template("ios_xctest_test") {
"$_ios_platform_library/PrivateFrameworks/IDEBundleInjection.framework",
]
- if (!_is_secondary_build) {
+ if (current_toolchain == default_toolchain) {
if (!defined(bundle_deps)) {
bundle_deps = []
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698