Index: build/config/ios/rules.gni |
diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni |
index ac2c61ac1c9d98487141d5df7f50bb4d02523114..741776cea7d284896770efe99ea2b8e24976819f 100644 |
--- a/build/config/ios/rules.gni |
+++ b/build/config/ios/rules.gni |
@@ -122,154 +122,267 @@ template("ios_app_bundle") { |
_output_name = invoker.output_name |
} |
- _generate_info_plist = target_name + "_generate_info_plist" |
- _bundle_data_info_plist = target_name + "_bundle_data_info_plist" |
- |
- ios_info_plist(_generate_info_plist) { |
- executable_name = _output_name |
- forward_variables_from(invoker, |
- [ |
- "extra_substitutions", |
- "info_plist", |
- "info_plist_target", |
- ]) |
+ _is_fat_build = multi_arch_toolchains != [] |
+ if (_is_fat_build) { |
+ _is_fat_build_main_target = current_toolchain == multi_arch_toolchains[0] |
} |
- bundle_data(_bundle_data_info_plist) { |
- forward_variables_from(invoker, [ "testonly" ]) |
- visibility = [ ":$_target_name" ] |
- sources = get_target_outputs(":$_generate_info_plist") |
- outputs = [ |
- "{{bundle_root_dir}}/Info.plist", |
- ] |
- public_deps = [ |
- ":$_generate_info_plist", |
- ] |
- } |
+ if (_is_fat_build && !_is_fat_build_main_target) { |
+ executable(_target_name) { |
+ forward_variables_from(invoker, |
+ "*", |
+ [ |
+ "bundle_extension", |
+ "entitlements_path", |
+ "extra_substitutions", |
+ "info_plist", |
+ "info_plist_target", |
+ "output_name", |
+ "product_type", |
+ ]) |
- _generate_executable = target_name + "_generate_executable" |
- if (!ios_enable_code_signing) { |
- _bundle_data_executable = target_name + "_bundle_data_executable" |
- } |
+ if (defined(visibility)) { |
+ visibility += [ ":*($default_toolchain)" ] |
+ } |
- executable(_generate_executable) { |
- if (ios_enable_code_signing) { |
- visibility = [ ":$_target_name" ] |
- } else { |
- visibility = [ ":$_bundle_data_executable" ] |
+ output_name = _output_name |
+ if (!defined(libs)) { |
+ libs = [] |
+ } |
+ libs += [ "UIKit.framework" ] |
+ if (!defined(ldflags)) { |
+ ldflags = [] |
+ } |
+ ldflags += [ "-ObjC" ] |
} |
- forward_variables_from(invoker, |
- "*", |
- [ |
- "bundle_extension", |
- "data_deps", |
- "entitlements_path", |
- "info_plist", |
- "info_plist_target", |
- "output_name", |
- "product_type", |
- "visibility", |
- ]) |
- output_name = rebase_path("$target_gen_dir/$_output_name", root_out_dir) |
- output_prefix_override = true |
+ # TODO(crbug.com/395883): ensure those variables are marked as used to |
+ # avoid errors while running "gn gen". |
+ assert(!defined(invoker.bundle_extension) || invoker.bundle_extension != "", |
+ "mark bundle_extension as used") |
+ assert( |
+ !defined(invoker.entitlements_path) || invoker.entitlements_path != "", |
+ "mark entitlements_path as used") |
+ assert(!defined(invoker.extra_substitutions) || |
+ invoker.extra_substitutions != [], |
+ "mark extra_substitutions as used") |
+ assert(!defined(invoker.info_plist) || invoker.info_plist != "", |
+ "mark info_plist as used") |
+ assert( |
+ !defined(invoker.info_plist_target) || invoker.info_plist_target != "", |
+ "mark info_plist_target as used") |
+ assert(!defined(invoker.product_type) || invoker.product_type != "", |
+ "mark product_type as used") |
+ } else { |
+ _generate_info_plist = target_name + "_generate_info_plist" |
+ _bundle_data_info_plist = target_name + "_bundle_data_info_plist" |
- if (!defined(libs)) { |
- libs = [] |
- } |
- libs += [ "UIKit.framework" ] |
- if (!defined(ldflags)) { |
- ldflags = [] |
+ ios_info_plist(_generate_info_plist) { |
+ visibility = [ ":$_bundle_data_info_plist" ] |
+ executable_name = _output_name |
+ forward_variables_from(invoker, |
+ [ |
+ "extra_substitutions", |
+ "info_plist", |
+ "info_plist_target", |
+ ]) |
} |
- ldflags += [ "-ObjC" ] |
- } |
- if (!ios_enable_code_signing) { |
- bundle_data(_bundle_data_executable) { |
- forward_variables_from(invoker, [ "testonly" ]) |
+ bundle_data(_bundle_data_info_plist) { |
visibility = [ ":$_target_name" ] |
- sources = [ |
- "$target_gen_dir/$_output_name", |
- ] |
+ forward_variables_from(invoker, [ "testonly" ]) |
+ sources = get_target_outputs(":$_generate_info_plist") |
outputs = [ |
- "{{bundle_executable_dir}}/$_output_name", |
+ "{{bundle_root_dir}}/Info.plist", |
] |
public_deps = [ |
- ":$_generate_executable", |
+ ":$_generate_info_plist", |
] |
} |
- } |
- create_bundle(target_name) { |
- forward_variables_from(invoker, |
- [ |
- "data_deps", |
- "deps", |
- "public_deps", |
- "testonly", |
- "visibility", |
- ]) |
+ _link_executable = _target_name + "_link_executable" |
+ _executable_path = "$target_gen_dir/$_output_name" |
- if (!defined(deps)) { |
- deps = [] |
- } |
- deps += [ ":$_bundle_data_info_plist" ] |
if (ios_enable_code_signing) { |
- deps += [ ":$_generate_executable" ] |
+ _link_executable_visibility = [ ":$_target_name" ] |
} else { |
- deps += [ ":$_bundle_data_executable" ] |
+ _bundle_data_executable = target_name + "_bundle_data_executable" |
+ _link_executable_visibility = [ ":$_bundle_data_executable" ] |
} |
- if (use_ios_simulator) { |
- if (!defined(data_deps)) { |
- data_deps = [] |
+ if (_is_fat_build) { |
+ _lipo_executable = _target_name + "_lipo_executable" |
+ _lipo_executable_visibility = _link_executable_visibility |
+ |
+ _link_executable_visibility = [] |
+ _link_executable_visibility = [ ":$_lipo_executable" ] |
+ |
+ _arch_executable_path = "$target_gen_dir/$current_cpu/$_output_name" |
+ } |
+ |
+ executable(_link_executable) { |
+ forward_variables_from(invoker, |
+ "*", |
+ [ |
+ "bundle_extension", |
+ "data_deps", |
+ "entitlements_path", |
+ "extra_substitutions", |
+ "info_plist", |
+ "info_plist_target", |
+ "output_name", |
+ "product_type", |
+ "visibility", |
+ ]) |
+ |
+ visibility = _link_executable_visibility |
+ |
+ output_prefix_override = true |
+ if (_is_fat_build) { |
+ output_name = rebase_path(_arch_executable_path, root_build_dir) |
+ } else { |
+ output_name = rebase_path(_executable_path, root_build_dir) |
+ } |
+ |
+ if (!defined(libs)) { |
+ libs = [] |
+ } |
+ libs += [ "UIKit.framework" ] |
+ if (!defined(ldflags)) { |
+ ldflags = [] |
} |
- data_deps += [ "//testing/iossim" ] |
+ ldflags += [ "-ObjC" ] |
} |
- if (defined(invoker.product_type)) { |
- product_type = invoker.product_type |
- } else { |
- product_type = "com.apple.product-type.application" |
+ if (_is_fat_build) { |
Robert Sesek
2016/07/07 17:27:09
How many times is lipo going to get run? I'd think
|
+ action(_lipo_executable) { |
+ forward_variables_from(invoker, [ "testonly" ]) |
+ visibility = _lipo_executable_visibility |
+ script = "//build/config/mac/xcrun.py" |
+ outputs = [ |
+ _executable_path, |
+ ] |
+ inputs = [ |
+ _arch_executable_path, |
+ ] |
+ deps = [ |
+ ":$_link_executable", |
+ ] |
+ foreach(_toolchain, multi_arch_toolchains) { |
+ if (_toolchain != current_toolchain) { |
+ _toolchain_target = "$_target_name($_toolchain)" |
+ deps += [ ":$_toolchain_target" ] |
+ inputs += [ get_label_info(_toolchain_target, "root_out_dir") + |
+ "/$_output_name" ] |
+ } |
+ } |
+ args = [ |
+ "lipo", |
+ "-create", |
+ "-output", |
+ rebase_path(outputs[0], root_build_dir), |
+ ] + rebase_path(inputs, root_build_dir) |
+ } |
} |
- if (defined(invoker.bundle_extension)) { |
- _bundle_extension = invoker.bundle_extension |
- } else { |
- _bundle_extension = ".app" |
+ if (!ios_enable_code_signing) { |
+ bundle_data(_bundle_data_executable) { |
+ forward_variables_from(invoker, [ "testonly" ]) |
+ visibility = [ ":$_target_name" ] |
+ outputs = [ |
+ "{{bundle_executable_dir}}/$_output_name", |
+ ] |
+ if (_is_fat_build) { |
+ public_deps = [ |
+ ":$_lipo_executable", |
+ ] |
+ } else { |
+ public_deps = [ |
+ ":$_link_executable", |
+ ] |
+ } |
+ sources = [ |
+ "$target_gen_dir/$_output_name", |
+ ] |
+ } |
} |
- 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" |
+ create_bundle(target_name) { |
+ forward_variables_from(invoker, |
+ [ |
+ "data_deps", |
+ "deps", |
+ "public_deps", |
+ "testonly", |
+ "visibility", |
+ ]) |
- if (defined(invoker.entitlements_path)) { |
- _entitlements_path = invoker.entitlements_path |
- } else { |
- _entitlements_path = "$ios_sdk_path/Entitlements.plist" |
- } |
+ if (!defined(deps)) { |
+ deps = [] |
+ } |
+ deps += [ ":$_bundle_data_info_plist" ] |
+ if (ios_enable_code_signing) { |
+ if (_is_fat_build) { |
+ deps += [ ":$_lipo_executable" ] |
+ } else { |
+ deps += [ ":$_link_executable" ] |
+ } |
+ } else { |
+ deps += [ ":$_bundle_data_executable" ] |
+ } |
- if (ios_enable_code_signing) { |
- code_signing_script = "//build/config/ios/codesign.py" |
- code_signing_sources = [ |
- _entitlements_path, |
- "$target_gen_dir/$_output_name", |
- ] |
- code_signing_outputs = [ |
- "$bundle_root_dir/$_output_name", |
- "$bundle_root_dir/_CodeSignature/CodeResources", |
- "$bundle_root_dir/embedded.mobileprovision", |
- ] |
- code_signing_args = [ |
- "-i=" + ios_code_signing_identity, |
- "-b=" + rebase_path("$target_gen_dir/$_output_name", root_build_dir), |
- "-e=" + rebase_path(_entitlements_path, root_build_dir), |
- rebase_path(bundle_root_dir, root_build_dir), |
- ] |
- } else { |
- assert(_entitlements_path != "", |
- "force usage of _entitlements_path to avoid unused variable error") |
+ if (use_ios_simulator) { |
+ if (!defined(data_deps)) { |
+ data_deps = [] |
+ } |
+ data_deps += [ "//testing/iossim" ] |
+ } |
+ |
+ if (defined(invoker.product_type)) { |
+ product_type = invoker.product_type |
+ } else { |
+ 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" |
+ |
+ if (defined(invoker.entitlements_path)) { |
+ _entitlements_path = invoker.entitlements_path |
+ } else { |
+ _entitlements_path = "$ios_sdk_path/Entitlements.plist" |
+ } |
+ |
+ if (ios_enable_code_signing) { |
+ code_signing_script = "//build/config/ios/codesign.py" |
+ code_signing_sources = [ |
+ _entitlements_path, |
+ "$target_gen_dir/$_output_name", |
+ ] |
+ code_signing_outputs = [ |
+ "$bundle_root_dir/$_output_name", |
+ "$bundle_root_dir/_CodeSignature/CodeResources", |
+ "$bundle_root_dir/embedded.mobileprovision", |
+ ] |
+ code_signing_args = [ |
+ "-i=" + ios_code_signing_identity, |
+ "-b=" + rebase_path("$target_gen_dir/$_output_name", root_build_dir), |
+ "-e=" + rebase_path(_entitlements_path, root_build_dir), |
+ rebase_path(bundle_root_dir, root_build_dir), |
+ ] |
+ } else { |
+ assert( |
+ _entitlements_path != "", |
+ "force usage of _entitlements_path to avoid unused variable error") |
+ } |
} |
} |
} |