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_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" |
11 #include "tools/gn/target.h" | 11 #include "tools/gn/target.h" |
12 | 12 |
13 NinjaActionTargetWriter::NinjaActionTargetWriter(const Target* target, | 13 NinjaActionTargetWriter::NinjaActionTargetWriter(const Target* target, |
14 const Toolchain* toolchain, | 14 const Toolchain* toolchain, |
15 std::ostream& out) | 15 std::ostream& out) |
16 : NinjaTargetWriter(target, toolchain, out), | 16 : NinjaTargetWriter(target, toolchain, out), |
17 path_output_no_escaping_( | 17 path_output_no_escaping_( |
18 target->settings()->build_settings()->build_dir(), | 18 target->settings()->build_settings()->build_dir(), |
19 ESCAPE_NONE, false) { | 19 ESCAPE_NONE) { |
20 } | 20 } |
21 | 21 |
22 NinjaActionTargetWriter::~NinjaActionTargetWriter() { | 22 NinjaActionTargetWriter::~NinjaActionTargetWriter() { |
23 } | 23 } |
24 | 24 |
25 void NinjaActionTargetWriter::Run() { | 25 void NinjaActionTargetWriter::Run() { |
26 FileTemplate args_template(target_->action_values().args()); | 26 FileTemplate args_template(target_->action_values().args()); |
27 std::string custom_rule_name = WriteRuleDefinition(args_template); | 27 std::string custom_rule_name = WriteRuleDefinition(args_template); |
28 | 28 |
29 // Collect our deps to pass as "extra hard dependencies" for input deps. This | 29 // Collect our deps to pass as "extra hard dependencies" for input deps. This |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 return custom_rule_name; | 137 return custom_rule_name; |
138 } | 138 } |
139 | 139 |
140 void NinjaActionTargetWriter::WriteArgsSubstitutions( | 140 void NinjaActionTargetWriter::WriteArgsSubstitutions( |
141 const SourceFile& source, | 141 const SourceFile& source, |
142 const FileTemplate& args_template) { | 142 const FileTemplate& args_template) { |
143 std::ostringstream source_file_stream; | 143 std::ostringstream source_file_stream; |
144 path_output_no_escaping_.WriteFile(source_file_stream, source); | 144 path_output_no_escaping_.WriteFile(source_file_stream, source); |
145 | 145 |
146 EscapeOptions template_escape_options; | 146 EscapeOptions template_escape_options; |
147 template_escape_options.mode = ESCAPE_NINJA_SHELL; | 147 template_escape_options.mode = ESCAPE_NINJA_COMMAND; |
148 template_escape_options.inhibit_quoting = true; | |
149 | 148 |
150 args_template.WriteNinjaVariablesForSubstitution( | 149 args_template.WriteNinjaVariablesForSubstitution( |
151 out_, source_file_stream.str(), template_escape_options); | 150 out_, source_file_stream.str(), template_escape_options); |
152 } | 151 } |
153 | 152 |
154 void NinjaActionTargetWriter::WriteSourceRules( | 153 void NinjaActionTargetWriter::WriteSourceRules( |
155 const std::string& custom_rule_name, | 154 const std::string& custom_rule_name, |
156 const std::string& implicit_deps, | 155 const std::string& implicit_deps, |
157 const FileTemplate& args_template, | 156 const FileTemplate& args_template, |
158 std::vector<OutputFile>* output_files) { | 157 std::vector<OutputFile>* output_files) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 234 } |
236 | 235 |
237 FileTemplate NinjaActionTargetWriter::GetDepfileTemplate() const { | 236 FileTemplate NinjaActionTargetWriter::GetDepfileTemplate() const { |
238 std::vector<std::string> template_args; | 237 std::vector<std::string> template_args; |
239 std::string depfile_relative_to_build_dir = | 238 std::string depfile_relative_to_build_dir = |
240 RemovePrefix(target_->action_values().depfile().value(), | 239 RemovePrefix(target_->action_values().depfile().value(), |
241 settings_->build_settings()->build_dir().value()); | 240 settings_->build_settings()->build_dir().value()); |
242 template_args.push_back(depfile_relative_to_build_dir); | 241 template_args.push_back(depfile_relative_to_build_dir); |
243 return FileTemplate(template_args); | 242 return FileTemplate(template_args); |
244 } | 243 } |
OLD | NEW |