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

Unified Diff: gclient_utils.py

Issue 538393002: Make gn.py support root directories other than 'src'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Improved readability and returning non-zero exit code on failure to find gn Created 6 years, 3 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 | « no previous file | gn.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index e8d916e78d5d2a8aeba4cbf61bebf7b64ad79084..a21e65a5fc31c5d01af67dc395f1ea65fabea86d 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -681,7 +681,10 @@ def GetBuildtoolsPath():
if os.path.exists(os.path.join(top_dir, 'buildtools')):
return os.path.join(top_dir, 'buildtools')
return None
- return os.path.join(gclient_root, 'src', 'buildtools')
+
+ # Some projects' top directory is not named 'src'.
+ source_dir_name = GetGClientPrimarySolutionName(gclient_root) or 'src'
+ return os.path.join(gclient_root, source_dir_name, 'buildtools')
def GetBuildtoolsPlatformBinaryPath():
@@ -713,6 +716,17 @@ def GetExeSuffix():
return ''
+def GetGClientPrimarySolutionName(gclient_root_dir_path):
+ """Returns the name of the primary solution in the .gclient file specified."""
+ gclient_config_file = os.path.join(gclient_root_dir_path, '.gclient')
+ env = {}
+ execfile(gclient_config_file, env)
+ solutions = env.get('solutions', [])
+ if solutions:
+ return solutions[0].get('name')
+ return None
+
+
def GetGClientRootAndEntries(path=None):
"""Returns the gclient root and the dict of entries."""
config_file = '.gclient_entries'
« no previous file with comments | « no previous file | gn.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698