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

Unified Diff: tools/gn/ninja_copy_target_writer.cc

Issue 693443002: Make the gn copy() tool honor dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix formatting Created 6 years, 2 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/ninja_copy_target_writer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_copy_target_writer.cc
diff --git a/tools/gn/ninja_copy_target_writer.cc b/tools/gn/ninja_copy_target_writer.cc
index ca3485240854cd8147600fb838e36c19918df64a..26455d9852e0ea8efd87de9d49cc6561cc86e294 100644
--- a/tools/gn/ninja_copy_target_writer.cc
+++ b/tools/gn/ninja_copy_target_writer.cc
@@ -71,6 +71,9 @@ void NinjaCopyTargetWriter::WriteCopyRules(
GetNinjaRulePrefixForToolchain(settings_) +
Toolchain::ToolTypeToName(Toolchain::TYPE_COPY);
+ OutputFile input_dep =
+ WriteInputDepsStampAndGetDep(std::vector<const Target*>());
+
// Note that we don't write implicit deps for copy steps. "copy" only
// depends on the output files themselves, rather than having includes
// (the possibility of generated #includes is the main reason for implicit
@@ -92,6 +95,11 @@ void NinjaCopyTargetWriter::WriteCopyRules(
//
// Moreover, doing this assumes that the copy step is always a simple
// locally run command, so there is no need for a toolchain dependency.
+ //
+ // Note that there is the need in some cases for order-only dependencies
+ // where a command might need to make sure something else runs before it runs
+ // to avoid conflicts. Such cases should be avoided where possible, but
+ // sometimes that's not possible.
for (size_t i = 0; i < target_->sources().size(); i++) {
const SourceFile& input_file = target_->sources()[i];
@@ -104,6 +112,10 @@ void NinjaCopyTargetWriter::WriteCopyRules(
path_output_.WriteFile(out_, output_file);
out_ << ": " << tool_name << " ";
path_output_.WriteFile(out_, input_file);
+ if (!input_dep.value().empty()) {
+ out_ << " || ";
+ path_output_.WriteFile(out_, input_dep);
+ }
out_ << std::endl;
}
}
« no previous file with comments | « no previous file | tools/gn/ninja_copy_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698