OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/ninja_action_target_writer.h" | 5 #include "tools/gn/ninja_action_target_writer.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "tools/gn/deps_iterator.h" | 8 #include "tools/gn/deps_iterator.h" |
9 #include "tools/gn/err.h" | 9 #include "tools/gn/err.h" |
10 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 void NinjaActionTargetWriter::Run() { | 26 void NinjaActionTargetWriter::Run() { |
27 std::string custom_rule_name = WriteRuleDefinition(); | 27 std::string custom_rule_name = WriteRuleDefinition(); |
28 | 28 |
29 // Collect our deps to pass as "extra hard dependencies" for input deps. This | 29 // Collect our deps to pass as "extra hard dependencies" for input deps. This |
30 // will force all of the action's dependencies to be completed before the | 30 // will force all of the action's dependencies to be completed before the |
31 // action is run. Usually, if an action has a dependency, it will be | 31 // action is run. Usually, if an action has a dependency, it will be |
32 // operating on the result of that previous step, so we need to be sure to | 32 // operating on the result of that previous step, so we need to be sure to |
33 // serialize these. | 33 // serialize these. |
34 std::vector<const Target*> extra_hard_deps; | 34 std::vector<const Target*> extra_hard_deps; |
35 for (DepsIterator iter(target_, DepsIterator::LINKED_ONLY); | 35 for (const auto& pair : target_->GetDeps(Target::DEPS_LINKED)) |
36 !iter.done(); iter.Advance()) | 36 extra_hard_deps.push_back(pair.ptr); |
37 extra_hard_deps.push_back(iter.target()); | |
38 | 37 |
39 // For ACTIONs this is a bit inefficient since it creates an input dep | 38 // For ACTIONs this is a bit inefficient since it creates an input dep |
40 // stamp file even though we're only going to use it once. It would save a | 39 // stamp file even though we're only going to use it once. It would save a |
41 // build step to skip this and write the order-only deps directly on the | 40 // build step to skip this and write the order-only deps directly on the |
42 // build rule. This should probably be handled by WriteInputDepsStampAndGetDep | 41 // build rule. This should probably be handled by WriteInputDepsStampAndGetDep |
43 // automatically if we supply a count of sources (so it can optimize based on | 42 // automatically if we supply a count of sources (so it can optimize based on |
44 // how many times things would be duplicated). | 43 // how many times things would be duplicated). |
45 OutputFile input_dep = WriteInputDepsStampAndGetDep(extra_hard_deps); | 44 OutputFile input_dep = WriteInputDepsStampAndGetDep(extra_hard_deps); |
46 out_ << std::endl; | 45 out_ << std::endl; |
47 | 46 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 out_ << " "; | 208 out_ << " "; |
210 path_output_.WriteFile(out_, (*output_files)[i]); | 209 path_output_.WriteFile(out_, (*output_files)[i]); |
211 } | 210 } |
212 } | 211 } |
213 | 212 |
214 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) { | 213 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) { |
215 path_output_.WriteFile(out_, | 214 path_output_.WriteFile(out_, |
216 SubstitutionWriter::ApplyPatternToSourceAsOutputFile( | 215 SubstitutionWriter::ApplyPatternToSourceAsOutputFile( |
217 settings_, target_->action_values().depfile(), source)); | 216 settings_, target_->action_values().depfile(), source)); |
218 } | 217 } |
OLD | NEW |