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