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

Unified Diff: tools/gn/analyzer.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/analyzer_unittest.cc » ('j') | tools/gn/scope.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/analyzer.cc
diff --git a/tools/gn/analyzer.cc b/tools/gn/analyzer.cc
index aa0eca4d1c1c882fe8ede2bb00b81ef7cf8ebce9..7ed6871a2b6e3926156c458a89ae7d6063285dc7 100644
--- a/tools/gn/analyzer.cc
+++ b/tools/gn/analyzer.cc
@@ -56,12 +56,9 @@ LabelSet LabelsFor(const TargetSet& targets) {
return labels;
}
-bool AnyBuildFilesWereModified(const SourceFileSet& source_files) {
+bool DotGNFileWasModified(const SourceFileSet& source_files) {
for (auto* file : source_files) {
- if (base::EndsWith(file->value(), ".gn", base::CompareCase::SENSITIVE) ||
- base::EndsWith(file->value(), ".gni", base::CompareCase::SENSITIVE) ||
- base::EndsWith(file->value(), "build/vs_toolchain.py",
- base::CompareCase::SENSITIVE))
+ if (file->value() == "//.gn")
return true;
}
return false;
@@ -262,12 +259,7 @@ std::string Analyzer::Analyze(const std::string& input, Err* err) const {
return OutputsToJSON(outputs, default_toolchain_, err);
}
- // TODO(crbug.com/555273): We can do smarter things when we detect changes
- // to build files. For example, if all of the ninja files are unchanged,
- // we know that we can ignore changes to .gn* files. Also, for most .gn
- // files, we can treat a change as simply affecting every target, config,
- // or toolchain defined in that file.
- if (AnyBuildFilesWereModified(inputs.source_files)) {
+ if (DotGNFileWasModified(inputs.source_files)) {
outputs.status = "Found dependency (all)";
if (inputs.compile_included_all) {
outputs.compile_includes_all = true;
@@ -360,6 +352,10 @@ void Analyzer::FilterTarget(const Target* target,
bool Analyzer::TargetRefersToFile(const Target* target,
const SourceFile* file) const {
+ const auto& source_files_hashes = target->source_files_hashes();
+ if (source_files_hashes.find(base::Hash(file->value())) !=
+ source_files_hashes.end())
+ return true;
for (const auto& cur_file : target->sources()) {
if (cur_file == *file)
return true;
« no previous file with comments | « no previous file | tools/gn/analyzer_unittest.cc » ('j') | tools/gn/scope.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698