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

Unified Diff: tools/gn/template.cc

Issue 1361263004: GN: Don't allow nested things inside template invocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« tools/gn/functions.h ('K') | « tools/gn/functions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/template.cc
diff --git a/tools/gn/template.cc b/tools/gn/template.cc
index 80d6c5cf74843772dce9c9c428248c5d33f195ba..3d58b9a7eb010df9c650f80d4815f3fc74ec18ff 100644
--- a/tools/gn/template.cc
+++ b/tools/gn/template.cc
@@ -41,9 +41,20 @@ Value Template::Invoke(Scope* scope,
invocation->function().value().as_string(),
block, args, invocation_scope.get(), err))
return Value();
- block->Execute(invocation_scope.get(), err);
- if (err->has_error())
- return Value();
+
+ {
+ // Don't allow the block of the template invocation to include other
+ // targets configs, or template invocations. This must only be applied
+ // to the invoker's block rather than the whole function because the
+ // template execution itself must be able to define targets, etc.
+ NonNestableBlock non_nestable(scope, invocation, "template invocation");
+ if (!non_nestable.Enter(err))
+ return Value();
+
+ block->Execute(invocation_scope.get(), err);
+ if (err->has_error())
+ return Value();
+ }
// Set up the scope to run the template and set the current directory for the
// template (which ScopePerFileProvider uses to base the target-related
« tools/gn/functions.h ('K') | « tools/gn/functions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698