| 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_script_target_writer.h" | 5 #include "tools/gn/ninja_script_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/file_template.h" | 9 #include "tools/gn/file_template.h" |
| 10 #include "tools/gn/string_utils.h" | 10 #include "tools/gn/string_utils.h" |
| 11 #include "tools/gn/target.h" | 11 #include "tools/gn/target.h" |
| 12 | 12 |
| 13 NinjaScriptTargetWriter::NinjaScriptTargetWriter(const Target* target, | 13 NinjaScriptTargetWriter::NinjaScriptTargetWriter(const Target* target, |
| 14 const Toolchain* toolchain, | |
| 15 std::ostream& out) | 14 std::ostream& out) |
| 16 : NinjaTargetWriter(target, toolchain, out), | 15 : NinjaTargetWriter(target, out), |
| 17 path_output_no_escaping_( | 16 path_output_no_escaping_( |
| 18 target->settings()->build_settings()->build_dir(), | 17 target->settings()->build_settings()->build_dir(), |
| 19 ESCAPE_NONE, false) { | 18 ESCAPE_NONE, false) { |
| 20 } | 19 } |
| 21 | 20 |
| 22 NinjaScriptTargetWriter::~NinjaScriptTargetWriter() { | 21 NinjaScriptTargetWriter::~NinjaScriptTargetWriter() { |
| 23 } | 22 } |
| 24 | 23 |
| 25 void NinjaScriptTargetWriter::Run() { | 24 void NinjaScriptTargetWriter::Run() { |
| 26 FileTemplate args_template(target_->script_values().args()); | 25 FileTemplate args_template(target_->script_values().args()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 if (args_template.has_substitutions()) | 145 if (args_template.has_substitutions()) |
| 147 WriteArgsSubstitutions(sources[i], args_template); | 146 WriteArgsSubstitutions(sources[i], args_template); |
| 148 } | 147 } |
| 149 } | 148 } |
| 150 | 149 |
| 151 void NinjaScriptTargetWriter::WriteStamp( | 150 void NinjaScriptTargetWriter::WriteStamp( |
| 152 const std::vector<OutputFile>& output_files) { | 151 const std::vector<OutputFile>& output_files) { |
| 153 out_ << "build "; | 152 out_ << "build "; |
| 154 path_output_.WriteFile(out_, helper_.GetTargetOutputFile(target_)); | 153 path_output_.WriteFile(out_, helper_.GetTargetOutputFile(target_)); |
| 155 out_ << ": " | 154 out_ << ": " |
| 156 << helper_.GetRulePrefix(target_->settings()) | 155 << helper_.GetRulePrefix(target_->settings()->toolchain()) |
| 157 << "stamp"; | 156 << "stamp"; |
| 158 for (size_t i = 0; i < output_files.size(); i++) { | 157 for (size_t i = 0; i < output_files.size(); i++) { |
| 159 out_ << " "; | 158 out_ << " "; |
| 160 path_output_.WriteFile(out_, output_files[i]); | 159 path_output_.WriteFile(out_, output_files[i]); |
| 161 } | 160 } |
| 162 out_ << std::endl; | 161 out_ << std::endl; |
| 163 } | 162 } |
| 164 | 163 |
| 165 void NinjaScriptTargetWriter::WriteOutputFilesForBuildLine( | 164 void NinjaScriptTargetWriter::WriteOutputFilesForBuildLine( |
| 166 const FileTemplate& output_template, | 165 const FileTemplate& output_template, |
| 167 const SourceFile& source, | 166 const SourceFile& source, |
| 168 std::vector<OutputFile>* output_files) { | 167 std::vector<OutputFile>* output_files) { |
| 169 std::vector<std::string> output_template_result; | 168 std::vector<std::string> output_template_result; |
| 170 output_template.ApplyString(source.value(), &output_template_result); | 169 output_template.ApplyString(source.value(), &output_template_result); |
| 171 for (size_t out_i = 0; out_i < output_template_result.size(); out_i++) { | 170 for (size_t out_i = 0; out_i < output_template_result.size(); out_i++) { |
| 172 OutputFile output_path(output_template_result[out_i]); | 171 OutputFile output_path(output_template_result[out_i]); |
| 173 output_files->push_back(output_path); | 172 output_files->push_back(output_path); |
| 174 out_ << " "; | 173 out_ << " "; |
| 175 path_output_.WriteFile(out_, output_path); | 174 path_output_.WriteFile(out_, output_path); |
| 176 } | 175 } |
| 177 } | 176 } |
| OLD | NEW |