mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
This reverts commitc9fb389f4b. Reason for revert: Breaks ability to do "ninja -t commands" Original change's description: > Reland "siso.py: check ninja marker" > > This reverts commitb1c6497e19. > > Reason for revert: Fix var name > > ``` > ukai@ukai ...src/chromium/src % ~/src/depot_tools/depot_tools/siso ninja -C out/ninja > depot_tools/siso.py: Using Siso binary from SISO_PATH: /usr/local/google/home/ukai/go/bin/siso. > depot_tools/siso.py: out/ninja contains Ninja state file. > Use `autoninja` to use reclient, > or run `gn clean out/ninja` to switch from ninja to siso > > ukai@ukai ...src/chromium/src % ~/src/depot_tools/depot_tools/siso ninja -C out/siso base > depot_tools/siso.py: Using Siso binary from SISO_PATH: /usr/local/google/home/ukai/go/bin/siso. > 4.63s init credentials > reapi instance: projects/rbe-chrome-untrusted/instances/default_instance > 1.63s loading fs state > 3.42s load build.ninja > 15.32s Regenerating ninja files > 3.64s reloading > build finished > local:3 remote:0 cache:0 fallback:0 skip:3026 > reapi: ops: 17(err:1) / r:0(err:0) 0B / w:0(err:0) 0B > fs: ops: 12092(err:192) / r:350(err:0) 189.04MiB / w:1(err:0) 13.96KiB > 27.29s Build Succeeded: 3 steps - 0.11/s > > ``` > > Original change's description: > > Revert "siso.py: check ninja marker" > > > > This reverts commit41bbfb8b90. > > > > Reason for revert: > > ukai@ukai ...src/chromium/src % siso ninja -C out/siso > > depot_tools/siso.py: Using Siso binary from SISO_PATH: /usr/local/google/home/ukai/go/bin/siso. > > Traceback (most recent call last): > > File "/usr/local/google/home/ukai/depot_tools/siso.py", line 115, in <module> > > sys.exit(main(sys.argv)) > > ^^^^^^^^^^^^^^ > > File "/usr/local/google/home/ukai/depot_tools/siso.py", line 104, in main > > checkOutdir(args[1:]) > > File "/usr/local/google/home/ukai/depot_tools/siso.py", line 21, in checkOutdir > > for i, arg in enumerate(ninja_args): > > ^^^^^^^^^^ > > NameError: name 'ninja_args' is not defined. Did you mean: 'ninja_marker'? > > > > > > Original change's description: > > > 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 <jwata@google.com> > > > Commit-Queue: Junji Watanabe <jwata@google.com> > > > Auto-Submit: Fumitoshi Ukai <ukai@google.com> > > > Commit-Queue: Fumitoshi Ukai <ukai@google.com> > > > > Bug: b/338414465 > > Change-Id: Ie69ca1b6c1d3dc47475d9356beab29a917356479 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5514902 > > Reviewed-by: Philipp Wollermann <philwo@chromium.org> > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > > Commit-Queue: Fumitoshi Ukai <ukai@google.com> > > Bug: b/338414465 > Change-Id: Idb18ad9191a062f83b538c1e2a76ee77200c4df0 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5518397 > Reviewed-by: Philipp Wollermann <philwo@chromium.org> > Auto-Submit: Fumitoshi Ukai <ukai@google.com> > Commit-Queue: Fumitoshi Ukai <ukai@google.com> Bug: b/338414465 Change-Id: I0a24db3675762b92e96ab37b629fa12b4af89240 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5522633 Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Auto-Submit: Andrew Grieve <agrieve@chromium.org> Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
97 lines
3.2 KiB
Python
Executable File
97 lines
3.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright 2022 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
"""This script is a wrapper around the ninja binary that is pulled to
|
|
third_party as part of gclient sync. It will automatically find the ninja
|
|
binary when run inside a gclient source tree, so users can just type
|
|
"ninja" on the command line."""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
import gclient_paths
|
|
|
|
|
|
def findNinjaInPath():
|
|
env_path = os.getenv("PATH")
|
|
if not env_path:
|
|
return
|
|
exe = "ninja"
|
|
if sys.platform in ("win32", "cygwin"):
|
|
exe += ".exe"
|
|
for bin_dir in env_path.split(os.pathsep):
|
|
if bin_dir.rstrip(os.sep).endswith("depot_tools"):
|
|
# skip depot_tools to avoid calling ninja.py infinitely.
|
|
continue
|
|
ninja_path = os.path.join(bin_dir, exe)
|
|
if os.path.isfile(ninja_path):
|
|
return ninja_path
|
|
|
|
|
|
def fallback(ninja_args):
|
|
# Try to find ninja in PATH.
|
|
ninja_path = findNinjaInPath()
|
|
if ninja_path:
|
|
return subprocess.call([ninja_path] + ninja_args)
|
|
|
|
print(
|
|
"depot_tools/ninja.py: Could not find Ninja in the third_party of "
|
|
"the current project, nor in your PATH.\n"
|
|
"Please take one of the following actions to install Ninja:\n"
|
|
"- If your project has DEPS, add a CIPD Ninja dependency to DEPS.\n"
|
|
"- Otherwise, add Ninja to your PATH *after* depot_tools.",
|
|
file=sys.stderr,
|
|
)
|
|
return 1
|
|
|
|
|
|
def main(args):
|
|
# On Windows the ninja.bat script passes along the arguments enclosed in
|
|
# double quotes. This prevents multiple levels of parsing of the special '^'
|
|
# characters needed when compiling a single file. When this case is
|
|
# detected, we need to split the argument. This means that arguments
|
|
# containing actual spaces are not supported by ninja.bat, but that is not a
|
|
# real limitation.
|
|
if sys.platform.startswith("win") and len(args) == 2:
|
|
args = args[:1] + args[1].split()
|
|
|
|
# macOS's python sets CPATH, LIBRARY_PATH, SDKROOT implicitly.
|
|
# https://openradar.appspot.com/radar?id=5608755232243712
|
|
#
|
|
# Removing those environment variables to avoid affecting clang's behaviors.
|
|
if sys.platform == "darwin":
|
|
os.environ.pop("CPATH", None)
|
|
os.environ.pop("LIBRARY_PATH", None)
|
|
os.environ.pop("SDKROOT", None)
|
|
|
|
# Get gclient root + src.
|
|
primary_solution_path = gclient_paths.GetPrimarySolutionPath()
|
|
gclient_root_path = gclient_paths.FindGclientRoot(os.getcwd())
|
|
gclient_src_root_path = None
|
|
if gclient_root_path:
|
|
gclient_src_root_path = os.path.join(gclient_root_path, "src")
|
|
|
|
for base_path in set(
|
|
[primary_solution_path, gclient_root_path, gclient_src_root_path]):
|
|
if not base_path:
|
|
continue
|
|
ninja_path = os.path.join(
|
|
base_path,
|
|
"third_party",
|
|
"ninja",
|
|
"ninja" + gclient_paths.GetExeSuffix(),
|
|
)
|
|
if os.path.isfile(ninja_path):
|
|
return subprocess.call([ninja_path] + args[1:])
|
|
|
|
return fallback(args[1:])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
sys.exit(main(sys.argv))
|
|
except KeyboardInterrupt:
|
|
sys.exit(1)
|