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 <brucedawson@chromium.org>
Reviewed-by: Junji Watanabe <jwata@google.com>
Reviewed-by: Philipp Wollermann <philwo@google.com>
changes/03/4784103/6
Bruce Dawson 2 years ago committed by LUCI CQ
parent 2d5c673fdb
commit 9c4fbc5a2a

@ -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)

Loading…
Cancel
Save