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

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

Issue 226223006: Template invocation fixes in GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/import_manager.h" 5 #include "tools/gn/import_manager.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "tools/gn/parse_tree.h" 9 #include "tools/gn/parse_tree.h"
10 #include "tools/gn/scheduler.h" 10 #include "tools/gn/scheduler.h"
11 #include "tools/gn/scope_per_file_provider.h" 11 #include "tools/gn/scope_per_file_provider.h"
12 12
13 namespace { 13 namespace {
14 14
15 // Returns a newly-allocated scope on success, null on failure. 15 // Returns a newly-allocated scope on success, null on failure.
16 Scope* UncachedImport(const Settings* settings, 16 Scope* UncachedImport(const Settings* settings,
17 const SourceFile& file, 17 const SourceFile& file,
18 const ParseNode* node_for_err, 18 const ParseNode* node_for_err,
19 Err* err) { 19 Err* err) {
20 const ParseNode* node = g_scheduler->input_file_manager()->SyncLoadFile( 20 const ParseNode* node = g_scheduler->input_file_manager()->SyncLoadFile(
21 node_for_err->GetRange(), settings->build_settings(), file, err); 21 node_for_err->GetRange(), settings->build_settings(), file, err);
22 if (!node) 22 if (!node)
23 return NULL; 23 return NULL;
24 const BlockNode* block = node->AsBlock(); 24 const BlockNode* block = node->AsBlock();
25 CHECK(block); 25 CHECK(block);
26 26
27 scoped_ptr<Scope> scope(new Scope(settings->base_config())); 27 scoped_ptr<Scope> scope(new Scope(settings->base_config()));
28 ScopePerFileProvider per_file_provider(scope.get());
29 scope->set_source_dir(file.GetDir()); 28 scope->set_source_dir(file.GetDir());
29
30 // Don't allow ScopePerFileProvider to provide target-related variables.
31 // These will be relative to the imported file, which is probably not what
32 // people mean when they use these.
33 ScopePerFileProvider per_file_provider(scope.get(), false);
34
30 scope->SetProcessingImport(); 35 scope->SetProcessingImport();
31 block->ExecuteBlockInScope(scope.get(), err); 36 block->ExecuteBlockInScope(scope.get(), err);
32 if (err->has_error()) 37 if (err->has_error())
33 return NULL; 38 return NULL;
34 scope->ClearProcessingImport(); 39 scope->ClearProcessingImport();
35 40
36 return scope.release(); 41 return scope.release();
37 } 42 }
38 43
39 } // namesapce 44 } // namesapce
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 imported_scope = found->second; 82 imported_scope = found->second;
78 } else { 83 } else {
79 imports_[file] = imported_scope; 84 imports_[file] = imported_scope;
80 } 85 }
81 } 86 }
82 } 87 }
83 88
84 return imported_scope->NonRecursiveMergeTo(scope, false, node_for_err, 89 return imported_scope->NonRecursiveMergeTo(scope, false, node_for_err,
85 "import", err); 90 "import", err);
86 } 91 }
OLDNEW
« base/BUILD.gn ('K') | « build/config/BUILD.gn ('k') | tools/gn/loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698