Commit 39fe426a authored by lpromero's avatar lpromero Committed by Commit bot

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}
parent fac225ce
...@@ -795,7 +795,7 @@ set_defaults("ios_appex_bundle") { ...@@ -795,7 +795,7 @@ set_defaults("ios_appex_bundle") {
# string, path of the xib or storyboard to compile. # string, path of the xib or storyboard to compile.
# #
# Forwards all variables to the bundle_data target. # 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") assert(defined(invoker.source), "source needs to be defined for $target_name")
_source_extension = get_path_info(invoker.source, "extension") _source_extension = get_path_info(invoker.source, "extension")
...@@ -803,12 +803,19 @@ template("bundle_data_xib") { ...@@ -803,12 +803,19 @@ template("bundle_data_xib") {
"source must be a .xib or .storyboard for $target_name") "source must be a .xib or .storyboard for $target_name")
_target_name = 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 = [ sources = [
invoker.source, invoker.source,
] ]
output_extension = _output_extension
visibility = [ ":$_target_name" ] visibility = [ ":$_target_name" ]
ibtool_flags = [ ibtool_flags = [
"--minimum-deployment-target", "--minimum-deployment-target",
...@@ -827,9 +834,9 @@ template("bundle_data_xib") { ...@@ -827,9 +834,9 @@ template("bundle_data_xib") {
if (!defined(public_deps)) { if (!defined(public_deps)) {
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 = [ outputs = [
"{{bundle_resources_dir}}/{{source_file_part}}", "{{bundle_resources_dir}}/{{source_file_part}}",
......
...@@ -202,7 +202,7 @@ template("info_plist") { ...@@ -202,7 +202,7 @@ template("info_plist") {
} }
} }
# Template to combile .xib or .storyboard files. # Template to compile .xib and .storyboard files.
# #
# Arguments # Arguments
# #
...@@ -211,7 +211,7 @@ template("info_plist") { ...@@ -211,7 +211,7 @@ template("info_plist") {
# #
# ibtool_flags: # ibtool_flags:
# (optional) list of string, additional flags to pass to the ibtool # (optional) list of string, additional flags to pass to the ibtool
template("compile_xibs") { template("compile_ib_files") {
action_foreach(target_name) { action_foreach(target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
...@@ -219,23 +219,28 @@ template("compile_xibs") { ...@@ -219,23 +219,28 @@ template("compile_xibs") {
"visibility", "visibility",
]) ])
assert(defined(invoker.sources), 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 = [] ibtool_flags = []
if (defined(invoker.ibtool_flags)) { if (defined(invoker.ibtool_flags)) {
ibtool_flags = 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 sources = invoker.sources
outputs = [ outputs = [
"$target_gen_dir/$target_name/{{source_name_part}}.nib", "$target_gen_dir/$target_name/{{source_name_part}}.$_output_extension",
] ]
args = [ args = [
"--input", "--input",
"{{source}}", "{{source}}",
"--output", "--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) { if (!use_system_xcode) {
args += [ args += [
......
...@@ -77,10 +77,11 @@ template("mac_xib_bundle_data") { ...@@ -77,10 +77,11 @@ template("mac_xib_bundle_data") {
_target_name = target_name _target_name = target_name
_compile_target_name = _target_name + "_compile_ibtool" _compile_target_name = _target_name + "_compile_ibtool"
compile_xibs(_compile_target_name) { compile_ib_files(_compile_target_name) {
forward_variables_from(invoker, [ "testonly" ]) forward_variables_from(invoker, [ "testonly" ])
visibility = [ ":$_target_name" ] visibility = [ ":$_target_name" ]
sources = invoker.sources sources = invoker.sources
output_extension = "nib"
ibtool_flags = [ ibtool_flags = [
"--minimum-deployment-target", "--minimum-deployment-target",
mac_deployment_target, mac_deployment_target,
......
...@@ -107,7 +107,7 @@ bundle_data("launchscreen_assets") { ...@@ -107,7 +107,7 @@ bundle_data("launchscreen_assets") {
] ]
} }
bundle_data_xib("launchscreen_xib") { bundle_data_ib_file("launchscreen_xib") {
source = "LaunchScreen.xib" source = "LaunchScreen.xib"
deps = [ deps = [
ios_launchscreen_assets_target, ios_launchscreen_assets_target,
......
...@@ -77,7 +77,7 @@ source_set("unit_tests") { ...@@ -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" ] visibility = [ ":unit_tests" ]
testonly = true testonly = true
source = "native_content_controller_test.xib" source = "native_content_controller_test.xib"
......
...@@ -29,6 +29,6 @@ bundle_data("assets") { ...@@ -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" source = "resources/DownloadManagerController.xib"
} }
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