Index: tools/gn/scope.cc |
diff --git a/tools/gn/scope.cc b/tools/gn/scope.cc |
index f2fe7521dfafc8e94f5a6c35ff2723a9ec960c9f..8158e82ccc6cef91223d9a34749733ddf39c6b67 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,30 @@ Scope::ProgrammaticProvider::~ProgrammaticProvider() { |
scope_->RemoveProvider(this); |
} |
-Scope::Scope(const Settings* settings) |
+Scope::Scope(const Settings* settings, |
+ const std::set<uint32_t>& source_files_hashes) |
: const_containing_(nullptr), |
mutable_containing_(nullptr), |
settings_(settings), |
mode_flags_(0), |
- item_collector_(nullptr) { |
-} |
+ item_collector_(nullptr), |
+ source_files_hashes_(source_files_hashes) {} |
Scope::Scope(Scope* parent) |
: const_containing_(nullptr), |
mutable_containing_(parent), |
settings_(parent->settings()), |
mode_flags_(0), |
- item_collector_(nullptr) { |
-} |
+ item_collector_(nullptr), |
+ source_files_hashes_(parent->source_files_hashes_) {} |
Scope::Scope(const Scope* parent) |
: const_containing_(parent), |
mutable_containing_(nullptr), |
settings_(parent->settings()), |
mode_flags_(0), |
- item_collector_(nullptr) { |
-} |
+ item_collector_(nullptr), |
+ source_files_hashes_(parent->source_files_hashes_) {} |
Scope::~Scope() { |
} |
@@ -339,7 +341,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_, source_files_hashes_); |
pair.second->NonRecursiveMergeTo(dest_scope.get(), options, node_for_err, |
"<SHOULDN'T HAPPEN>", err); |
} |
@@ -397,6 +399,10 @@ bool Scope::NonRecursiveMergeTo(Scope* dest, |
dest->templates_[current_name] = pair.second; |
} |
+ // Source files. |
+ dest->source_files_hashes_.insert(source_files_hashes_.begin(), |
+ source_files_hashes_.end()); |
+ |
return true; |
} |
@@ -412,7 +418,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_, source_files_hashes_)); |
} |
// Want to clobber since we've flattened some nested scopes, and our parent |
@@ -430,7 +436,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_, source_files_hashes_); |
return dest.get(); |
} |
@@ -495,6 +501,10 @@ const SourceDir& Scope::GetSourceDir() const { |
return source_dir_; |
} |
+void Scope::AddSourceFile(const SourceFile& source_file) { |
+ source_files_hashes_.insert(base::Hash(source_file.value())); |
+} |
+ |
Scope::ItemVector* Scope::GetItemCollector() { |
if (item_collector_) |
return item_collector_; |