Chromium Code Reviews| Index: pylib/gyp/input.py |
| diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py |
| index 8abfa3d999e3ed71dae961824292fcd702787058..71535294e989bfa265eaba9767e0faeb350628ca 100644 |
| --- a/pylib/gyp/input.py |
| +++ b/pylib/gyp/input.py |
| @@ -2562,6 +2562,22 @@ def TurnIntIntoStrInList(the_list): |
| TurnIntIntoStrInList(item) |
| +def PruneUnwantedTargets(targets, flat_list, dependency_nodes, build_files): |
| + """ |
| + Return only the targets that are deep dependencies of the targets specified |
| + in |build_files|. |
| + """ |
| + wanted_targets = {} |
| + for target in flat_list: |
| + if gyp.common.BuildFile(target) in build_files: |
| + wanted_targets[target] = targets[target] |
| + for dependency in dependency_nodes[target].DeepDependencies(): |
| + wanted_targets[dependency] = targets[dependency] |
| + |
| + wanted_flat_list = [t for t in flat_list if t in wanted_targets] |
| + return [wanted_targets, wanted_flat_list] |
| + |
| + |
| def VerifyNoCollidingTargets(targets): |
| """Verify that no two targets in the same directory share the same name. |
| @@ -2590,7 +2606,7 @@ def VerifyNoCollidingTargets(targets): |
| def Load(build_files, variables, includes, depth, generator_input_info, check, |
| - circular_check, parallel): |
| + circular_check, parallel, prune_targets): |
| # Set up path_sections and non_configuration_keys with the default data plus |
| # the generator-specifc data. |
| global path_sections |
| @@ -2617,6 +2633,10 @@ def Load(build_files, variables, includes, depth, generator_input_info, check, |
| # for rules. |
| extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] |
| + # Normalize paths everywhere. This is important because paths will be |
|
scottmg
2013/09/26 22:11:07
Why did this need to move?
|
| + # used as keys to the data dict and for references between input files. |
| + build_files = [os.path.normpath(i) for i in build_files] |
| + |
| # Load build files. This loads every target-containing build file into |
| # the |data| dictionary such that the keys to |data| are build file names, |
| # and the values are the entire build file contents after "early" or "pre" |
| @@ -2627,9 +2647,6 @@ def Load(build_files, variables, includes, depth, generator_input_info, check, |
| data = {'target_build_files': set()} |
| aux_data = {} |
| for build_file in build_files: |
| - # Normalize paths everywhere. This is important because paths will be |
| - # used as keys to the data dict and for references between input files. |
| - build_file = os.path.normpath(build_file) |
| try: |
| if parallel: |
| LoadTargetBuildFileParallel(build_file, data, aux_data, |
| @@ -2678,6 +2695,12 @@ def Load(build_files, variables, includes, depth, generator_input_info, check, |
| [dependency_nodes, flat_list] = BuildDependencyList(targets) |
| + if prune_targets: |
| + # Remove, from |targets| and |flat_list|, the targets that are not deep |
| + # dependencies of the targets specified in |build_files|. |
| + [targets, flat_list] = PruneUnwantedTargets( |
|
scottmg
2013/09/26 22:11:07
[ ] around targets, flat_list is odd here. Just re
|
| + targets, flat_list, dependency_nodes, build_files) |
| + |
| # Check that no two targets in the same directory have the same name. |
| VerifyNoCollidingTargets(flat_list) |