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

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

Issue 1126193005: Check for inputs not generated by deps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data
Patch Set: Created 5 years, 6 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_ls.cc ('k') | tools/gn/filesystem_utils.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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return true; 134 return true;
135 } 135 }
136 for (const auto& cur_file : target->inputs()) { 136 for (const auto& cur_file : target->inputs()) {
137 if (cur_file == file) 137 if (cur_file == file)
138 return true; 138 return true;
139 } 139 }
140 for (const auto& cur_file : target->data()) { 140 for (const auto& cur_file : target->data()) {
141 if (cur_file == file.value()) 141 if (cur_file == file.value())
142 return true; 142 return true;
143 } 143 }
144
145 std::vector<SourceFile> outputs;
146 target->action_values().GetOutputsAsSourceFiles(target, &outputs);
147 for (const auto& cur_file : outputs) {
148 if (cur_file == file)
149 return true;
150 }
144 return false; 151 return false;
145 } 152 }
146 153
147 void GetTargetsContainingFile(Setup* setup, 154 void GetTargetsContainingFile(Setup* setup,
148 const std::vector<const Target*>& all_targets, 155 const std::vector<const Target*>& all_targets,
149 const SourceFile& file, 156 const SourceFile& file,
150 bool all_toolchains, 157 bool all_toolchains,
151 UniqueVector<const Target*>* matches) { 158 UniqueVector<const Target*>* matches) {
152 Label default_toolchain = setup->loader()->default_toolchain_label(); 159 Label default_toolchain = setup->loader()->default_toolchain_label();
153 for (const auto& target : all_targets) { 160 for (const auto& target : all_targets) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 "\n" 286 "\n"
280 " - Config label: The result will be which targets list the given\n" 287 " - Config label: The result will be which targets list the given\n"
281 " config in its \"configs\" or \"public_configs\" list.\n" 288 " config in its \"configs\" or \"public_configs\" list.\n"
282 "\n" 289 "\n"
283 " - Label pattern: The result will be which targets depend on any\n" 290 " - Label pattern: The result will be which targets depend on any\n"
284 " target matching the given pattern. Patterns will not match\n" 291 " target matching the given pattern. Patterns will not match\n"
285 " configs. These are not general regular expressions, see\n" 292 " configs. These are not general regular expressions, see\n"
286 " \"gn help label_pattern\" for details.\n" 293 " \"gn help label_pattern\" for details.\n"
287 "\n" 294 "\n"
288 " - File name: The result will be which targets list the given file in\n" 295 " - File name: The result will be which targets list the given file in\n"
289 " its \"inputs\", \"sources\", \"public\", or \"data\". Any input\n" 296 " its \"inputs\", \"sources\", \"public\", \"data\", or \"outputs\".\n"
290 " that does not contain wildcards and does not match a target or a\n" 297 " Any input that does not contain wildcards and does not match a\n"
291 " config will be treated as a file.\n" 298 " target or a config will be treated as a file.\n"
292 "\n" 299 "\n"
293 " - Response file: If the input starts with an \"@\", it will be\n" 300 " - Response file: If the input starts with an \"@\", it will be\n"
294 " interpreted as a path to a file containing a list of labels or\n" 301 " interpreted as a path to a file containing a list of labels or\n"
295 " file names, one per line. This allows us to handle long lists\n" 302 " file names, one per line. This allows us to handle long lists\n"
296 " of inputs without worrying about command line limits.\n" 303 " of inputs without worrying about command line limits.\n"
297 "\n" 304 "\n"
298 "Options\n" 305 "Options\n"
299 "\n" 306 "\n"
300 " --all\n" 307 " --all\n"
301 " When used without --tree, will recurse and display all unique\n" 308 " When used without --tree, will recurse and display all unique\n"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 .PrintToStdout(); 391 .PrintToStdout();
385 return 1; 392 return 1;
386 } 393 }
387 394
388 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 395 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
389 bool tree = cmdline->HasSwitch("tree"); 396 bool tree = cmdline->HasSwitch("tree");
390 bool all = cmdline->HasSwitch("all"); 397 bool all = cmdline->HasSwitch("all");
391 bool all_toolchains = cmdline->HasSwitch("all-toolchains"); 398 bool all_toolchains = cmdline->HasSwitch("all-toolchains");
392 399
393 Setup* setup = new Setup; 400 Setup* setup = new Setup;
394 setup->set_check_for_bad_items(false); 401 setup->build_settings().set_check_for_bad_items(false);
395 if (!setup->DoSetup(args[0], false) || !setup->Run()) 402 if (!setup->DoSetup(args[0], false) || !setup->Run())
396 return 1; 403 return 1;
397 404
398 // The inputs are everything but the first arg (which is the build dir). 405 // The inputs are everything but the first arg (which is the build dir).
399 std::vector<std::string> inputs; 406 std::vector<std::string> inputs;
400 for (size_t i = 1; i < args.size(); i++) { 407 for (size_t i = 1; i < args.size(); i++) {
401 if (args[i][0] == '@') { 408 if (args[i][0] == '@') {
402 // The argument is as a path to a response file. 409 // The argument is as a path to a response file.
403 std::string contents; 410 std::string contents;
404 std::vector<std::string> lines; 411 std::vector<std::string> lines;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 481
475 // If you ask for the references of a valid target, but that target has 482 // If you ask for the references of a valid target, but that target has
476 // nothing referencing it, we'll get here without having printed anything. 483 // nothing referencing it, we'll get here without having printed anything.
477 if (!quiet && cnt == 0) 484 if (!quiet && cnt == 0)
478 OutputString("Nothing references this.\n", DECORATION_YELLOW); 485 OutputString("Nothing references this.\n", DECORATION_YELLOW);
479 486
480 return 0; 487 return 0;
481 } 488 }
482 489
483 } // namespace commands 490 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_ls.cc ('k') | tools/gn/filesystem_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698