Commit Graph

13 Commits (774f09ba90045039af1ec9ae019f6a589879c1ab)

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
Lowell Manners 4d2d5b4bbe Fix unhelpful error when gn.py run in wrong directory.
Before this change, when running gn.py outside of
the checkout, the error was:
AttributeError: 'NoneType' object has no attribute 'endswith'

R=scottmg@chromium.org
Bug: gn:14

Change-Id: I4f2f83b2a861bd6f9436c16c2c422fe18fab8f2a
Reviewed-on: https://chromium-review.googlesource.com/c/1299023
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Lowell Manners <lowell@google.com>
6 years ago
Sergiy Byelozyorov 01489553a0 Prune VirtualEnv's python from environment before running GN
This is neccessary to ensure that generated ninja commands invoke python from
PATH instead of the one from VPython's VirtualEnv. On LUCI builders that replace
system python with VPython using vpython:native-python-wrapper swarming tag, a
new VPython VirtualEnv bubble will be created for each script and contain that
script's individual dependencies.

Based on https://cs.chromium.org/chromium/infra/recipes-py/recipes.py?l=88&rcl=66d9d8c66f10ca37dffa4b6d374c3d802a061b01.

R=iannucci@chromium.org

Bug: 793687
Change-Id: I633d2e0dfeda0097072daba102fb013656aaafa2
Reviewed-on: https://chromium-review.googlesource.com/1120817
Commit-Queue: Sergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
7 years ago
Scott Graham a991ac69eb gn: Look in src for gn binaries before trying old buildtools location
Bug: 855791
Change-Id: I964df1a781da4335e9b77192faf7913d3546de13
Reviewed-on: https://chromium-review.googlesource.com/1112817
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
7 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
scottmg@chromium.org d05ab35296 Add canned presubmit check for GN formatting
Requires https://codereview.chromium.org/779883002/ to be landed/rolled before it's useful.

R=dpranke@chromium.org
BUG=348474

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@293269 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
kjellander@chromium.org f7facfab38 Make gn.py support root directories other than 'src'.
In https://codereview.chromium.org/341533006/ a change
was made so that gn.py is not looking for the .gn file
to identify the root of the checkout. This breaks
GN functionality for projects that uses gclient but
have a top directory named something else than 'src'.

This change adds support for arbitrarily named primary (the first)
solutions in the .gclient file.
It also adds a check for the generated GN path so a friendly
error message can be printed if the GN executable cannot be found.


BUG=389883
TESTED=Various cases of Chromium, WebRTC and custom checkouts
with .gclient containing empty solution list, solution missing the
'name' key and so on.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@291819 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
brettw@chromium.org cc968feb9a Make gn wrapper use the one in buildtools rather than tools/gn/bin.
This updates some infrastructure to make it easy to get at the platform-specific build tools directories.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@279132 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
dpranke@chromium.org a2a0c576ef Fix the gn wrapper to be aware of the --root argument.
The gn binary itself is capable of being run from outside of a
checkout as long as you pass the --root flag.

However, the gn.py wrapper script needs to *also* know where the the
checkout is, in order to figure out how to find the gn binary itself.

This patch changes the wrapper to be aware of the --root arg :).

R=brettw@chromium.org
BUG=

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@259998 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
brettw@chromium.org 7d6ffa55da Detect cygwin as Win32 for the purposes of running GN and downloading from google storage.
This normalizes sys.platform so people running cygwin are treated like Windows.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@238999 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
brettw@chromium.org 67bb861400 Add a wrapper script for GN to depot_tools
This automatically searches the path for a source root (or takes one from the
command line), and then executes the current platform's GN binary inside that
source tree.

This will allow the user to have a "gn" command on their path, and allow our
scripts to run GN without having to bake-in the logic for finding the correct
platform's GN binary.

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

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