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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "tools/gn/deps_iterator.h" | 10 #include "tools/gn/deps_iterator.h" |
11 #include "tools/gn/err.h" | 11 #include "tools/gn/err.h" |
| 12 #include "tools/gn/pool.h" |
12 #include "tools/gn/settings.h" | 13 #include "tools/gn/settings.h" |
13 #include "tools/gn/string_utils.h" | 14 #include "tools/gn/string_utils.h" |
14 #include "tools/gn/substitution_writer.h" | 15 #include "tools/gn/substitution_writer.h" |
15 #include "tools/gn/target.h" | 16 #include "tools/gn/target.h" |
16 | 17 |
17 NinjaActionTargetWriter::NinjaActionTargetWriter(const Target* target, | 18 NinjaActionTargetWriter::NinjaActionTargetWriter(const Target* target, |
18 std::ostream& out) | 19 std::ostream& out) |
19 : NinjaTargetWriter(target, out), | 20 : NinjaTargetWriter(target, out), |
20 path_output_no_escaping_( | 21 path_output_no_escaping_( |
21 target->settings()->build_settings()->build_dir(), | 22 target->settings()->build_settings()->build_dir(), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // time any of its dependencies change. | 70 // time any of its dependencies change. |
70 out_ << " | "; | 71 out_ << " | "; |
71 path_output_.WriteFile(out_, input_dep); | 72 path_output_.WriteFile(out_, input_dep); |
72 } | 73 } |
73 out_ << std::endl; | 74 out_ << std::endl; |
74 if (target_->action_values().has_depfile()) { | 75 if (target_->action_values().has_depfile()) { |
75 out_ << " depfile = "; | 76 out_ << " depfile = "; |
76 WriteDepfile(SourceFile()); | 77 WriteDepfile(SourceFile()); |
77 out_ << std::endl; | 78 out_ << std::endl; |
78 } | 79 } |
79 if (target_->action_values().is_console()) { | 80 if (target_->action_values().pool().ptr) { |
80 out_ << " pool = console"; | 81 out_ << " pool = "; |
| 82 out_ << target_->action_values().pool().ptr->GetNinjaName( |
| 83 settings_->default_toolchain_label()); |
81 out_ << std::endl; | 84 out_ << std::endl; |
82 } | 85 } |
83 } | 86 } |
84 out_ << std::endl; | 87 out_ << std::endl; |
85 | 88 |
86 // Write the stamp, which also depends on all data deps. These are needed at | 89 // Write the stamp, which also depends on all data deps. These are needed at |
87 // runtime and should be compiled when the action is, but don't need to be | 90 // runtime and should be compiled when the action is, but don't need to be |
88 // done before we run the action. | 91 // done before we run the action. |
89 std::vector<OutputFile> data_outs; | 92 std::vector<OutputFile> data_outs; |
90 for (const auto& dep : target_->data_deps()) | 93 for (const auto& dep : target_->data_deps()) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 out_ << " "; | 139 out_ << " "; |
137 path_output_.WriteFile(out_, target_->action_values().script()); | 140 path_output_.WriteFile(out_, target_->action_values().script()); |
138 for (const auto& arg : args.list()) { | 141 for (const auto& arg : args.list()) { |
139 out_ << " "; | 142 out_ << " "; |
140 SubstitutionWriter::WriteWithNinjaVariables( | 143 SubstitutionWriter::WriteWithNinjaVariables( |
141 arg, args_escape_options, out_); | 144 arg, args_escape_options, out_); |
142 } | 145 } |
143 out_ << std::endl; | 146 out_ << std::endl; |
144 out_ << " description = ACTION " << target_label << std::endl; | 147 out_ << " description = ACTION " << target_label << std::endl; |
145 out_ << " restat = 1" << std::endl; | 148 out_ << " restat = 1" << std::endl; |
| 149 const Tool* tool = target_->toolchain()->GetTool(Toolchain::TYPE_ACTION); |
| 150 if (tool && tool->pool().ptr) { |
| 151 out_ << " pool = "; |
| 152 out_ << tool->pool().ptr->GetNinjaName( |
| 153 settings_->default_toolchain_label()); |
| 154 out_ << std::endl; |
| 155 } |
146 | 156 |
147 return custom_rule_name; | 157 return custom_rule_name; |
148 } | 158 } |
149 | 159 |
150 void NinjaActionTargetWriter::WriteSourceRules( | 160 void NinjaActionTargetWriter::WriteSourceRules( |
151 const std::string& custom_rule_name, | 161 const std::string& custom_rule_name, |
152 const OutputFile& input_dep, | 162 const OutputFile& input_dep, |
153 std::vector<OutputFile>* output_files) { | 163 std::vector<OutputFile>* output_files) { |
154 EscapeOptions args_escape_options; | 164 EscapeOptions args_escape_options; |
155 args_escape_options.mode = ESCAPE_NINJA_COMMAND; | 165 args_escape_options.mode = ESCAPE_NINJA_COMMAND; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 out_ << " "; | 223 out_ << " "; |
214 path_output_.WriteFile(out_, (*output_files)[i]); | 224 path_output_.WriteFile(out_, (*output_files)[i]); |
215 } | 225 } |
216 } | 226 } |
217 | 227 |
218 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) { | 228 void NinjaActionTargetWriter::WriteDepfile(const SourceFile& source) { |
219 path_output_.WriteFile(out_, | 229 path_output_.WriteFile(out_, |
220 SubstitutionWriter::ApplyPatternToSourceAsOutputFile( | 230 SubstitutionWriter::ApplyPatternToSourceAsOutputFile( |
221 target_, settings_, target_->action_values().depfile(), source)); | 231 target_, settings_, target_->action_values().depfile(), source)); |
222 } | 232 } |
OLD | NEW |