From 5a4c350ee9dc22ee2ee5b66eb174732eab64fb75 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Tue, 8 Aug 2023 18:14:52 +0000 Subject: [PATCH] Teach autoninja to handle siso/autosiso autoninja is intended to mean "build this directory, don't bother me with the details". As we transition to siso it is therefore appropriate that it should take on the duty of deciding whether to invoke ninja or siso. By looking for a use_siso gn arg autoninja can easily do this. This change relies on crrev.com/c/4753433 to add the use_siso gn arg. This change also teaches autoninja to detect if a user switches between siso and ninja without doing a gn clean inbetween. Note that this change also teaches autoninja to invoke autosiso or siso ninja based on whether use_remoteexec is true. Bug: b/293657720 Change-Id: I3ad36a81857e75ffe6babc4f107b777e733a285b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4749722 Reviewed-by: Philipp Wollermann Reviewed-by: Junji Watanabe Commit-Queue: Bruce Dawson --- autoninja.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/autoninja.py b/autoninja.py index 1dbd38ec6..ece9126b4 100755 --- a/autoninja.py +++ b/autoninja.py @@ -62,12 +62,10 @@ def main(args): file=sys.stderr) print(file=sys.stderr) - # Strip -o/--offline so ninja doesn't see them. - input_args = [arg for arg in input_args if arg not in ('-o', '--offline')] - use_goma = False use_remoteexec = False use_rbe = False + use_siso = False # Attempt to auto-detect remote build acceleration. We support gn-based # builds, where we look for args.gn in the build tree, and cmake-based builds @@ -94,6 +92,27 @@ def main(args): if re.search(r'(^|\s)(use_rbe)\s*=\s*true($|\s)', line_without_comment): use_rbe = True continue + if re.search(r'(^|\s)(use_siso)\s*=\s*true($|\s)', + line_without_comment): + use_siso = True + continue + + if use_siso: + ninja_marker = os.path.join(output_dir, '.ninja_deps') + if os.path.exists(ninja_marker): + return ('echo Run gn clean before switching from ninja to siso in %s' % + output_dir) + siso = ['autosiso'] if use_remoteexec else ['siso', 'ninja'] + if sys.platform.startswith('win'): + # An explicit 'call' is needed to make sure the invocation of autosiso + # returns to autoninja.bat, and the command prompt title gets reset. + siso = ['call'] + siso + return ' '.join(siso + input_args[1:]) + + siso_marker = os.path.join(output_dir, '.siso_deps') + if os.path.exists(siso_marker): + return ('echo Run gn clean before switching from siso to ninja in %s' % + output_dir) else: for relative_path in [ @@ -108,6 +127,9 @@ def main(args): use_goma = True break + # Strip -o/--offline so ninja doesn't see them. + input_args = [arg for arg in input_args if arg not in ('-o', '--offline')] + # If GOMA_DISABLED is set to "true", "t", "yes", "y", or "1" # (case-insensitive) then gomacc will use the local compiler instead of doing # a goma compile. This is convenient if you want to briefly disable goma. It