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

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

Issue 387663003: Improve GN handling of directory templates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/action_values.h ('k') | tools/gn/file_template.h » ('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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "tools/gn/commands.h" 10 #include "tools/gn/commands.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 OutputString("\n" + header + ":\n"); 241 OutputString("\n" + header + ":\n");
242 242
243 std::string indent = indent_extra ? " " : " "; 243 std::string indent = indent_extra ? " " : " ";
244 244
245 Target::FileList sorted = files; 245 Target::FileList sorted = files;
246 std::sort(sorted.begin(), sorted.end()); 246 std::sort(sorted.begin(), sorted.end());
247 for (size_t i = 0; i < sorted.size(); i++) 247 for (size_t i = 0; i < sorted.size(); i++)
248 OutputString(indent + sorted[i].value() + "\n"); 248 OutputString(indent + sorted[i].value() + "\n");
249 } 249 }
250 250
251 // This sorts the list.
252 void PrintStringList(const std::vector<std::string>& strings,
253 const std::string& header,
254 bool indent_extra,
255 bool display_header) {
256 if (strings.empty())
257 return;
258
259 if (display_header)
260 OutputString("\n" + header + ":\n");
261
262 std::string indent = indent_extra ? " " : " ";
263
264 std::vector<std::string> sorted = strings;
265 std::sort(sorted.begin(), sorted.end());
266 for (size_t i = 0; i < sorted.size(); i++)
267 OutputString(indent + sorted[i] + "\n");
268 }
269
251 void PrintSources(const Target* target, bool display_header) { 270 void PrintSources(const Target* target, bool display_header) {
252 PrintFileList(target->sources(), "sources", false, display_header); 271 PrintFileList(target->sources(), "sources", false, display_header);
253 } 272 }
254 273
255 void PrintInputs(const Target* target, bool display_header) { 274 void PrintInputs(const Target* target, bool display_header) {
256 PrintFileList(target->inputs(), "inputs", false, display_header); 275 PrintFileList(target->inputs(), "inputs", false, display_header);
257 } 276 }
258 277
259 void PrintOutputs(const Target* target, bool display_header) { 278 void PrintOutputs(const Target* target, bool display_header) {
260 if (target->output_type() == Target::ACTION) { 279 if (target->output_type() == Target::ACTION) {
261 // Just display the outputs directly. 280 // Just display the outputs directly.
262 PrintFileList(target->action_values().outputs(), "outputs", false, 281 PrintStringList(target->action_values().outputs(), "outputs", false,
263 display_header); 282 display_header);
264 } else if (target->output_type() == Target::ACTION_FOREACH) { 283 } else if (target->output_type() == Target::ACTION_FOREACH ||
284 target->output_type() == Target::COPY_FILES) {
265 // Display both the output pattern and resolved list. 285 // Display both the output pattern and resolved list.
266 if (display_header) 286 if (display_header)
267 OutputString("\noutputs:\n"); 287 OutputString("\noutputs:\n");
268 288
269 // Display the pattern. 289 // Display the pattern.
270 OutputString(" Output pattern:\n"); 290 OutputString(" Output pattern:\n");
271 PrintFileList(target->action_values().outputs(), "", true, false); 291 PrintStringList(target->action_values().outputs(), "", true, false);
272 292
273 // Now display what that resolves to given the sources. 293 // Now display what that resolves to given the sources.
274 OutputString("\n Resolved output file list:\n"); 294 OutputString("\n Resolved output file list:\n");
275 295
276 std::vector<std::string> output_strings; 296 std::vector<std::string> output_strings;
277 FileTemplate file_template = FileTemplate::GetForTargetOutputs(target); 297 FileTemplate file_template = FileTemplate::GetForTargetOutputs(target);
278 for (size_t i = 0; i < target->sources().size(); i++) 298 for (size_t i = 0; i < target->sources().size(); i++)
279 file_template.Apply(target->sources()[i], &output_strings); 299 file_template.Apply(target->sources()[i], &output_strings);
280 300 PrintStringList(output_strings, "", true, false);
281 std::sort(output_strings.begin(), output_strings.end());
282 for (size_t i = 0; i < output_strings.size(); i++) {
283 OutputString(" " + output_strings[i] + "\n");
284 }
285 } 301 }
286 } 302 }
287 303
288 void PrintScript(const Target* target, bool display_header) { 304 void PrintScript(const Target* target, bool display_header) {
289 if (display_header) 305 if (display_header)
290 OutputString("\nscript:\n"); 306 OutputString("\nscript:\n");
291 OutputString(" " + target->action_values().script().value() + "\n"); 307 OutputString(" " + target->action_values().script().value() + "\n");
292 } 308 }
293 309
294 void PrintArgs(const Target* target, bool display_header) { 310 void PrintArgs(const Target* target, bool display_header) {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // so always display them, even for groups and such. 609 // so always display them, even for groups and such.
594 PrintLibs(target, true); 610 PrintLibs(target, true);
595 PrintLibDirs(target, true); 611 PrintLibDirs(target, true);
596 612
597 PrintDeps(target, true); 613 PrintDeps(target, true);
598 614
599 return 0; 615 return 0;
600 } 616 }
601 617
602 } // namespace commands 618 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/action_values.h ('k') | tools/gn/file_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698