mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.
Reformatted using:
files=( $(
git ls-tree -r --name-only HEAD | \
grep -Ev -e '^(third_party|recipes)/' | \
grep '\.py$';
git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"
The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py
These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py
Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
86 lines
2.6 KiB
Python
Executable File
86 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env vpython3
|
|
# Copyright 2023 The ChromiumOS Authors
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
# [VPYTHON:BEGIN]
|
|
# python_version: "3.8"
|
|
# [VPYTHON:END]
|
|
"""Bazel launcher wrapper.
|
|
|
|
This script starts Bazel appropriate for the project you're working in. It's
|
|
currently used by ChromiumOS, but is intended for use and to be updated by any
|
|
depot_tools users who are using Bazel.
|
|
|
|
In the case this script is not able to detect which project you're working in,
|
|
it will fall back to using the next "bazel" executable in your PATH.
|
|
"""
|
|
|
|
import itertools
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
from typing import List, Optional
|
|
|
|
|
|
def _find_bazel_cros() -> Optional[Path]:
|
|
"""Find the bazel launcher for ChromiumOS."""
|
|
cwd = Path.cwd()
|
|
for parent in itertools.chain([cwd], cwd.parents):
|
|
bazel_launcher = parent / "chromite" / "bin" / "bazel"
|
|
if bazel_launcher.exists():
|
|
return bazel_launcher
|
|
return None
|
|
|
|
|
|
def _find_next_bazel_in_path() -> Optional[Path]:
|
|
"""The fallback method: search the remainder of PATH for bazel."""
|
|
# Remove depot_tools from PATH if present.
|
|
depot_tools = Path(__file__).resolve().parent
|
|
path_env = os.environ.get("PATH", os.defpath)
|
|
search_paths = []
|
|
for path in path_env.split(os.pathsep):
|
|
if Path(path).resolve() != depot_tools:
|
|
search_paths.append(path)
|
|
new_path_env = os.pathsep.join(search_paths)
|
|
bazel = shutil.which("bazel", path=new_path_env)
|
|
if bazel:
|
|
return Path(bazel)
|
|
return None
|
|
|
|
|
|
# All functions used to search for Bazel (in order of search).
|
|
_SEARCH_FUNCTIONS = (
|
|
_find_bazel_cros,
|
|
_find_next_bazel_in_path,
|
|
)
|
|
|
|
_FIND_FAILURE_MSG = """\
|
|
ERROR: The depot_tools bazel launcher was unable to find an appropriate bazel
|
|
executable to use.
|
|
|
|
For ChromiumOS developers:
|
|
Make sure your current directory is inside a ChromiumOS checkout (e.g.,
|
|
~/chromiumos). If you're already in a ChromiumOS checkout, it may be because
|
|
you're working on a branch that's too old (i.e., prior to Bazel).
|
|
|
|
If you're not working on any of the above listed projects, this launcher assumes
|
|
that you have Bazel installed on your system somewhere else in PATH. Check that
|
|
it's actually installed."""
|
|
|
|
|
|
def main(argv: List[str]) -> int:
|
|
"""Main."""
|
|
for search_func in _SEARCH_FUNCTIONS:
|
|
bazel = search_func()
|
|
if bazel:
|
|
os.execv(bazel, [str(bazel), *argv])
|
|
|
|
print(_FIND_FAILURE_MSG, file=sys.stderr)
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv[1:]))
|