From 9c4fbc5a2a69e8388b9b5ce937aeb3c67ce7ca42 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Tue, 22 Aug 2023 15:16:55 +0000 Subject: [PATCH] Improve ninja-to-siso switch detection autoninja tries to detect if a user switches an output directory from ninja to siso without doing a "gn clean" between. Initiallly this detection looked for .ninja_deps, but this file doesn't always exist after a ninja build. This change switches to looking for .ninja_log. However autosiso creates a .ninja_log file (currently zero length) so the new check is: a) If .siso_deps exists then a siso build has been done and only siso builds are allowed. b) If .siso_deps doesn't exist but .ninja_log does then a ninja build has been done and only ninja builds are allowed. c) If neither file exists then the directory was cleaned and any type of build is allowed. Bug: b/293657720 Change-Id: I2cdba74f0894e62aa0e68f91e225f497b2425f45 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4784103 Commit-Queue: Bruce Dawson Reviewed-by: Junji Watanabe Reviewed-by: Philipp Wollermann --- autoninja.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/autoninja.py b/autoninja.py index 01a5935f4..d4f8c0c0f 100755 --- a/autoninja.py +++ b/autoninja.py @@ -97,9 +97,13 @@ def main(args): use_siso = True continue + siso_marker = os.path.join(output_dir, '.siso_deps') if use_siso: - ninja_marker = os.path.join(output_dir, '.ninja_deps') - if os.path.exists(ninja_marker): + ninja_marker = os.path.join(output_dir, '.ninja_log') + # autosiso generates a .ninja_log file so the mere existence of a + # .ninja_log file doesn't imply that a ninja build was done. However if + # there is a .ninja_log but no .siso_deps then that implies a ninja build. + if os.path.exists(ninja_marker) and not os.path.exists(siso_marker): return ('echo Run gn clean before switching from ninja to siso in %s' % output_dir) siso = ['autosiso'] if use_remoteexec else ['siso', 'ninja'] @@ -109,7 +113,6 @@ def main(args): 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)