diff options
author | sdefresne <sdefresne@chromium.org> | 2016-03-25 10:10:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 17:11:37 +0000 |
commit | f33a28da1492886771cefe133372077b762a9077 (patch) | |
tree | 0b1e7ef0e7cba373a06109174b0216391717ca99 /build | |
parent | f7fd5b6ce047688f350a93c60658b5f4e10ad1a8 (diff) | |
download | chromium_src-f33a28da1492886771cefe133372077b762a9077.zip chromium_src-f33a28da1492886771cefe133372077b762a9077.tar.gz chromium_src-f33a28da1492886771cefe133372077b762a9077.tar.bz2 |
[iOS] Fix ios_web_shell to build with gn.
Add a new template bundle_data_xib that compile a xib or storyboard
file and declare a bundle_data target with the compilation output.
Add bundle_data targets required to get ios_web_shell to build and
run in the simulator.
BUG=297668,546283
Review URL: https://codereview.chromium.org/1808733003
Cr-Commit-Position: refs/heads/master@{#383295}
Diffstat (limited to 'build')
-rw-r--r-- | build/config/ios/ios_compile_xib.py | 34 | ||||
-rw-r--r-- | build/config/ios/rules.gni | 60 |
2 files changed, 94 insertions, 0 deletions
diff --git a/build/config/ios/ios_compile_xib.py b/build/config/ios/ios_compile_xib.py new file mode 100644 index 0000000..ebca3ab --- /dev/null +++ b/build/config/ios/ios_compile_xib.py @@ -0,0 +1,34 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +import argparse +import os +import subprocess +import sys + + +def main(): + parser = argparse.ArgumentParser( + description='A script to compile xib and storyboard.', + fromfile_prefix_chars='@') + parser.add_argument('-o', '--output', required=True, + help='Path to output bundle.') + parser.add_argument('-i', '--input', required=True, + help='Path to input xib or storyboard.') + parser.add_argument('-m', '--minimum-deployment-target', required=True, + help='Minimum deployment target.') + args = parser.parse_args() + + subprocess.check_call([ + 'xcrun', 'ibtool', '--errors', '--warnings', '--notices', + '--auto-activate-custom-fonts', '--target-device', 'iphone', + '--target-device', 'ipad', '--output-format', 'human-readable-text', + '--minimum-deployment-target', args.minimum_deployment_target, + '--compile', os.path.abspath(args.output), os.path.abspath(args.input), + ]) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni index 87e7ff3..8afbbca 100644 --- a/build/config/ios/rules.gni +++ b/build/config/ios/rules.gni @@ -167,3 +167,63 @@ template("app") { # an alias to "ninja -C out/Default base_unittests" (for convenience # and compatibility with gyp), } + +# Compile a xib or storyboard file and add it to a bundle_data so that it is +# available at runtime in the bundle. +# +# Arguments +# +# source: +# string, path of the xib or storyboard to compile. +# +# Forwards all variables to the bundle_data target. +template("bundle_data_xib") { + 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" + + _nib_basename = get_path_info(invoker.source, "name") + _nib_filename = "$_nib_basename.nib" + + action(_compile_xib) { + visibility = [ ":$_target_name" ] + script = "//build/config/ios/ios_compile_xib.py" + sources = [ + invoker.source, + ] + outputs = [ + "$target_gen_dir/$_nib_filename/objects.nib", + "$target_gen_dir/$_nib_filename/runtime.nib", + ] + args = [ + "--minimum-deployment-target", + ios_deployment_target, + "--output", + rebase_path("$target_gen_dir/$_nib_filename"), + "--input", + rebase_path(invoker.source, root_build_dir), + ] + } + + bundle_data(_target_name) { + forward_variables_from(invoker, "*", [ "source" ]) + + if (!defined(public_deps)) { + public_deps = [] + } + public_deps += [ ":$_compile_xib" ] + + sources = [ + "$target_gen_dir/$_nib_filename/objects.nib", + "$target_gen_dir/$_nib_filename/runtime.nib", + ] + outputs = [ + "{{bundle_resources_dir}}/$_nib_filename/{{source_file_part}}", + ] + } +} |