mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
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>
This commit is contained in:
10
gn.py
10
gn.py
@@ -12,7 +12,7 @@ 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)."""
|
||||
|
||||
import gclient_utils
|
||||
import gclient_paths
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -45,22 +45,22 @@ def main(args):
|
||||
|
||||
# Try in primary solution location first, with the gn binary having been
|
||||
# downloaded by cipd in the projects DEPS.
|
||||
primary_solution_path = gclient_utils.GetPrimarySolutionPath()
|
||||
primary_solution_path = gclient_paths.GetPrimarySolutionPath()
|
||||
if primary_solution_path:
|
||||
gn_path = os.path.join(primary_solution_path, 'third_party',
|
||||
'gn', 'gn' + gclient_utils.GetExeSuffix())
|
||||
'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_utils.GetBuildtoolsPlatformBinaryPath()
|
||||
bin_path = gclient_paths.GetBuildtoolsPlatformBinaryPath()
|
||||
if not bin_path:
|
||||
print >> sys.stderr, ('gn.py: Could not find checkout in any parent of '
|
||||
'the current path.\nThis must be run inside a '
|
||||
'checkout.')
|
||||
return 1
|
||||
gn_path = os.path.join(bin_path, 'gn' + gclient_utils.GetExeSuffix())
|
||||
gn_path = os.path.join(bin_path, 'gn' + gclient_paths.GetExeSuffix())
|
||||
if not os.path.exists(gn_path):
|
||||
print >> sys.stderr, 'gn.py: Could not find gn executable at: %s' % gn_path
|
||||
return 2
|
||||
|
||||
Reference in New Issue
Block a user