Index: tools/gn/template.cc |
diff --git a/tools/gn/template.cc b/tools/gn/template.cc |
index bf4eb6187804c08f4e2586ba9d9046151cc04aad..11dcf1ff199b3d2ad4bb8dd224ba08a70749c23b 100644 |
--- a/tools/gn/template.cc |
+++ b/tools/gn/template.cc |
@@ -62,6 +62,9 @@ Value Template::Invoke(Scope* scope, |
ScopePerFileProvider per_file_provider(&template_scope, true); |
+ // Targets defined in the template go in the collector for the invoking file. |
+ template_scope.set_item_collector(scope->GetItemCollector()); |
+ |
// We jump through some hoops to avoid copying the invocation scope when |
// setting it in the template scope (since the invocation scope may have |
// large lists of source files in it and could be expensive to copy). |