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

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

Issue 1155713006: GN: Make file/dir resolving return errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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_format.cc ('k') | tools/gn/filesystem_utils_unittest.cc » ('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 "tools/gn/builder.h" 8 #include "tools/gn/builder.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/item.h" 10 #include "tools/gn/item.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return true; 83 return true;
84 } 84 }
85 85
86 // Try to figure out what this thing is. 86 // Try to figure out what this thing is.
87 Err err; 87 Err err;
88 Label label = Label::Resolve(current_dir, 88 Label label = Label::Resolve(current_dir,
89 setup->loader()->default_toolchain_label(), 89 setup->loader()->default_toolchain_label(),
90 Value(nullptr, input), &err); 90 Value(nullptr, input), &err);
91 if (err.has_error()) { 91 if (err.has_error()) {
92 // Not a valid label, assume this must be a file. 92 // Not a valid label, assume this must be a file.
93 err = Err();
93 file_matches->push_back(current_dir.ResolveRelativeFile( 94 file_matches->push_back(current_dir.ResolveRelativeFile(
94 input, setup->build_settings().root_path_utf8())); 95 Value(nullptr, input), &err, setup->build_settings().root_path_utf8()));
96 if (err.has_error()) {
97 err.PrintToStdout();
98 return false;
99 }
95 return true; 100 return true;
96 } 101 }
97 102
98 const Item* item = setup->builder()->GetItem(label); 103 const Item* item = setup->builder()->GetItem(label);
99 if (item) { 104 if (item) {
100 if (const Config* as_config = item->AsConfig()) 105 if (const Config* as_config = item->AsConfig())
101 config_matches->push_back(as_config); 106 config_matches->push_back(as_config);
102 else if (const Target* as_target = item->AsTarget()) 107 else if (const Target* as_target = item->AsTarget())
103 target_matches->push_back(as_target); 108 target_matches->push_back(as_target);
104 else if (const Toolchain* as_toolchain = item->AsToolchain()) 109 else if (const Toolchain* as_toolchain = item->AsToolchain())
105 toolchain_matches->push_back(as_toolchain); 110 toolchain_matches->push_back(as_toolchain);
106 } else { 111 } else {
107 // Not an item, assume this must be a file. 112 // Not an item, assume this must be a file.
108 file_matches->push_back(current_dir.ResolveRelativeFile( 113 file_matches->push_back(current_dir.ResolveRelativeFile(
109 input, setup->build_settings().root_path_utf8())); 114 Value(nullptr, input), &err, setup->build_settings().root_path_utf8()));
115 if (err.has_error()) {
116 err.PrintToStdout();
117 return false;
118 }
110 } 119 }
111 120
112 return true; 121 return true;
113 } 122 }
114 123
115 enum TargetPrintingMode { 124 enum TargetPrintingMode {
116 TARGET_PRINT_BUILDFILE, 125 TARGET_PRINT_BUILDFILE,
117 TARGET_PRINT_LABEL, 126 TARGET_PRINT_LABEL,
118 TARGET_PRINT_OUTPUT, 127 TARGET_PRINT_OUTPUT,
119 }; 128 };
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 490 }
482 } 491 }
483 492
484 void FilterAndPrintTargetSet(bool indent, 493 void FilterAndPrintTargetSet(bool indent,
485 const std::set<const Target*>& targets) { 494 const std::set<const Target*>& targets) {
486 std::vector<const Target*> target_vector(targets.begin(), targets.end()); 495 std::vector<const Target*> target_vector(targets.begin(), targets.end());
487 FilterAndPrintTargets(indent, &target_vector); 496 FilterAndPrintTargets(indent, &target_vector);
488 } 497 }
489 498
490 } // namespace commands 499 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_format.cc ('k') | tools/gn/filesystem_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698