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

Side by Side Diff: tools/gn/ninja_action_target_writer.cc

Issue 321323004: Add yasm to the GN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/function_rebase_path.cc ('k') | tools/gn/ninja_action_target_writer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_template.h" 9 #include "tools/gn/file_template.h"
10 #include "tools/gn/string_utils.h" 10 #include "tools/gn/string_utils.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (target_->output_type() == Target::ACTION_FOREACH) { 50 if (target_->output_type() == Target::ACTION_FOREACH) {
51 // Write separate build lines for each input source file. 51 // Write separate build lines for each input source file.
52 WriteSourceRules(custom_rule_name, implicit_deps, args_template, 52 WriteSourceRules(custom_rule_name, implicit_deps, args_template,
53 &output_files); 53 &output_files);
54 } else { 54 } else {
55 DCHECK(target_->output_type() == Target::ACTION); 55 DCHECK(target_->output_type() == Target::ACTION);
56 56
57 // Write a rule that invokes the script once with the outputs as outputs, 57 // Write a rule that invokes the script once with the outputs as outputs,
58 // and the data as inputs. 58 // and the data as inputs.
59 out_ << "build"; 59 out_ << "build";
60 if (target_->action_values().has_depfile()) {
61 out_ << " ";
62 WriteDepfile(SourceFile());
63 }
64 const Target::FileList& outputs = target_->action_values().outputs(); 60 const Target::FileList& outputs = target_->action_values().outputs();
65 for (size_t i = 0; i < outputs.size(); i++) { 61 for (size_t i = 0; i < outputs.size(); i++) {
66 OutputFile output_path( 62 OutputFile output_path(
67 RemovePrefix(outputs[i].value(), 63 RemovePrefix(outputs[i].value(),
68 settings_->build_settings()->build_dir().value())); 64 settings_->build_settings()->build_dir().value()));
69 output_files.push_back(output_path); 65 output_files.push_back(output_path);
70 out_ << " "; 66 out_ << " ";
71 path_output_.WriteFile(out_, output_path); 67 path_output_.WriteFile(out_, output_path);
72 } 68 }
73 69
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 helper_.GetTargetOutputFile(target_->datadeps()[i].ptr)); 200 helper_.GetTargetOutputFile(target_->datadeps()[i].ptr));
205 } 201 }
206 202
207 out_ << std::endl; 203 out_ << std::endl;
208 } 204 }
209 205
210 void NinjaActionTargetWriter::WriteOutputFilesForBuildLine( 206 void NinjaActionTargetWriter::WriteOutputFilesForBuildLine(
211 const FileTemplate& output_template, 207 const FileTemplate& output_template,
212 const SourceFile& source, 208 const SourceFile& source,
213 std::vector<OutputFile>* output_files) { 209 std::vector<OutputFile>* output_files) {
214 // If there is a depfile specified we need to list it as the first output as
215 // that is what ninja will expect the depfile to refer to itself as.
216 if (target_->action_values().has_depfile()) {
217 out_ << " ";
218 WriteDepfile(source);
219 }
220 std::vector<std::string> output_template_result; 210 std::vector<std::string> output_template_result;
221 output_template.ApplyString(source.value(), &output_template_result); 211 output_template.ApplyString(source.value(), &output_template_result);
222 for (size_t out_i = 0; out_i < output_template_result.size(); out_i++) { 212 for (size_t out_i = 0; out_i < output_template_result.size(); out_i++) {
223 OutputFile output_path(output_template_result[out_i]); 213 OutputFile output_path(output_template_result[out_i]);
224 output_files->push_back(output_path); 214 output_files->push_back(output_path);
225 out_ << " "; 215 out_ << " ";
226 path_output_.WriteFile(out_, output_path); 216 path_output_.WriteFile(out_, output_path);
227 } 217 }
228 } 218 }
229 219
230 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) { 220 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) {
231 std::vector<std::string> result; 221 std::vector<std::string> result;
232 GetDepfileTemplate().ApplyString(source.value(), &result); 222 GetDepfileTemplate().ApplyString(source.value(), &result);
233 path_output_.WriteFile(out_, OutputFile(result[0])); 223 path_output_.WriteFile(out_, OutputFile(result[0]));
234 } 224 }
235 225
236 FileTemplate NinjaActionTargetWriter::GetDepfileTemplate() const { 226 FileTemplate NinjaActionTargetWriter::GetDepfileTemplate() const {
237 std::vector<std::string> template_args; 227 std::vector<std::string> template_args;
238 std::string depfile_relative_to_build_dir = 228 std::string depfile_relative_to_build_dir =
239 RemovePrefix(target_->action_values().depfile().value(), 229 RemovePrefix(target_->action_values().depfile().value(),
240 settings_->build_settings()->build_dir().value()); 230 settings_->build_settings()->build_dir().value());
241 template_args.push_back(depfile_relative_to_build_dir); 231 template_args.push_back(depfile_relative_to_build_dir);
242 return FileTemplate(template_args); 232 return FileTemplate(template_args);
243 } 233 }
OLDNEW
« no previous file with comments | « tools/gn/function_rebase_path.cc ('k') | tools/gn/ninja_action_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698