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

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

Issue 2152413002: GN: don't write separate files for non-binary targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 4 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
« no previous file with comments | « tools/gn/command_refs.cc ('k') | tools/gn/eclipse_writer.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 "tools/gn/commands.h" 5 #include "tools/gn/commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "tools/gn/builder.h" 10 #include "tools/gn/builder.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // If the caller wants to default to the main toolchain only, set it 49 // If the caller wants to default to the main toolchain only, set it
50 // explicitly. 50 // explicitly.
51 if (pattern.toolchain().is_null()) { 51 if (pattern.toolchain().is_null()) {
52 // No explicit toolchain set. 52 // No explicit toolchain set.
53 pattern.set_toolchain(setup->loader()->default_toolchain_label()); 53 pattern.set_toolchain(setup->loader()->default_toolchain_label());
54 } 54 }
55 } 55 }
56 56
57 std::vector<LabelPattern> pattern_vector; 57 std::vector<LabelPattern> pattern_vector;
58 pattern_vector.push_back(pattern); 58 pattern_vector.push_back(pattern);
59 FilterTargetsByPatterns(setup->builder()->GetAllResolvedTargets(), 59 FilterTargetsByPatterns(setup->builder().GetAllResolvedTargets(),
60 pattern_vector, matches); 60 pattern_vector, matches);
61 return true; 61 return true;
62 } 62 }
63 63
64 64
65 // If there's an error, it will be printed and false will be returned. 65 // If there's an error, it will be printed and false will be returned.
66 bool ResolveStringFromCommandLineInput( 66 bool ResolveStringFromCommandLineInput(
67 Setup* setup, 67 Setup* setup,
68 const SourceDir& current_dir, 68 const SourceDir& current_dir,
69 const std::string& input, 69 const std::string& input,
(...skipping 25 matching lines...) Expand all
95 err = Err(); 95 err = Err();
96 file_matches->push_back(current_dir.ResolveRelativeFile( 96 file_matches->push_back(current_dir.ResolveRelativeFile(
97 Value(nullptr, input), &err, setup->build_settings().root_path_utf8())); 97 Value(nullptr, input), &err, setup->build_settings().root_path_utf8()));
98 if (err.has_error()) { 98 if (err.has_error()) {
99 err.PrintToStdout(); 99 err.PrintToStdout();
100 return false; 100 return false;
101 } 101 }
102 return true; 102 return true;
103 } 103 }
104 104
105 const Item* item = setup->builder()->GetItem(label); 105 const Item* item = setup->builder().GetItem(label);
106 if (item) { 106 if (item) {
107 if (const Config* as_config = item->AsConfig()) 107 if (const Config* as_config = item->AsConfig())
108 config_matches->push_back(as_config); 108 config_matches->push_back(as_config);
109 else if (const Target* as_target = item->AsTarget()) 109 else if (const Target* as_target = item->AsTarget())
110 target_matches->push_back(as_target); 110 target_matches->push_back(as_target);
111 else if (const Toolchain* as_toolchain = item->AsToolchain()) 111 else if (const Toolchain* as_toolchain = item->AsToolchain())
112 toolchain_matches->push_back(as_toolchain); 112 toolchain_matches->push_back(as_toolchain);
113 } else { 113 } else {
114 // Not an item, assume this must be a file. 114 // Not an item, assume this must be a file.
115 file_matches->push_back(current_dir.ResolveRelativeFile( 115 file_matches->push_back(current_dir.ResolveRelativeFile(
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 Value arg_value(nullptr, label_string); 384 Value arg_value(nullptr, label_string);
385 Err err; 385 Err err;
386 Label label = Label::Resolve(SourceDirForCurrentDirectory( 386 Label label = Label::Resolve(SourceDirForCurrentDirectory(
387 setup->build_settings().root_path()), 387 setup->build_settings().root_path()),
388 default_toolchain, arg_value, &err); 388 default_toolchain, arg_value, &err);
389 if (err.has_error()) { 389 if (err.has_error()) {
390 err.PrintToStdout(); 390 err.PrintToStdout();
391 return nullptr; 391 return nullptr;
392 } 392 }
393 393
394 const Item* item = setup->builder()->GetItem(label); 394 const Item* item = setup->builder().GetItem(label);
395 if (!item) { 395 if (!item) {
396 Err(Location(), "Label not found.", 396 Err(Location(), "Label not found.",
397 label.GetUserVisibleName(false) + " not found.").PrintToStdout(); 397 label.GetUserVisibleName(false) + " not found.").PrintToStdout();
398 return nullptr; 398 return nullptr;
399 } 399 }
400 400
401 const Target* target = item->AsTarget(); 401 const Target* target = item->AsTarget();
402 if (!target) { 402 if (!target) {
403 Err(Location(), "Not a target.", 403 Err(Location(), "Not a target.",
404 "The \"" + label.GetUserVisibleName(false) + "\" thing\n" 404 "The \"" + label.GetUserVisibleName(false) + "\" thing\n"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 FilterAndPrintTargets(indent, &target_vector); 528 FilterAndPrintTargets(indent, &target_vector);
529 } 529 }
530 530
531 void FilterAndPrintTargetSet(const std::set<const Target*>& targets, 531 void FilterAndPrintTargetSet(const std::set<const Target*>& targets,
532 base::ListValue* out) { 532 base::ListValue* out) {
533 std::vector<const Target*> target_vector(targets.begin(), targets.end()); 533 std::vector<const Target*> target_vector(targets.begin(), targets.end());
534 FilterAndPrintTargets(&target_vector, out); 534 FilterAndPrintTargets(&target_vector, out);
535 } 535 }
536 536
537 } // namespace commands 537 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_refs.cc ('k') | tools/gn/eclipse_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698