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

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

Issue 30253002: Use paths relative to build dir in custom actions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: break lines to be <= 80 chars Created 7 years, 1 month 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 | « no previous file | tools/gn/ninja_script_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_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"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // The build command goes in the rsp file. 87 // The build command goes in the rsp file.
88 out_ << " rspfile_content = "; 88 out_ << " rspfile_content = ";
89 path_output_.WriteFile(out_, settings_->build_settings()->python_path()); 89 path_output_.WriteFile(out_, settings_->build_settings()->python_path());
90 out_ << " "; 90 out_ << " ";
91 path_output_.WriteFile(out_, target_->script_values().script()); 91 path_output_.WriteFile(out_, target_->script_values().script());
92 args_template.WriteWithNinjaExpansions(out_); 92 args_template.WriteWithNinjaExpansions(out_);
93 out_ << std::endl; 93 out_ << std::endl;
94 } else { 94 } else {
95 // Posix can execute Python directly. 95 // Posix can execute Python directly.
96 out_ << "rule " << custom_rule_name << std::endl; 96 out_ << "rule " << custom_rule_name << std::endl;
97 out_ << " command = cd "; 97 out_ << " command = ";
98 path_output_.WriteDir(out_, target_->label().dir(), 98 path_output_.WriteFile(out_, settings_->build_settings()->python_path());
99 PathOutput::DIR_NO_LAST_SLASH); 99 out_ << " ";
100 out_ << "; $pythonpath ";
101 path_output_.WriteFile(out_, target_->script_values().script()); 100 path_output_.WriteFile(out_, target_->script_values().script());
102 args_template.WriteWithNinjaExpansions(out_); 101 args_template.WriteWithNinjaExpansions(out_);
103 out_ << std::endl; 102 out_ << std::endl;
104 out_ << " description = CUSTOM " << target_label << std::endl; 103 out_ << " description = CUSTOM " << target_label << std::endl;
105 out_ << " restat = 1" << std::endl; 104 out_ << " restat = 1" << std::endl;
106 } 105 }
107 106
108 out_ << std::endl; 107 out_ << std::endl;
109 return custom_rule_name; 108 return custom_rule_name;
110 } 109 }
(...skipping 17 matching lines...) Expand all
128 const std::string& implicit_deps, 127 const std::string& implicit_deps,
129 const FileTemplate& args_template, 128 const FileTemplate& args_template,
130 std::vector<OutputFile>* output_files) { 129 std::vector<OutputFile>* output_files) {
131 FileTemplate output_template(GetOutputTemplate()); 130 FileTemplate output_template(GetOutputTemplate());
132 131
133 const Target::FileList& sources = target_->sources(); 132 const Target::FileList& sources = target_->sources();
134 for (size_t i = 0; i < sources.size(); i++) { 133 for (size_t i = 0; i < sources.size(); i++) {
135 out_ << "build"; 134 out_ << "build";
136 WriteOutputFilesForBuildLine(output_template, sources[i], output_files); 135 WriteOutputFilesForBuildLine(output_template, sources[i], output_files);
137 136
138 out_ << ": " << custom_rule_name; 137 out_ << ": " << custom_rule_name << " ";
139 path_output_.WriteFile(out_, sources[i]); 138 path_output_.WriteFile(out_, sources[i]);
140 out_ << implicit_deps << std::endl; 139 out_ << implicit_deps << std::endl;
141 140
142 // Windows needs a unique ID for the response file. 141 // Windows needs a unique ID for the response file.
143 if (target_->settings()->IsWin()) 142 if (target_->settings()->IsWin())
144 out_ << " unique_name = " << i << std::endl; 143 out_ << " unique_name = " << i << std::endl;
145 144
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 }
(...skipping 19 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/ninja_script_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698