From 41bbfb8b90d7290acb7ef406dfbea01724fe83e3 Mon Sep 17 00:00:00 2001 From: Fumitoshi Ukai Date: Tue, 7 May 2024 08:23:35 +0000 Subject: [PATCH] siso.py: check ninja marker If out dir was built by Ninja, don't build by Siso. (still allow `siso query` etc) Bug: b/338414465 Change-Id: I48f8fbb5e83714fd3d27ff3a2bfffe929e4ef121 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5518396 Reviewed-by: Junji Watanabe Commit-Queue: Junji Watanabe Auto-Submit: Fumitoshi Ukai Commit-Queue: Fumitoshi Ukai --- siso.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/siso.py b/siso.py index a0b8902f9..8db18c5ba 100644 --- a/siso.py +++ b/siso.py @@ -15,6 +15,29 @@ import sys import gclient_paths +def checkOutdir(args): + subcmd = '' + out_dir = "." + for i, arg in enumerate(ninja_args): + if not arg.startswith("-") and not subcmd: + subcmd = arg + continue + if arg == "-C": + out_dir = ninja_args[i + 1] + elif arg.startswith("-C"): + out_dir = arg[2:] + if subcmd != "ninja": + return + ninja_marker = os.path.join(out_dir, ".ninja_deps") + if os.path.exists(ninja_marker): + print("depot_tools/siso.py: %s contains Ninja state file.\n" + "Use `autoninja` to use reclient,\n" + "or run `gn clean %s` to switch from ninja to siso\n" % + (out_dir, out_dir), + file=sys.stderr) + sys.exit(1) + + def main(args): # Propagate signals to siso process so that it can run cleanup steps. # Siso will be terminated immediately after the second Ctrl-C. @@ -78,6 +101,7 @@ def main(args): base_path, 'third_party', 'siso', 'siso' + gclient_paths.GetExeSuffix()) if os.path.isfile(siso_path): + checkOutdir(args[1:]) return subprocess.call([siso_path] + args[1:], env=env) print(