Index: tools/gn/target.cc |
diff --git a/tools/gn/target.cc b/tools/gn/target.cc |
index 2386870c5788f4813d635f24450d8e453eab26c4..005dd973b2961cb4f445a1a61bb302a85df03b71 100644 |
--- a/tools/gn/target.cc |
+++ b/tools/gn/target.cc |
@@ -83,6 +83,7 @@ bool EnsureFileIsGeneratedByDependency(const Target* target, |
const OutputFile& file, |
bool check_private_deps, |
bool consider_object_files, |
+ bool check_data_deps, |
std::set<const Target*>* seen_targets) { |
if (seen_targets->find(target) != seen_targets->end()) |
return false; // Already checked this one and it's not found. |
@@ -96,6 +97,9 @@ bool EnsureFileIsGeneratedByDependency(const Target* target, |
return true; |
} |
+ if (file == target->write_runtime_deps_output()) |
+ return true; |
+ |
// Check binary target intermediate files if requested. |
if (consider_object_files && target->IsBinary()) { |
std::vector<OutputFile> source_outputs; |
@@ -109,11 +113,22 @@ bool EnsureFileIsGeneratedByDependency(const Target* target, |
} |
} |
+ if (check_data_deps) { |
+ check_data_deps = false; // Consider only direct data_deps. |
+ for (const auto& pair : target->data_deps()) { |
+ if (EnsureFileIsGeneratedByDependency(pair.ptr, file, false, |
+ consider_object_files, |
+ check_data_deps, seen_targets)) |
+ return true; // Found a path. |
+ } |
+ } |
+ |
// Check all public dependencies (don't do data ones since those are |
// runtime-only). |
for (const auto& pair : target->public_deps()) { |
if (EnsureFileIsGeneratedByDependency(pair.ptr, file, false, |
- consider_object_files, seen_targets)) |
+ consider_object_files, |
+ check_data_deps, seen_targets)) |
return true; // Found a path. |
} |
@@ -122,14 +137,14 @@ bool EnsureFileIsGeneratedByDependency(const Target* target, |
for (const auto& pair : target->private_deps()) { |
if (EnsureFileIsGeneratedByDependency(pair.ptr, file, false, |
consider_object_files, |
- seen_targets)) |
+ check_data_deps, seen_targets)) |
return true; // Found a path. |
} |
if (target->output_type() == Target::CREATE_BUNDLE) { |
for (const auto& dep : target->bundle_data().bundle_deps()) { |
if (EnsureFileIsGeneratedByDependency(dep, file, false, |
consider_object_files, |
- seen_targets)) |
+ check_data_deps, seen_targets)) |
return true; // Found a path. |
} |
} |
@@ -752,13 +767,20 @@ void Target::CheckSourceGenerated(const SourceFile& source) const { |
// can be filtered out of this list. |
OutputFile out_file(settings()->build_settings(), source); |
std::set<const Target*> seen_targets; |
- if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, |
+ bool check_data_deps = false; |
+ bool consider_object_files = false; |
+ if (!EnsureFileIsGeneratedByDependency(this, out_file, true, |
+ consider_object_files, check_data_deps, |
&seen_targets)) { |
+ seen_targets.clear(); |
+ // Allow dependency to be through data_deps for files generated by gn. |
+ check_data_deps = g_scheduler->IsFileGeneratedByWriteRuntimeDeps(out_file); |
// Check object files (much slower and very rare) only if the "normal" |
// output check failed. |
- seen_targets.clear(); |
- if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, |
- &seen_targets)) |
+ consider_object_files = !check_data_deps; |
+ if (!EnsureFileIsGeneratedByDependency(this, out_file, true, |
+ consider_object_files, |
+ check_data_deps, &seen_targets)) |
g_scheduler->AddUnknownGeneratedInput(this, source); |
} |
} |