Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Unified Diff: gn.py

Issue 134313007: Depot tools: use the clang-format binaries that are now included (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fixed gclient_utils_test.py Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_cl.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gn.py
diff --git a/gn.py b/gn.py
old mode 100644
new mode 100755
index 23521e3abb757aa12e824cf45f3422929fe04e10..067f42e0f1ce62ab43eb5ed3fc55a7747d4e0689
--- a/gn.py
+++ b/gn.py
@@ -12,55 +12,27 @@ 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 os
import subprocess
import sys
-class PlatformUnknownError(IOError):
- pass
-
-
-def HasDotfile(path):
- """Returns True if the given path has a .gn file in it."""
- return os.path.exists(path + '/.gn')
-
-
-def FindSourceRootOnPath():
- """Searches upward from the current directory for the root of the source
- tree and returns the found path. Returns None if no source root could
- be found."""
- cur = os.getcwd()
- while True:
- if HasDotfile(cur):
- return cur
- up_one = os.path.dirname(cur)
- if up_one == cur:
- return None # Reached the top of the directory tree
- cur = up_one
-
-
def RunGN(sourceroot):
# The binaries in platform-specific subdirectories in src/tools/gn/bin.
- gnpath = sourceroot + '/tools/gn/bin/'
- if sys.platform in ('cygwin', 'win32'):
- gnpath += 'win/gn.exe'
- elif sys.platform.startswith('linux'):
- gnpath += 'linux/gn'
- elif sys.platform == 'darwin':
- gnpath += 'mac/gn'
- else:
- raise PlatformUnknownError('Unknown platform for GN: ' + sys.platform)
-
+ gnpath = os.path.join(sourceroot,
+ 'tools', 'gn', 'bin', gclient_utils.GetMacWinOrLinux(),
+ 'gn' + gclient_utils.GetExeSuffix())
return subprocess.call([gnpath] + sys.argv[1:])
def main(args):
- sourceroot = FindSourceRootOnPath()
+ sourceroot = gclient_utils.FindFileUpwards('.gn')
if not sourceroot:
print >> sys.stderr, '.gn file not found in any parent of the current path.'
sys.exit(1)
return RunGN(sourceroot)
+
if __name__ == '__main__':
sys.exit(main(sys.argv))
« no previous file with comments | « git_cl.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698