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

Unified Diff: pylib/gyp/input.py

Issue 10399096: Check for and disallow rules the process the output of other rules (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: fix comment Created 8 years, 7 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 | « no previous file | test/chained-rules/chained-rules.gyp » ('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 568049df6c349c6dae60fcbd966e73a0c628a7ee..6bd4d172baae21cc153689401a390f10d6207c65 100644
--- a/pylib/gyp/input.py
+++ b/pylib/gyp/input.py
@@ -2190,6 +2190,15 @@ def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules):
rule_extensions = {}
rules = target_dict.get('rules', [])
+
+ # Gather the outputs for all rules with process_outputs_as_sources so we can
+ # validate that they're not chained below.
+ processed_outputs = []
+ for rule in rules:
+ if rule.get('process_outputs_as_sources', False):
+ for output in rule['outputs']:
+ processed_outputs.append((rule, output))
Evan Martin 2012/05/18 22:53:36 Why not a map of output extension => other stuff,
+
for rule in rules:
# Make sure that there's no conflict among rule names and extensions.
rule_name = rule['rule_name']
@@ -2207,6 +2216,17 @@ def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules):
rule_name)
rule_extensions[rule_extension] = rule
+ # Make sure rules aren't chained (i.e. the output of one rule with
+ # process_outputs_as_sources is the input for another rule). Some
+ # generators can't reasonably support this.
+ for other, output in processed_outputs:
+ if other == rule:
+ continue
+ if output.endswith('.' + rule_extension):
+ raise KeyError, ('target %s contains "%s" rule that would handle '
+ 'the output of other rule %s (processing %s)' %
+ (target, rule_extension, other['rule_name'], output))
+
# Make sure rule_sources isn't already there. It's going to be
# created below if needed.
if 'rule_sources' in rule:
« no previous file with comments | « no previous file | test/chained-rules/chained-rules.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698