Index: pylib/gyp/generator/analyzer.py |
=================================================================== |
--- pylib/gyp/generator/analyzer.py (revision 1950) |
+++ pylib/gyp/generator/analyzer.py (working copy) |
@@ -32,14 +32,13 @@ |
'CONFIGURATION_NAME']: |
generator_default_variables[unused] = '' |
-def __MakeRelativeTargetName(path): |
+def __MakeRelativeTargetName(path, toplevel_dir): |
"""Converts a gyp target name into a relative name. For example, the path to a |
gyp file may be something like c:\foo\bar.gyp:target, this converts it to |
bar.gyp. |
""" |
- prune_path = os.getcwd() |
- if path.startswith(prune_path): |
- path = path[len(prune_path):] |
+ if path.startswith(toplevel_dir): |
Mark Mentovai
2014/07/14 18:10:55
This should be
if path == toplevel_dir or path.s
|
+ path = path[len(toplevel_dir):] |
if len(path) and path.startswith(os.sep): |
path = path[len(os.sep):] |
# Gyp paths are always posix style. |
@@ -128,9 +127,9 @@ |
self.sources = [] |
self.deps = [] |
-def __GenerateTargets(target_list, target_dicts): |
+def __GenerateTargets(target_list, target_dicts, toplevel_dir): |
"""Generates a dictionary with the key the name of a target and the value a |
- Target.""" |
+ Target. |toplevel_dir| is the root of the source tree.""" |
targets = {} |
# Queue of targets to visit. |
@@ -140,7 +139,8 @@ |
absolute_target_name = targets_to_visit.pop() |
# |absolute_target| may be an absolute path and may include #target. |
# References to targets are relative, so we need to clean the name. |
- relative_target_name = __MakeRelativeTargetName(absolute_target_name) |
+ relative_target_name = __MakeRelativeTargetName(absolute_target_name, |
+ toplevel_dir) |
if relative_target_name in targets: |
continue |
@@ -150,7 +150,8 @@ |
target_dicts[absolute_target_name])) |
for dep in target_dicts[absolute_target_name].get('dependencies', []): |
- targets[relative_target_name].deps.append(__MakeRelativeTargetName(dep)) |
+ targets[relative_target_name].deps.append( |
+ __MakeRelativeTargetName(dep, toplevel_dir)) |
targets_to_visit.append(dep) |
return targets |
@@ -204,7 +205,8 @@ |
print 'Must specify files to analyze via file_path generator flag' |
return |
- targets = __GenerateTargets(target_list, target_dicts) |
+ targets = __GenerateTargets(target_list, target_dicts, |
+ os.path.abspath(params['options'].toplevel_dir)) |
files_set = frozenset(files) |
found_in_all_sources = 0 |