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

Unified Diff: tools/gn/scope.cc

Issue 2940873002: Implement tracking of BUILD.gn files used to define target, toolchain or (Closed)
Patch Set: Use base::flat_set instead of std::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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/scope.cc
diff --git a/tools/gn/scope.cc b/tools/gn/scope.cc
index f2fe7521dfafc8e94f5a6c35ff2723a9ec960c9f..b5ba8d24b1688888edd5cee07e2e9af9a6d8a860 100644
--- a/tools/gn/scope.cc
+++ b/tools/gn/scope.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "tools/gn/parse_tree.h"
+#include "tools/gn/source_file.h"
#include "tools/gn/template.h"
namespace {
@@ -39,29 +40,29 @@ Scope::ProgrammaticProvider::~ProgrammaticProvider() {
scope_->RemoveProvider(this);
}
-Scope::Scope(const Settings* settings)
+Scope::Scope(const Settings* settings, const InputFileSet& input_files)
: const_containing_(nullptr),
mutable_containing_(nullptr),
settings_(settings),
mode_flags_(0),
- item_collector_(nullptr) {
-}
+ item_collector_(nullptr),
+ input_files_(input_files) {}
Scope::Scope(Scope* parent)
: const_containing_(nullptr),
mutable_containing_(parent),
settings_(parent->settings()),
mode_flags_(0),
- item_collector_(nullptr) {
-}
+ item_collector_(nullptr),
+ input_files_(parent->input_files_) {}
Scope::Scope(const Scope* parent)
: const_containing_(parent),
mutable_containing_(nullptr),
settings_(parent->settings()),
mode_flags_(0),
- item_collector_(nullptr) {
-}
+ item_collector_(nullptr),
+ input_files_(parent->input_files_) {}
Scope::~Scope() {
}
@@ -339,7 +340,7 @@ bool Scope::NonRecursiveMergeTo(Scope* dest,
}
std::unique_ptr<Scope>& dest_scope = dest->target_defaults_[current_name];
- dest_scope = base::MakeUnique<Scope>(settings_);
+ dest_scope = base::MakeUnique<Scope>(settings_, input_files_);
pair.second->NonRecursiveMergeTo(dest_scope.get(), options, node_for_err,
"<SHOULDN'T HAPPEN>", err);
}
@@ -397,6 +398,9 @@ bool Scope::NonRecursiveMergeTo(Scope* dest,
dest->templates_[current_name] = pair.second;
}
+ // Input files.
+ dest->input_files_.insert(input_files_.begin(), input_files_.end());
+
return true;
}
@@ -412,7 +416,7 @@ std::unique_ptr<Scope> Scope::MakeClosure() const {
result = mutable_containing_->MakeClosure();
} else {
// This is a standalone scope, just copy it.
- result.reset(new Scope(settings_));
+ result.reset(new Scope(settings_, input_files_));
}
// Want to clobber since we've flattened some nested scopes, and our parent
@@ -430,7 +434,7 @@ std::unique_ptr<Scope> Scope::MakeClosure() const {
Scope* Scope::MakeTargetDefaults(const std::string& target_type) {
std::unique_ptr<Scope>& dest = target_defaults_[target_type];
- dest = base::MakeUnique<Scope>(settings_);
+ dest = base::MakeUnique<Scope>(settings_, input_files_);
return dest.get();
}
@@ -495,6 +499,10 @@ const SourceDir& Scope::GetSourceDir() const {
return source_dir_;
}
+void Scope::AddInputFile(const InputFile* input_file) {
+ input_files_.insert(input_file);
+}
+
Scope::ItemVector* Scope::GetItemCollector() {
if (item_collector_)
return item_collector_;

Powered by Google App Engine
This is Rietveld 408576698