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

Unified Diff: pylib/gyp/input.py

Issue 24803004: Add an option to prune unwanted targets (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: incorporate review comments Created 7 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 | « pylib/gyp/common.py ('k') | test/prune_targets/gyptest-prune-targets.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/input.py
diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py
index 8abfa3d999e3ed71dae961824292fcd702787058..b151d247d7040cc1c5c6b0b6d965c6a60fe25b36 100644
--- a/pylib/gyp/input.py
+++ b/pylib/gyp/input.py
@@ -2562,6 +2562,26 @@ def TurnIntIntoStrInList(the_list):
TurnIntIntoStrInList(item)
+def PruneUnwantedTargets(targets, flat_list, dependency_nodes, root_targets):
+ """Return only the targets that are deep dependencies of |root_targets|."""
+ qualified_root_targets = []
+ for target in root_targets:
+ target = target.strip()
+ qualified_targets = gyp.common.FindQualifiedTargets(target, flat_list)
+ if not qualified_targets:
+ raise GypError("Could not find target %s" % target)
+ qualified_root_targets.extend(qualified_targets)
+
+ wanted_targets = {}
+ for target in qualified_root_targets:
+ 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 +2610,7 @@ def VerifyNoCollidingTargets(targets):
def Load(build_files, variables, includes, depth, generator_input_info, check,
- circular_check, parallel):
+ circular_check, parallel, root_targets):
# Set up path_sections and non_configuration_keys with the default data plus
# the generator-specifc data.
global path_sections
@@ -2678,6 +2698,12 @@ def Load(build_files, variables, includes, depth, generator_input_info, check,
[dependency_nodes, flat_list] = BuildDependencyList(targets)
+ if root_targets:
+ # Remove, from |targets| and |flat_list|, the targets that are not deep
+ # dependencies of the targets specified in |root_targets|.
+ targets, flat_list = PruneUnwantedTargets(
+ targets, flat_list, dependency_nodes, root_targets)
+
# Check that no two targets in the same directory have the same name.
VerifyNoCollidingTargets(flat_list)
« no previous file with comments | « pylib/gyp/common.py ('k') | test/prune_targets/gyptest-prune-targets.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698