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

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

Issue 2940873002: Implement tracking of BUILD.gn files used to define target, toolchain or (Closed)
Patch Set: Created 3 years, 6 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
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 "tools/gn/err.h" 7 #include "tools/gn/err.h"
8 #include "tools/gn/parse_tree.h" 8 #include "tools/gn/parse_tree.h"
9 #include "tools/gn/scheduler.h" 9 #include "tools/gn/scheduler.h"
10 #include "tools/gn/scope_per_file_provider.h" 10 #include "tools/gn/scope_per_file_provider.h"
11 #include "tools/gn/trace.h" 11 #include "tools/gn/trace.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 std::unique_ptr<Scope> UncachedImport(const Settings* settings, 16 std::unique_ptr<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 ScopedTrace load_trace(TraceItem::TRACE_IMPORT_LOAD, file.value()); 20 ScopedTrace load_trace(TraceItem::TRACE_IMPORT_LOAD, file.value());
21 21
22 const ParseNode* node = g_scheduler->input_file_manager()->SyncLoadFile( 22 const ParseNode* node = g_scheduler->input_file_manager()->SyncLoadFile(
23 node_for_err->GetRange(), settings->build_settings(), file, err); 23 node_for_err->GetRange(), settings->build_settings(), file, err);
24 if (!node) 24 if (!node)
25 return nullptr; 25 return nullptr;
26 26
27 std::unique_ptr<Scope> scope(new Scope(settings->base_config())); 27 std::unique_ptr<Scope> scope(new Scope(settings->base_config()));
28 scope->AddSourceFile(file);
28 scope->set_source_dir(file.GetDir()); 29 scope->set_source_dir(file.GetDir());
29 30
30 // Don't allow ScopePerFileProvider to provide target-related variables. 31 // Don't allow ScopePerFileProvider to provide target-related variables.
31 // These will be relative to the imported file, which is probably not what 32 // These will be relative to the imported file, which is probably not what
32 // people mean when they use these. 33 // people mean when they use these.
33 ScopePerFileProvider per_file_provider(scope.get(), false); 34 ScopePerFileProvider per_file_provider(scope.get(), false);
34 35
35 scope->SetProcessingImport(); 36 scope->SetProcessingImport();
36 node->Execute(scope.get(), err); 37 node->Execute(scope.get(), err);
37 if (err->has_error()) { 38 if (err->has_error()) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 "import", err); 132 "import", err);
132 } 133 }
133 134
134 std::vector<SourceFile> ImportManager::GetImportedFiles() const { 135 std::vector<SourceFile> ImportManager::GetImportedFiles() const {
135 std::vector<SourceFile> imported_files; 136 std::vector<SourceFile> imported_files;
136 imported_files.resize(imports_.size()); 137 imported_files.resize(imports_.size());
137 std::transform(imports_.begin(), imports_.end(), imported_files.begin(), 138 std::transform(imports_.begin(), imports_.end(), imported_files.begin(),
138 [](const ImportMap::value_type& val) { return val.first; }); 139 [](const ImportMap::value_type& val) { return val.first; });
139 return imported_files; 140 return imported_files;
140 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698