Commit Graph

10 Commits (721a721d0875f08a4634f54923b6ea7b32514d25)

Author SHA1 Message Date
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