| Index: gclient_utils.py
|
| diff --git a/gclient_utils.py b/gclient_utils.py
|
| index 21c44c36a786bc5f9e6b84a3ccef0b9b2f5cc84a..e8d6f72f0549ba185a39a2b0010859dde600605c 100644
|
| --- a/gclient_utils.py
|
| +++ b/gclient_utils.py
|
| @@ -683,7 +683,8 @@ def GetPrimarySolutionPath():
|
| return None
|
|
|
| # Some projects' top directory is not named 'src'.
|
| - source_dir_name = GetGClientPrimarySolutionName(gclient_root) or 'src'
|
| + solution_dict = _GetGClientPrimarySolution(gclient_root)
|
| + source_dir_name = solution_dict.get('name', 'src')
|
| return os.path.join(gclient_root, source_dir_name)
|
|
|
|
|
| @@ -697,13 +698,22 @@ def GetBuildtoolsPath():
|
| if override is not None:
|
| return override
|
|
|
| + # Attempt to find buildtools/ by reading the DEPS file.
|
| + gclient_root = FindGclientRoot(os.getcwd())
|
| + if gclient_root:
|
| + solution_dict = _GetGClientPrimarySolution(gclient_root)
|
| + deps_dict = _ReadDepsFileForSolution(gclient_root, solution_dict) or {}
|
| + for sub_path in deps_dict.get('deps', {}):
|
| + if sub_path.endswith('/buildtools'):
|
| + return os.path.join(gclient_root, sub_path)
|
| +
|
| + # Fall-back to heuristics.
|
| primary_solution = GetPrimarySolutionPath()
|
| if not primary_solution:
|
| return None
|
| buildtools_path = os.path.join(primary_solution, 'buildtools')
|
| if not os.path.exists(buildtools_path):
|
| # Buildtools may be in the gclient root.
|
| - gclient_root = FindGclientRoot(os.getcwd())
|
| buildtools_path = os.path.join(gclient_root, 'buildtools')
|
| return buildtools_path
|
|
|
| @@ -732,15 +742,33 @@ 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')
|
| +def _ReadDepsFileForSolution(gclient_root, solution_dict):
|
| + """Reads the DEPS file for the given solution.
|
| +
|
| + This stubs out Var(), as it's not currently required.
|
| + """
|
| + env = {}
|
| + if 'name' in solution_dict:
|
| + deps_file = solution_dict.get('deps_file', 'DEPS')
|
| + deps_path = os.path.join(gclient_root, solution_dict['name'], deps_file)
|
| + global_scope = {
|
| + '__builtins__': {'None': None},
|
| + 'Var': lambda x: '',
|
| + 'deps_os': {},
|
| + }
|
| + execfile(deps_path, global_scope, env)
|
| + return env
|
| +
|
| +
|
| +def _GetGClientPrimarySolution(gclient_root):
|
| + """Returns the dict for the primary solution in the given gclient path."""
|
| + gclient_config_file = os.path.join(gclient_root, '.gclient')
|
| env = {}
|
| execfile(gclient_config_file, env)
|
| solutions = env.get('solutions', [])
|
| if solutions:
|
| - return solutions[0].get('name')
|
| - return None
|
| + return solutions[0]
|
| + return {}
|
|
|
|
|
| def GetGClientRootAndEntries(path=None):
|
|
|