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

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: Created 7 years, 2 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // The build command goes in the rsp file. 85 // The build command goes in the rsp file.
86 out_ << " rspfile_content = "; 86 out_ << " rspfile_content = ";
87 path_output_.WriteFile(out_, settings_->build_settings()->python_path()); 87 path_output_.WriteFile(out_, settings_->build_settings()->python_path());
88 out_ << " "; 88 out_ << " ";
89 path_output_.WriteFile(out_, target_->script_values().script()); 89 path_output_.WriteFile(out_, target_->script_values().script());
90 args_template.WriteWithNinjaExpansions(out_); 90 args_template.WriteWithNinjaExpansions(out_);
91 out_ << std::endl; 91 out_ << std::endl;
92 } else { 92 } else {
93 // Posix can execute Python directly. 93 // Posix can execute Python directly.
94 out_ << "rule " << custom_rule_name << std::endl; 94 out_ << "rule " << custom_rule_name << std::endl;
95 out_ << " command = cd "; 95 out_ << " command = $pythonpath ";
brettw 2013/10/23 16:27:05 While you're here, can you do WriteFile(...python_
koz (OOO until 15th September) 2013/10/24 05:56:28 Done.
96 path_output_.WriteDir(out_, target_->label().dir(),
97 PathOutput::DIR_NO_LAST_SLASH);
98 out_ << "; $pythonpath ";
99 path_output_.WriteFile(out_, target_->script_values().script()); 96 path_output_.WriteFile(out_, target_->script_values().script());
100 args_template.WriteWithNinjaExpansions(out_); 97 args_template.WriteWithNinjaExpansions(out_);
101 out_ << std::endl; 98 out_ << std::endl;
102 out_ << " description = CUSTOM " << target_label << std::endl; 99 out_ << " description = CUSTOM " << target_label << std::endl;
103 out_ << " restat = 1" << std::endl; 100 out_ << " restat = 1" << std::endl;
104 } 101 }
105 102
106 out_ << std::endl; 103 out_ << std::endl;
107 return custom_rule_name; 104 return custom_rule_name;
108 } 105 }
(...skipping 17 matching lines...) Expand all
126 const std::string& implicit_deps, 123 const std::string& implicit_deps,
127 const FileTemplate& args_template, 124 const FileTemplate& args_template,
128 std::vector<OutputFile>* output_files) { 125 std::vector<OutputFile>* output_files) {
129 FileTemplate output_template(GetOutputTemplate()); 126 FileTemplate output_template(GetOutputTemplate());
130 127
131 const Target::FileList& sources = target_->sources(); 128 const Target::FileList& sources = target_->sources();
132 for (size_t i = 0; i < sources.size(); i++) { 129 for (size_t i = 0; i < sources.size(); i++) {
133 out_ << "build"; 130 out_ << "build";
134 WriteOutputFilesForBuildLine(output_template, sources[i], output_files); 131 WriteOutputFilesForBuildLine(output_template, sources[i], output_files);
135 132
136 out_ << ": " << custom_rule_name; 133 out_ << ": " << custom_rule_name << " ";
brettw 2013/10/23 16:27:05 Whoopsies! I guess I haven't done any script stuff
koz (OOO until 15th September) 2013/10/24 05:56:28 I wondered for a bit if it was some bit of ninja s
137 path_output_.WriteFile(out_, sources[i]); 134 path_output_.WriteFile(out_, sources[i]);
138 out_ << implicit_deps << std::endl; 135 out_ << implicit_deps << std::endl;
139 136
140 // Windows needs a unique ID for the response file. 137 // Windows needs a unique ID for the response file.
141 if (target_->settings()->IsWin()) 138 if (target_->settings()->IsWin())
142 out_ << " unique_name = " << i << std::endl; 139 out_ << " unique_name = " << i << std::endl;
143 140
144 if (args_template.has_substitutions()) 141 if (args_template.has_substitutions())
145 WriteArgsSubstitutions(sources[i], args_template); 142 WriteArgsSubstitutions(sources[i], args_template);
146 } 143 }
(...skipping 19 matching lines...) Expand all
166 std::vector<OutputFile>* output_files) { 163 std::vector<OutputFile>* output_files) {
167 std::vector<std::string> output_template_result; 164 std::vector<std::string> output_template_result;
168 output_template.ApplyString(source.value(), &output_template_result); 165 output_template.ApplyString(source.value(), &output_template_result);
169 for (size_t out_i = 0; out_i < output_template_result.size(); out_i++) { 166 for (size_t out_i = 0; out_i < output_template_result.size(); out_i++) {
170 OutputFile output_path(output_template_result[out_i]); 167 OutputFile output_path(output_template_result[out_i]);
171 output_files->push_back(output_path); 168 output_files->push_back(output_path);
172 out_ << " "; 169 out_ << " ";
173 path_output_.WriteFile(out_, output_path); 170 path_output_.WriteFile(out_, output_path);
174 } 171 }
175 } 172 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/ninja_script_target_writer_unittest.cc » ('j') | tools/gn/ninja_script_target_writer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698