Skip to content

Commit

Permalink
Handle storyboards in GN.
Browse files Browse the repository at this point in the history
BUG=none
R=sdefresne@chromium.org,rohitrao@chromium.org

Review-Url: https://codereview.chromium.org/2564023002
Cr-Commit-Position: refs/heads/master@{#437779}
  • Loading branch information
Arcank authored and Commit bot committed Dec 10, 2016
1 parent fac225c commit 39fe426
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 15 deletions.
17 changes: 12 additions & 5 deletions build/config/ios/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -795,20 +795,27 @@ 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")
assert(_source_extension == "xib" || _source_extension == "storyboard",
"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",
Expand All @@ -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}}",
Expand Down
17 changes: 11 additions & 6 deletions build/config/mac/base_rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ template("info_plist") {
}
}

# Template to combile .xib or .storyboard files.
# Template to compile .xib and .storyboard files.
#
# Arguments
#
Expand All @@ -211,31 +211,36 @@ 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,
[
"testonly",
"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 += [
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion build/config/mac/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/app/resources/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ios/chrome/browser/ui/downloads/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 39fe426

Please sign in to comment.