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

Side by Side Diff: tools/gn/template.cc

Issue 269723006: Add get_target_outputs function to GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/target_generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/template.h" 5 #include "tools/gn/template.h"
6 6
7 #include "tools/gn/err.h" 7 #include "tools/gn/err.h"
8 #include "tools/gn/functions.h" 8 #include "tools/gn/functions.h"
9 #include "tools/gn/parse_tree.h" 9 #include "tools/gn/parse_tree.h"
10 #include "tools/gn/scope.h" 10 #include "tools/gn/scope.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // template (which ScopePerFileProvider uses to base the target-related 55 // template (which ScopePerFileProvider uses to base the target-related
56 // variables target_gen_dir and target_out_dir on) to be that of the invoker. 56 // variables target_gen_dir and target_out_dir on) to be that of the invoker.
57 // This way, files don't have to be rebased and target_*_dir works the way 57 // This way, files don't have to be rebased and target_*_dir works the way
58 // people expect (otherwise its to easy to be putting generated files in the 58 // people expect (otherwise its to easy to be putting generated files in the
59 // gen dir corresponding to an imported file). 59 // gen dir corresponding to an imported file).
60 Scope template_scope(closure_.get()); 60 Scope template_scope(closure_.get());
61 template_scope.set_source_dir(scope->GetSourceDir()); 61 template_scope.set_source_dir(scope->GetSourceDir());
62 62
63 ScopePerFileProvider per_file_provider(&template_scope, true); 63 ScopePerFileProvider per_file_provider(&template_scope, true);
64 64
65 // Targets defined in the template go in the collector for the invoking file.
66 template_scope.set_item_collector(scope->GetItemCollector());
67
65 // We jump through some hoops to avoid copying the invocation scope when 68 // We jump through some hoops to avoid copying the invocation scope when
66 // setting it in the template scope (since the invocation scope may have 69 // setting it in the template scope (since the invocation scope may have
67 // large lists of source files in it and could be expensive to copy). 70 // large lists of source files in it and could be expensive to copy).
68 // 71 //
69 // Scope.SetValue will copy the value which will in turn copy the scope, but 72 // Scope.SetValue will copy the value which will in turn copy the scope, but
70 // if we instead create a value and then set the scope on it, the copy can 73 // if we instead create a value and then set the scope on it, the copy can
71 // be avoided. 74 // be avoided.
72 const char kInvoker[] = "invoker"; 75 const char kInvoker[] = "invoker";
73 template_scope.SetValue(kInvoker, Value(NULL, scoped_ptr<Scope>()), 76 template_scope.SetValue(kInvoker, Value(NULL, scoped_ptr<Scope>()),
74 invocation); 77 invocation);
(...skipping 29 matching lines...) Expand all
104 // Check for unused variables in the template itself. 107 // Check for unused variables in the template itself.
105 if (!template_scope.CheckForUnusedVars(err)) 108 if (!template_scope.CheckForUnusedVars(err))
106 return Value(); 109 return Value();
107 110
108 return result; 111 return result;
109 } 112 }
110 113
111 LocationRange Template::GetDefinitionRange() const { 114 LocationRange Template::GetDefinitionRange() const {
112 return definition_->GetRange(); 115 return definition_->GetRange();
113 } 116 }
OLDNEW
« no previous file with comments | « tools/gn/target_generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698