Chromium Code Reviews| Index: pylib/gyp/generator/ninja.py |
| =================================================================== |
| --- pylib/gyp/generator/ninja.py (revision 1973) |
| +++ pylib/gyp/generator/ninja.py (working copy) |
| @@ -1695,6 +1695,16 @@ |
| pool='link_pool') |
| +class VisitedTarget: |
| + """Used to track the set of qualified targets with the same short name as |
| + well as if the target is empty.""" |
| + def __init__(self): |
| + # True if the only targets with this name are empty (not interesting). |
| + self.has_empty_target = True |
| + # List of qualified targets with the same name. |
| + self.qualified_targets = [] |
| + |
| + |
| def GenerateOutputForConfig(target_list, target_dicts, data, params, |
| config_name): |
| options = params['options'] |
| @@ -2150,9 +2160,8 @@ |
| # objects. |
| target_short_names = {} |
| - # short name of targets that were skipped because they didn't contain anything |
| - # interesting. |
| - empty_target_names = [] |
| + # Maps from short name to a VisitedTarget. |
| + name_to_visited = {} |
| for qualified_target in target_list: |
| # qualified_target is like: third_party/icu/icu.gyp:icui18n#target |
| @@ -2197,9 +2206,14 @@ |
| target_outputs[qualified_target] = target |
| if qualified_target in all_targets: |
| all_outputs.add(target.FinalOutput()) |
| - else: |
| - empty_target_names.append(name) |
| + if name not in name_to_visited: |
| + name_to_visited[name] = VisitedTarget() |
| + name_to_visited[name].has_empty_target = (target == None) |
|
Nico
2014/09/08 21:29:02
nit: `target is None`
|
| + elif target != None: |
|
Nico
2014/09/08 21:29:02
nit: `target is not None`
|
| + name_to_visited[name].has_empty_target = False |
| + name_to_visited[name].qualified_targets.append(qualified_target) |
| + |
| if target_short_names: |
| # Write a short name to build this target. This benefits both the |
| # "build chrome" case as well as the gyp tests, which expect to be |
| @@ -2210,10 +2224,12 @@ |
| master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in |
| target_short_names[short_name]]) |
| + # Write phony targets for any empty targets that weren't written yet. As |
| + # short names are not necessarily unique only do this for short names that |
| + # haven't already been output for another target. |
| + empty_target_names = [x for x in name_to_visited |
| + if name_to_visited[x].has_empty_target] |
| if empty_target_names: |
| - # Write out any targets that were skipped because they didn't contain |
| - # anything interesting. This way the targets can still be built without |
| - # causing build errors. |
| master_ninja.newline() |
| master_ninja.comment('Empty targets (output for completeness).') |
| for name in sorted(empty_target_names): |
| @@ -2226,7 +2242,13 @@ |
| master_ninja_file.close() |
| + for short_name in \ |
| + [x for x in name_to_visited |
| + if len(name_to_visited[x].qualified_targets) > 1]: |
| + print 'WARNING: %s is defined in multiple places: %s' % \ |
| + (short_name, name_to_visited[short_name].qualified_targets) |
|
Nico
2014/09/08 21:29:02
That just moves the warning from build time to gyp
sky
2014/09/08 21:50:21
Done.
|
| + |
| def PerformBuild(data, configurations, params): |
| options = params['options'] |
| for config in configurations: |