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>
80 lines
3.1 KiB
Python
Executable File
80 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright 2013 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 GN binary that is pulled from Google
|
|
Cloud Storage when you sync Chrome. The binaries go into platform-specific
|
|
subdirectories in the source tree.
|
|
|
|
This script makes there be one place for forwarding to the correct platform's
|
|
binary. It will also automatically try to find the gn binary when run inside
|
|
the chrome source tree, so users can just type "gn" on the command line
|
|
(normally depot_tools is on the path)."""
|
|
|
|
from __future__ import print_function
|
|
|
|
import gclient_paths
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def PruneVirtualEnv():
|
|
# Set by VirtualEnv, no need to keep it.
|
|
os.environ.pop('VIRTUAL_ENV', None)
|
|
|
|
# Set by VPython, if scripts want it back they have to set it explicitly.
|
|
os.environ.pop('PYTHONNOUSERSITE', None)
|
|
|
|
# Look for "activate_this.py" in this path, which is installed by
|
|
# VirtualEnv. This mechanism is used by vpython as well to sanitize
|
|
# VirtualEnvs from $PATH.
|
|
os.environ['PATH'] = os.pathsep.join([
|
|
p for p in os.environ.get('PATH', '').split(os.pathsep)
|
|
if not os.path.isfile(os.path.join(p, 'activate_this.py'))
|
|
])
|
|
|
|
|
|
def main(args):
|
|
# Prune all evidence of VPython/VirtualEnv out of the environment. This
|
|
# means that we 'unwrap' vpython VirtualEnv path/env manipulation.
|
|
# Invocations of `python` from GN should never inherit the gn.py's own
|
|
# VirtualEnv. This also helps to ensure that generated ninja files do not
|
|
# reference python.exe from the VirtualEnv generated from depot_tools' own
|
|
# .vpython file (or lack thereof), but instead reference the default python
|
|
# from the PATH.
|
|
PruneVirtualEnv()
|
|
|
|
# Try in primary solution location first, with the gn binary having been
|
|
# downloaded by cipd in the projects DEPS.
|
|
primary_solution_path = gclient_paths.GetPrimarySolutionPath()
|
|
if primary_solution_path:
|
|
gn_path = os.path.join(primary_solution_path, 'third_party', 'gn',
|
|
'gn' + gclient_paths.GetExeSuffix())
|
|
if os.path.exists(gn_path):
|
|
return subprocess.call([gn_path] + args[1:])
|
|
|
|
# Otherwise try the old .sha1 and download_from_google_storage locations
|
|
# inside of buildtools.
|
|
bin_path = gclient_paths.GetBuildtoolsPlatformBinaryPath()
|
|
if not bin_path:
|
|
print(
|
|
'gn.py: Could not find checkout in any parent of the current '
|
|
'path.\nThis must be run inside a checkout.',
|
|
file=sys.stderr)
|
|
return 1
|
|
gn_path = os.path.join(bin_path, 'gn' + gclient_paths.GetExeSuffix())
|
|
if not os.path.exists(gn_path):
|
|
print('gn.py: Could not find gn executable at: %s' % gn_path,
|
|
file=sys.stderr)
|
|
return 2
|
|
return subprocess.call([gn_path] + args[1:])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
sys.exit(main(sys.argv))
|
|
except KeyboardInterrupt:
|
|
sys.stderr.write('interrupted\n')
|
|
sys.exit(1)
|