Index: tools/gn/ninja_target_writer.cc |
diff --git a/tools/gn/ninja_target_writer.cc b/tools/gn/ninja_target_writer.cc |
index 2383251c68b7ce5a3b69be67f7f92aea84f730be..df0412bcfab52174f3a35e69a8edae7064892e75 100644 |
--- a/tools/gn/ninja_target_writer.cc |
+++ b/tools/gn/ninja_target_writer.cc |
@@ -86,17 +86,19 @@ std::string NinjaTargetWriter::WriteInputDepsStampAndGetDep( |
const std::vector<const Target*>& extra_hard_deps) const { |
// For an action (where we run a script only once) the sources are the same |
// as the source prereqs. |
- bool list_sources_as_input_deps = target_->output_type() == Target::ACTION; |
+ bool list_sources_as_input_deps = (target_->output_type() == Target::ACTION); |
// Actions get implicit dependencies on the script itself. |
- bool add_script_source_as_dep = target_->output_type() == Target::ACTION || |
- target_->output_type() == Target::ACTION_FOREACH; |
+ bool add_script_source_as_dep = |
+ (target_->output_type() == Target::ACTION) || |
+ (target_->output_type() == Target::ACTION_FOREACH); |
if (!add_script_source_as_dep && |
extra_hard_deps.empty() && |
target_->inputs().empty() && |
target_->recursive_hard_deps().empty() && |
- (!list_sources_as_input_deps || target_->sources().empty())) |
+ (!list_sources_as_input_deps || target_->sources().empty()) && |
+ toolchain_->deps().empty()) |
return std::string(); // No input/hard deps. |
// One potential optimization is if there are few input dependencies (or |
@@ -145,6 +147,17 @@ std::string NinjaTargetWriter::WriteInputDepsStampAndGetDep( |
path_output_.WriteFile(out_, helper_.GetTargetOutputFile(*i)); |
} |
+ // Toolchain dependencies. These must be resolved before doing anything. |
+ // This just writs all toolchain deps for simplicity. If we find that |
+ // toolchains often have more than one dependency, we could consider writing |
+ // a toolchain-specific stamp file and only include the stamp here. |
+ const LabelTargetVector& toolchain_deps = toolchain_->deps(); |
+ for (size_t i = 0; i < toolchain_deps.size(); i++) { |
+ out_ << " "; |
+ path_output_.WriteFile(out_, |
+ helper_.GetTargetOutputFile(toolchain_deps[i].ptr)); |
+ } |
+ |
// Extra hard deps passed in. |
for (size_t i = 0; i < extra_hard_deps.size(); i++) { |
out_ << " "; |