| 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/err.h" | 8 #include "tools/gn/err.h" |
| 9 #include "tools/gn/string_utils.h" | 9 #include "tools/gn/string_utils.h" |
| 10 #include "tools/gn/substitution_writer.h" | 10 #include "tools/gn/substitution_writer.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // Collects all output files for writing below. | 46 // Collects all output files for writing below. |
| 47 std::vector<OutputFile> output_files; | 47 std::vector<OutputFile> output_files; |
| 48 | 48 |
| 49 if (target_->output_type() == Target::ACTION_FOREACH) { | 49 if (target_->output_type() == Target::ACTION_FOREACH) { |
| 50 // Write separate build lines for each input source file. | 50 // Write separate build lines for each input source file. |
| 51 WriteSourceRules(custom_rule_name, implicit_deps, &output_files); | 51 WriteSourceRules(custom_rule_name, implicit_deps, &output_files); |
| 52 } else { | 52 } else { |
| 53 DCHECK(target_->output_type() == Target::ACTION); | 53 DCHECK(target_->output_type() == Target::ACTION); |
| 54 | 54 |
| 55 // Write a rule that invokes the script once with the outputs as outputs, | 55 // Write a rule that invokes the script once with the outputs as outputs, |
| 56 // and the data as inputs. | 56 // and the data as inputs. It does not depend on the sources. |
| 57 out_ << "build"; | 57 out_ << "build"; |
| 58 SubstitutionWriter::ApplyListToSourcesAsOutputFile( | 58 SubstitutionWriter::GetListAsOutputFiles( |
| 59 settings_, target_->action_values().outputs(), target_->sources(), | 59 settings_, target_->action_values().outputs(), &output_files); |
| 60 &output_files); | |
| 61 for (size_t i = 0; i < output_files.size(); i++) { | 60 for (size_t i = 0; i < output_files.size(); i++) { |
| 62 out_ << " "; | 61 out_ << " "; |
| 63 path_output_.WriteFile(out_, output_files[i]); | 62 path_output_.WriteFile(out_, output_files[i]); |
| 64 } | 63 } |
| 65 | 64 |
| 66 out_ << ": " << custom_rule_name << implicit_deps << std::endl; | 65 out_ << ": " << custom_rule_name << implicit_deps << std::endl; |
| 67 if (target_->action_values().has_depfile()) { | 66 if (target_->action_values().has_depfile()) { |
| 68 out_ << " depfile = "; | 67 out_ << " depfile = "; |
| 69 WriteDepfile(SourceFile()); | 68 WriteDepfile(SourceFile()); |
| 70 out_ << std::endl; | 69 out_ << std::endl; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 out_ << " "; | 215 out_ << " "; |
| 217 path_output_.WriteFile(out_, (*output_files)[i]); | 216 path_output_.WriteFile(out_, (*output_files)[i]); |
| 218 } | 217 } |
| 219 } | 218 } |
| 220 | 219 |
| 221 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) { | 220 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) { |
| 222 path_output_.WriteFile(out_, | 221 path_output_.WriteFile(out_, |
| 223 SubstitutionWriter::ApplyPatternToSourceAsOutputFile( | 222 SubstitutionWriter::ApplyPatternToSourceAsOutputFile( |
| 224 settings_, target_->action_values().depfile(), source)); | 223 settings_, target_->action_values().depfile(), source)); |
| 225 } | 224 } |
| OLD | NEW |