Additional switches to build_aar.py
Extra switches to GN could be passed via --extra-gn-switches. Extra switches to Ninja could be passed via --extra-ninja-switches. They could be used in different scenarios, when additional switches need to be passed to GN or Ninja. For example, when diagnosing build issues extra switch `-v` could be passed to enable verbose logging of GN and Ninja. Bug: None Change-Id: I09d18a57b3df4e698784fb7d58c02e8adecddefa Reviewed-on: https://webrtc-review.googlesource.com/78722 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23388}
This commit is contained in:

committed by
Commit Bot

parent
94150ee487
commit
f517f11fcb
@ -67,8 +67,21 @@ def _ParseArgs():
|
||||
help='Debug logging.')
|
||||
parser.add_argument('--extra-gn-args', default=[], nargs='*',
|
||||
help="""Additional GN arguments to be used during Ninja generation.
|
||||
These are applied after any other arguments and will
|
||||
override any values defined by the script.""")
|
||||
These are passed to gn inside `--args` switch and
|
||||
applied after any other arguments and will
|
||||
override any values defined by the script.
|
||||
Example of building debug aar file:
|
||||
build_aar.py --extra-gn-args='is_debug=true'""")
|
||||
parser.add_argument('--extra-ninja-switches', default=[], nargs='*',
|
||||
help="""Additional Ninja switches to be used during compilation.
|
||||
These are applied after any other Ninja switches.
|
||||
Example of enabling verbose Ninja output:
|
||||
build_aar.py --extra-ninja-switches='-v'""")
|
||||
parser.add_argument('--extra-gn-switches', default=[], nargs='*',
|
||||
help="""Additional GN switches to be used during compilation.
|
||||
These are applied after any other GN switches.
|
||||
Example of enabling verbose GN output:
|
||||
build_aar.py --extra-gn-switches='-v'""")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@ -129,7 +142,8 @@ def _GetArmVersion(arch):
|
||||
raise Exception('Unknown arch: ' + arch)
|
||||
|
||||
|
||||
def Build(build_dir, arch, use_goma, extra_gn_args):
|
||||
def Build(build_dir, arch, use_goma, extra_gn_args, extra_gn_switches,
|
||||
extra_ninja_switches):
|
||||
"""Generates target architecture using GN and builds it using ninja."""
|
||||
logging.info('Building: %s', arch)
|
||||
output_directory = _GetOutputDirectory(build_dir, arch)
|
||||
@ -147,11 +161,14 @@ def Build(build_dir, arch, use_goma, extra_gn_args):
|
||||
gn_args_str = '--args=' + ' '.join([
|
||||
k + '=' + _EncodeForGN(v) for k, v in gn_args.items()] + extra_gn_args)
|
||||
|
||||
_RunGN(['gen', output_directory, gn_args_str])
|
||||
gn_args = ['gen', output_directory, gn_args_str]
|
||||
gn_args.extend(extra_gn_switches)
|
||||
_RunGN(gn_args)
|
||||
|
||||
ninja_args = TARGETS[:]
|
||||
if use_goma:
|
||||
ninja_args.extend(['-j', '200'])
|
||||
ninja_args.extend(extra_ninja_switches)
|
||||
_RunNinja(output_directory, ninja_args)
|
||||
|
||||
|
||||
@ -181,12 +198,16 @@ def GenerateLicenses(output_dir, build_dir, archs):
|
||||
|
||||
|
||||
def BuildAar(archs, output_file, use_goma=False, extra_gn_args=None,
|
||||
ext_build_dir=None):
|
||||
ext_build_dir=None, extra_gn_switches=None,
|
||||
extra_ninja_switches=None):
|
||||
extra_gn_args = extra_gn_args or []
|
||||
extra_gn_switches = extra_gn_switches or []
|
||||
extra_ninja_switches = extra_ninja_switches or []
|
||||
build_dir = ext_build_dir if ext_build_dir else tempfile.mkdtemp()
|
||||
|
||||
for arch in archs:
|
||||
Build(build_dir, arch, use_goma, extra_gn_args)
|
||||
Build(build_dir, arch, use_goma, extra_gn_args, extra_gn_switches,
|
||||
extra_ninja_switches)
|
||||
|
||||
with zipfile.ZipFile(output_file, 'w') as aar_file:
|
||||
# Architecture doesn't matter here, arbitrarily using the first one.
|
||||
@ -206,7 +227,7 @@ def main():
|
||||
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
|
||||
|
||||
BuildAar(args.arch, args.output, args.use_goma, args.extra_gn_args,
|
||||
args.build_dir)
|
||||
args.build_dir, args.extra_gn_switches, args.extra_ninja_switches)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Reference in New Issue
Block a user