Commit Graph

16 Commits (main)

Author SHA1 Message Date
Josip Sokcevic 9428cf648b [clang_format] Update clang path
Bug: 336843583
Change-Id: I1ace05b40420894797e68f6beaaea2360a297ba6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5586436
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
9 months ago
Stephanie Kim 8d3ab2eeb6 [depot_tools] Update clang_format.py with new path
Look for both new and old paths when checking the buildtools/ dir.

Currently, there's different binaries for mac x64 and mac arm64.
Depending on the host cpu, only one is downloaded to buildtools/mac,
meaning that there is an overlap in buildtools/mac.
When we migrate to clang-format, buildtools/mac will be for mac x64
and buildtools/mac_arm64 will be for mac arm64.
- Verified locally on my macbook that the mac_arm64 path correctly
gets chosen.

Migration CL: https://chromium-review.googlesource.com/c/chromium/src/+/5484590

Bug: b/336843583,
Change-Id: I26f80dff0e39b7ae31ed5d0a1d8e436eb19fbb3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5484138
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Stephanie Kim <kimstephanie@google.com>
10 months ago
Gavin Mak f936d540e1 Remove __future__ imports
All __future__ imports (unicode_literals, print_function) are already
mandatory in py3. Also remove an outdated py2 comment in
presubmit_canned_checks.py

Bug: 1475402
Change-Id: I27cf6a8268f6dd1081f22af782c4c29a975376ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4867135
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
1 year ago
Mike Frysinger 124bb8e53c switch to 4 space indent
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>
2 years ago
Primiano Tucci a964ca1296 clang-format: lookup for binary under third_party/clang-format
This change looks for clang-format (and its script) *also*
inside third_party/clang-format (on top of buildtools/$plat).
This is to bring consistency to the recent changes [1] to
gn and ninja wrappers, which now look only in third_party
and not in buildtools/.
This is to make it so that a project can use depot_tools
without requiring both buildtools/ and third_party/
directories.

[1] See https://crrev.com/c/3925341

Bug: b/261398524
Bug: 1340825
Change-Id: I895d244592eed259ab8efa050cc87372d891246c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4079069
Commit-Queue: Primiano Tucci <primiano@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Junji Watanabe <jwata@google.com>
2 years ago
Josip Sokcevic 3912091152 Use py3 for remaining tools in depot_tools path
R=apolito@google.com, dpranke@google.com

Bug: 1199102
Change-Id: I06ff344ac91464eb558e92598c87e43ecfa830dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2994488
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Anthony Polito <apolito@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Raul Tambre 80ee78e7fa Convert print statements to Python 3 style
Ran "2to3 -w -n -f print ./" and manually added imports.
Ran "^\s*print " and "\s+print " to find batch/shell scripts, comments and the like with embedded code, and updated them manually.
Also manually added imports to files, which used print as a function, but were missing the import.

The scripts still work with Python 2.
There are no intended behaviour changes.

Bug: 942522
Change-Id: Id777e4d4df4adcdfdab1b18bde89f235ef491b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1595684
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
6 years ago
Nico Weber 09e0b38f0f Move gclient path access to separate module.
gclient_utils.py is a kitchen sink and is for that reason expensive
to import. Move the comparatively cheap and simple path routines
to a new gclient_paths module and use that in gn.py, clang_format.py,
dart_format.py.

(To be able to move FindGclientRoot() to gclient_paths.py,
make it use io.open() instead of FileRead(). FileRead() tries
to paper over invalid utf-8, but that was added for presubmits,
not for .gclient files, so this is hopefully fine.)

Cuts gn.py overhead in half (on my Windows laptop from 0.6s to 0.25s,
still high; on my Mac laptop from 0.1s to 0.05s), and probably helps
the other two too.

Completely remove PathDifference() since it's unused.

Bug: 939959
Change-Id: I6a70f6e4c16062b622fb2df8778e8a598d4cc956
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1512058
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
6 years ago
Sam Clegg 54985b6b96 Improve clang-format error messages when run outside of chromium checkout
Its useful to be able to run clang-format on projects
outside of chromium. This change informs developers
how they can do that.

Change-Id: I01ef755aa6e5b53a0a5bb6377e92b2ffdfd17eff
Reviewed-on: https://chromium-review.googlesource.com/414204
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Sam Clegg <sbc@chromium.org>
8 years ago
tfarina@chromium.org c432a7f7b3 Fix the argument passed to main() in clang_format.py
Passing arg[1] rather than argv[1:] is causing the following with
Python 2.7.3.

Traceback (most recent call last):
File "/home/tfarina/depot_tools/clang_format.py", line 70, in
<module>
sys.exit(main(sys.argv[1]))
File "/home/tfarina/depot_tools/clang_format.py", line 65,
in main
return subprocess.call([tool] + args)
TypeError: can only concatenate list (not "str") to list
No output from clang-format (crashed?).
Please report to bugs.llvm.org.

This started to happening after
http://src.chromium.org/viewvc/chrome?view=rev&revision=294250

BUG=None
TEST=try to format a c++ file using clang-format
TBR=sbc@chromium.org,maruel@chromium.org

Review URL: https://codereview.chromium.org/972453002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294267 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
sbc@chromium.org 013731e832 Handle KeyboardInterrupt consistently in python scripts
Handle KeyboardInterrupt gracefully rather the printing a
backtrace. Most users of these tools don't expect a
backtrace when then hit Ctrl-C.

Also, fix a few other inconsistencies found in the python
startup code of these different scripts:
- always call main function 'main' (rather than 'Main')
- always return 0 from main function
- if main takes args never include argv[0]

Review URL: https://codereview.chromium.org/955993006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294250 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
jochen@chromium.org aaee92f1ec Change clang_format.py to search for clang-format in buildtools
BUG=none
R=brettw@chromium.org,nick@chromium.org

Review URL: https://codereview.chromium.org/356733002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@280971 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
nick@chromium.org 8ca1aa3cd5 clang-format: Allow .proto files to be formatted (supported by an upcoming binary/script; this change is safe if you are running an older binary); remove warnings.
BUG=344916

Review URL: https://codereview.chromium.org/177213013

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@253295 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
ajm@chromium.org 098122337f Search for the source root rather than checkout root in clang_format.py.
Use the source root (src/ in Chromium) rather than the checkout root as
the path from which to locate the clang-format binaries.

webrtc uses the Chromium build/tools infrastructure but doesn't have
src/ as a source root path. This change allows us to continue to use
'git cl format' in a standalone webrtc checkout (which would be nice.)

BUG=240309
TESTED='git cl format' works on a trivial test change in both a
Chromium and webrtc checkout.

Review URL: https://codereview.chromium.org/135653014

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@248651 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
thakis@chromium.org 6813daf45e Let depot_tools use scripts from deps-pulled "script" folder.
BUG=240309
TBR=iannucci@chromium.org

Review URL: https://codereview.chromium.org/139693006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@248420 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
nick@chromium.org 3ac1c4e320 Depot tools: use the clang-format binaries that are now included
as part of the Chromium checkout.

This follows the approach used by gn.

Changes include:
 - in-the-PATH clang-format trampoline scripts
 - clang_format.py, which finds clang-format binaries inside of Chrome
 - Hook 'git cl format' to the new binaries and scripts
 - Rearrange some code, for reuse between clang_format.py and gn.py

BUG=240309
TEST=presubmits (one failure on mac, but it fails on a clean checkout too)

Review URL: https://codereview.chromium.org/134313007

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@245074 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago