Commit dac798e2 authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

Add ninja_args option to web_view build script.

Bug: None
Change-Id: Ic9427bdefbab9ac6caee15f1d6a43a23c7830cbc
Reviewed-on: https://chromium-review.googlesource.com/592235
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491885}
parent 06929038
...@@ -21,7 +21,7 @@ def target_dir_name(build_config, target_device): ...@@ -21,7 +21,7 @@ def target_dir_name(build_config, target_device):
""" """
return '%s-iphone%s' % (build_config, target_device) return '%s-iphone%s' % (build_config, target_device)
def build(build_config, target_device, extra_gn_options): def build(build_config, target_device, extra_gn_options, extra_ninja_options):
"""Generates and builds CronetChromeWebView.framework. """Generates and builds CronetChromeWebView.framework.
Args: Args:
...@@ -29,6 +29,8 @@ def build(build_config, target_device, extra_gn_options): ...@@ -29,6 +29,8 @@ def build(build_config, target_device, extra_gn_options):
target_device: A string describing the target device. Ex: 'simulator' target_device: A string describing the target device. Ex: 'simulator'
extra_gn_options: A string of gn args (space separated key=value items) to extra_gn_options: A string of gn args (space separated key=value items) to
be appended to the gn gen command. be appended to the gn gen command.
extra_ninja_options: A string of gn options to be appended to the ninja
command.
Returns: Returns:
The return code of generating ninja if it is non-zero, else the return code The return code of generating ninja if it is non-zero, else the return code
...@@ -63,8 +65,11 @@ def build(build_config, target_device, extra_gn_options): ...@@ -63,8 +65,11 @@ def build(build_config, target_device, extra_gn_options):
if gn_result != 0: if gn_result != 0:
return gn_result return gn_result
ninja_command = ('ninja -C %s ios/web_view:cronet_ios_web_view_package' % ninja_options = '-C %s' % build_dir
build_dir) if extra_ninja_options:
ninja_options += ' %s' % extra_ninja_options
ninja_command = ('ninja %s ios/web_view:cronet_ios_web_view_package' %
ninja_options)
print ninja_command print ninja_command
return os.system(ninja_command) return os.system(ninja_command)
...@@ -92,7 +97,11 @@ def copy_build_products(build_config, target_device, out_dir): ...@@ -92,7 +97,11 @@ def copy_build_products(build_config, target_device, out_dir):
print 'Copying %s to %s' % (symbols_source, symbols_dest) print 'Copying %s to %s' % (symbols_source, symbols_dest)
shutil.copytree(symbols_source, symbols_dest) shutil.copytree(symbols_source, symbols_dest)
def package_framework(build_config, target_device, out_dir, extra_gn_options): def package_framework(build_config,
target_device,
out_dir,
extra_gn_options,
extra_ninja_options):
"""Builds CronetChromeWebView.framework and copies the result to out_dir. """Builds CronetChromeWebView.framework and copies the result to out_dir.
Args: Args:
...@@ -101,13 +110,18 @@ def package_framework(build_config, target_device, out_dir, extra_gn_options): ...@@ -101,13 +110,18 @@ def package_framework(build_config, target_device, out_dir, extra_gn_options):
out_dir: A string to the path which all build products will be copied. out_dir: A string to the path which all build products will be copied.
extra_gn_options: A string of gn args (space separated key=value items) to extra_gn_options: A string of gn args (space separated key=value items) to
be appended to the gn gen command. be appended to the gn gen command.
extra_ninja_options: A string of gn options to be appended to the ninja
command.
Returns: Returns:
The return code of the build if it fails or 0 if the build was successful. The return code of the build if it fails or 0 if the build was successful.
""" """
print '\nBuilding for %s (%s)' % (target_device, build_config) print '\nBuilding for %s (%s)' % (target_device, build_config)
build_result = build(build_config, target_device, extra_gn_options) build_result = build(build_config,
target_device,
extra_gn_options,
extra_ninja_options)
if build_result != 0: if build_result != 0:
error = 'Building %s/%s failed with code: ' % (build_config, target_device) error = 'Building %s/%s failed with code: ' % (build_config, target_device)
print >>sys.stderr, error, build_result print >>sys.stderr, error, build_result
...@@ -115,7 +129,7 @@ def package_framework(build_config, target_device, out_dir, extra_gn_options): ...@@ -115,7 +129,7 @@ def package_framework(build_config, target_device, out_dir, extra_gn_options):
copy_build_products(build_config, target_device, out_dir) copy_build_products(build_config, target_device, out_dir)
return 0 return 0
def package_all_frameworks(out_dir, extra_gn_options): def package_all_frameworks(out_dir, extra_gn_options, extra_ninja_options):
"""Builds CronetChromeWebView.framework. """Builds CronetChromeWebView.framework.
Builds Release and Debug versions of CronetChromeWebView.framework for both Builds Release and Debug versions of CronetChromeWebView.framework for both
...@@ -125,6 +139,8 @@ def package_all_frameworks(out_dir, extra_gn_options): ...@@ -125,6 +139,8 @@ def package_all_frameworks(out_dir, extra_gn_options):
out_dir: A string to the path which all build products will be copied. out_dir: A string to the path which all build products will be copied.
extra_gn_options: A string of gn args (space separated key=value items) to extra_gn_options: A string of gn args (space separated key=value items) to
be appended to the gn gen command. be appended to the gn gen command.
extra_ninja_options: A string of gn options to be appended to the ninja
command.
Returns: Returns:
0 if all builds are successful or 1 if any build fails. 0 if all builds are successful or 1 if any build fails.
...@@ -134,14 +150,17 @@ def package_all_frameworks(out_dir, extra_gn_options): ...@@ -134,14 +150,17 @@ def package_all_frameworks(out_dir, extra_gn_options):
# Package all builds in the output directory # Package all builds in the output directory
os.makedirs(out_dir) os.makedirs(out_dir)
if package_framework('Debug', 'simulator', out_dir, extra_gn_options) != 0: configurations = [('Debug', 'simulator'),
return 1 ('Debug', 'os'),
if package_framework('Debug', 'os', out_dir, extra_gn_options) != 0: ('Release', 'simulator'),
return 1 ('Release', 'os')]
if package_framework('Release', 'simulator', out_dir, extra_gn_options) != 0: for build_config, target_device in configurations:
return 1 if package_framework(build_config,
if package_framework('Release', 'os', out_dir, extra_gn_options) != 0: target_device,
return 1 out_dir,
extra_gn_options,
extra_ninja_options) != 0:
return 1
# Copy common files from last built package to out_dir. # Copy common files from last built package to out_dir.
build_dir = os.path.join("out", target_dir_name('Release', 'os')) build_dir = os.path.join("out", target_dir_name('Release', 'os'))
...@@ -162,6 +181,8 @@ def main(): ...@@ -162,6 +181,8 @@ def main():
help='path to output directory') help='path to output directory')
parser.add_argument('--no_goma', action='store_true', parser.add_argument('--no_goma', action='store_true',
help='Prevents adding use_goma=true to the gn args.') help='Prevents adding use_goma=true to the gn args.')
parser.add_argument('--ninja_args',
help='Additional gn args to pass through to ninja.')
options, extra_options = parser.parse_known_args() options, extra_options = parser.parse_known_args()
print 'Options:', options print 'Options:', options
...@@ -178,7 +199,7 @@ def main(): ...@@ -178,7 +199,7 @@ def main():
gn_options = '' if options.no_goma else 'use_goma=true' gn_options = '' if options.no_goma else 'use_goma=true'
return package_all_frameworks(out_dir, gn_options) return package_all_frameworks(out_dir, gn_options, options.ninja_args)
if __name__ == '__main__': if __name__ == '__main__':
......
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