From 39fe426a5bec5352ddacab96ac10c6c33f9d5ac1 Mon Sep 17 00:00:00 2001 From: lpromero Date: Sat, 10 Dec 2016 15:48:09 -0800 Subject: [PATCH] Handle storyboards in GN. BUG=none R=sdefresne@chromium.org,rohitrao@chromium.org Review-Url: https://codereview.chromium.org/2564023002 Cr-Commit-Position: refs/heads/master@{#437779} --- build/config/ios/rules.gni | 17 ++++++++++++----- build/config/mac/base_rules.gni | 17 +++++++++++------ .../mac/{compile_xib.py => compile_ib_files.py} | 0 build/config/mac/rules.gni | 3 ++- ios/chrome/app/resources/BUILD.gn | 2 +- ios/chrome/browser/ui/BUILD.gn | 2 +- ios/chrome/browser/ui/downloads/BUILD.gn | 2 +- 7 files changed, 28 insertions(+), 15 deletions(-) rename build/config/mac/{compile_xib.py => compile_ib_files.py} (100%) diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni index 778a56b178186a..d6170c491876f3 100644 --- a/build/config/ios/rules.gni +++ b/build/config/ios/rules.gni @@ -795,7 +795,7 @@ set_defaults("ios_appex_bundle") { # string, path of the xib or storyboard to compile. # # Forwards all variables to the bundle_data target. -template("bundle_data_xib") { +template("bundle_data_ib_file") { assert(defined(invoker.source), "source needs to be defined for $target_name") _source_extension = get_path_info(invoker.source, "extension") @@ -803,12 +803,19 @@ template("bundle_data_xib") { "source must be a .xib or .storyboard for $target_name") _target_name = target_name - _compile_xib = target_name + "_compile_xib" + if (_source_extension == "xib") { + _compile_ib_file = target_name + "_compile_xib" + _output_extension = "nib" + } else { + _compile_ib_file = target_name + "_compile_storyboard" + _output_extension = "storyboardc" + } - compile_xibs(_compile_xib) { + compile_ib_files(_compile_ib_file) { sources = [ invoker.source, ] + output_extension = _output_extension visibility = [ ":$_target_name" ] ibtool_flags = [ "--minimum-deployment-target", @@ -827,9 +834,9 @@ template("bundle_data_xib") { if (!defined(public_deps)) { public_deps = [] } - public_deps += [ ":$_compile_xib" ] + public_deps += [ ":$_compile_ib_file" ] - sources = get_target_outputs(":$_compile_xib") + sources = get_target_outputs(":$_compile_ib_file") outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}", diff --git a/build/config/mac/base_rules.gni b/build/config/mac/base_rules.gni index 92e73a862f66a6..341c7508a46682 100644 --- a/build/config/mac/base_rules.gni +++ b/build/config/mac/base_rules.gni @@ -202,7 +202,7 @@ template("info_plist") { } } -# Template to combile .xib or .storyboard files. +# Template to compile .xib and .storyboard files. # # Arguments # @@ -211,7 +211,7 @@ template("info_plist") { # # ibtool_flags: # (optional) list of string, additional flags to pass to the ibtool -template("compile_xibs") { +template("compile_ib_files") { action_foreach(target_name) { forward_variables_from(invoker, [ @@ -219,23 +219,28 @@ template("compile_xibs") { "visibility", ]) assert(defined(invoker.sources), - "Sources must be specified for $target_name") + "sources must be specified for $target_name") + assert(defined(invoker.output_extension), + "output_extension must be specified for $target_name") ibtool_flags = [] if (defined(invoker.ibtool_flags)) { ibtool_flags = invoker.ibtool_flags } - script = "//build/config/mac/compile_xib.py" + _output_extension = invoker.output_extension + + script = "//build/config/mac/compile_ib_files.py" sources = invoker.sources outputs = [ - "$target_gen_dir/$target_name/{{source_name_part}}.nib", + "$target_gen_dir/$target_name/{{source_name_part}}.$_output_extension", ] args = [ "--input", "{{source}}", "--output", - rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"), + rebase_path( + "$target_gen_dir/$target_name/{{source_name_part}}.$_output_extension"), ] if (!use_system_xcode) { args += [ diff --git a/build/config/mac/compile_xib.py b/build/config/mac/compile_ib_files.py similarity index 100% rename from build/config/mac/compile_xib.py rename to build/config/mac/compile_ib_files.py diff --git a/build/config/mac/rules.gni b/build/config/mac/rules.gni index f59503481f8fdc..dd7b4a55508c08 100644 --- a/build/config/mac/rules.gni +++ b/build/config/mac/rules.gni @@ -77,10 +77,11 @@ template("mac_xib_bundle_data") { _target_name = target_name _compile_target_name = _target_name + "_compile_ibtool" - compile_xibs(_compile_target_name) { + compile_ib_files(_compile_target_name) { forward_variables_from(invoker, [ "testonly" ]) visibility = [ ":$_target_name" ] sources = invoker.sources + output_extension = "nib" ibtool_flags = [ "--minimum-deployment-target", mac_deployment_target, diff --git a/ios/chrome/app/resources/BUILD.gn b/ios/chrome/app/resources/BUILD.gn index f89503e2014666..90f39babb4fbdb 100644 --- a/ios/chrome/app/resources/BUILD.gn +++ b/ios/chrome/app/resources/BUILD.gn @@ -107,7 +107,7 @@ bundle_data("launchscreen_assets") { ] } -bundle_data_xib("launchscreen_xib") { +bundle_data_ib_file("launchscreen_xib") { source = "LaunchScreen.xib" deps = [ ios_launchscreen_assets_target, diff --git a/ios/chrome/browser/ui/BUILD.gn b/ios/chrome/browser/ui/BUILD.gn index ebaf2c476fc2cb..8883299f35cbf1 100644 --- a/ios/chrome/browser/ui/BUILD.gn +++ b/ios/chrome/browser/ui/BUILD.gn @@ -77,7 +77,7 @@ source_set("unit_tests") { ] } -bundle_data_xib("native_content_controller_test_xib") { +bundle_data_ib_file("native_content_controller_test_xib") { visibility = [ ":unit_tests" ] testonly = true source = "native_content_controller_test.xib" diff --git a/ios/chrome/browser/ui/downloads/BUILD.gn b/ios/chrome/browser/ui/downloads/BUILD.gn index 80010bd8279459..033ec0cb900dc0 100644 --- a/ios/chrome/browser/ui/downloads/BUILD.gn +++ b/ios/chrome/browser/ui/downloads/BUILD.gn @@ -29,6 +29,6 @@ bundle_data("assets") { ] } -bundle_data_xib("download_manager_controller_xib") { +bundle_data_ib_file("download_manager_controller_xib") { source = "resources/DownloadManagerController.xib" }