From 3ca8d0d0caa46532b338c221dbff03220a64bfc1 Mon Sep 17 00:00:00 2001 From: Fumitoshi Ukai Date: Thu, 13 Apr 2023 05:24:08 +0000 Subject: [PATCH] add siso wrapper Bug: b/277855544, b/277859568 Change-Id: I520834647881745db7a42fd357bc829a7c6779d8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4413517 Reviewed-by: Philipp Wollermann Reviewed-by: Joanna Wang Reviewed-by: Takuto Ikuta Reviewed-by: Junji Watanabe Commit-Queue: Joanna Wang Commit-Queue: Junji Watanabe Auto-Submit: Fumitoshi Ukai --- GOMA_OWNERS => BUILD_OWNERS | 4 +-- OWNERS | 9 ++--- siso | 8 +++++ siso.bat | 12 +++++++ siso.py | 72 +++++++++++++++++++++++++++++++++++++ tests/OWNERS | 2 +- 6 files changed, 100 insertions(+), 7 deletions(-) rename GOMA_OWNERS => BUILD_OWNERS (68%) create mode 100755 siso create mode 100644 siso.bat create mode 100644 siso.py diff --git a/GOMA_OWNERS b/BUILD_OWNERS similarity index 68% rename from GOMA_OWNERS rename to BUILD_OWNERS index f9b879bd4d..314df234db 100644 --- a/GOMA_OWNERS +++ b/BUILD_OWNERS @@ -1,6 +1,6 @@ -jojwang@chromium.org -jojwang@google.com jwata@google.com +philwo@google.com +richardwa@google.com tikuta@chromium.org tikuta@google.com ukai@chromium.org diff --git a/OWNERS b/OWNERS index b2f9603c31..fe3a5388d5 100644 --- a/OWNERS +++ b/OWNERS @@ -13,14 +13,12 @@ per-file gn*=dpranke@google.com per-file ninja*=dpranke@google.com per-file ninja*=thakis@chromium.org -per-file ninja_reclient.py=file://GOMA_OWNERS +per-file ninja_reclient.py=file://BUILD_OWNERS per-file ninjalog*=tikuta@chromium.org per-file post_build_ninja_summary.py=brucedawson@chromium.org per-file presubmit*.py=brucedawson@chromium.org -per-file cipd_manifest*=file://GOMA_OWNERS - per-file pylint*=vapier@chromium.org per-file cbuildbot=file://CROS_OWNERS @@ -33,7 +31,10 @@ per-file repo_launcher=file://CROS_OWNERS per-file CROS_OWNERS=file://CROS_OWNERS # for the Goma client update -per-file cipd_manifest*=file://GOMA_OWNERS +per-file cipd_manifest*=file://BUILD_OWNERS + +per-file BUILD_OWNERS=file://BUILD_OWNERS +per-file siso*=file://BUILD_OWNERS # LUCI related tooling per-file bb*=file://LUCI_OWNERS diff --git a/siso b/siso new file mode 100755 index 0000000000..9b27844fda --- /dev/null +++ b/siso @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Copyright (c) 2023 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +base_dir=$(dirname "$0") +PYTHONDONTWRITEBYTECODE=1 exec python3 "$base_dir/siso.py" "$@" diff --git a/siso.bat b/siso.bat new file mode 100644 index 0000000000..28b03e49ef --- /dev/null +++ b/siso.bat @@ -0,0 +1,12 @@ +@echo off +:: Copyright 2023 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. +setlocal + +:: Ensure that "depot_tools" is somewhere in PATH so this tool can be used +:: standalone, but allow other PATH manipulations to take priority. +set PATH=%PATH%;%~dp0 + +:: Defer control. +python3 "%~dp0\siso.py" "%*" diff --git a/siso.py b/siso.py new file mode 100644 index 0000000000..e6135413c8 --- /dev/null +++ b/siso.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# Copyright 2023 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 siso binary that is pulled to +third_party as part of gclient sync. It will automatically find the siso +binary when run inside a gclient source tree, so users can just type +"siso" on the command line.""" + +import os +import subprocess +import sys + +import gclient_paths + + +def main(args): + # On Windows the siso.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 siso.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) + + environ = os.environ.copy() + + # 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 + env = environ.copy() + sisoenv_path = os.path.join(base_path, 'build', 'config', 'siso', + '.sisoenv') + if os.path.exists(sisoenv_path): + with open(sisoenv_path) as f: + for line in f.readlines(): + k, v = line.rstrip().split('=', 1) + env[k] = v + siso_path = os.path.join(base_path, 'third_party', 'siso', + 'siso' + gclient_paths.GetExeSuffix()) + if os.path.isfile(siso_path): + return subprocess.call([siso_path] + args[1:], env=env) + + print( + 'depot_tools/siso.py: Could not find Siso in the third_party of ' + 'the current project.', + file=sys.stderr) + return 1 + + +if __name__ == '__main__': + try: + sys.exit(main(sys.argv)) + except KeyboardInterrupt: + sys.exit(1) diff --git a/tests/OWNERS b/tests/OWNERS index 03a0100ca1..317807ef25 100644 --- a/tests/OWNERS +++ b/tests/OWNERS @@ -1,4 +1,4 @@ per-file autoninja_test.py=brucedawson@chromium.org per-file autoninja_test.py=tikuta@chromium.org per-file ninjalog_uploader_test.py=tikuta@chromium.org -per-file ninja_reclient_test.py=file://GOMA_OWNERS +per-file ninja_reclient_test.py=file://BUILD_OWNERS