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

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

Issue 937003002: Enhance GN introspection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/label_pattern.h" 5 #include "tools/gn/label_pattern.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "tools/gn/err.h" 8 #include "tools/gn/err.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/value.h" 10 #include "tools/gn/value.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 type = RECURSIVE_DIRECTORY; 209 type = RECURSIVE_DIRECTORY;
210 } else { 210 } else {
211 // Everything else should be of the form "foo:*". 211 // Everything else should be of the form "foo:*".
212 type = DIRECTORY; 212 type = DIRECTORY;
213 } 213 }
214 214
215 // When we're doing wildcard matching, the name is always empty. 215 // When we're doing wildcard matching, the name is always empty.
216 return LabelPattern(type, dir, base::StringPiece(), toolchain_label); 216 return LabelPattern(type, dir, base::StringPiece(), toolchain_label);
217 } 217 }
218 218
219 bool LabelPattern::HasWildcard(const std::string& str) {
220 // Just look for a star. In the future, we may want to handle escaping or
221 // other types of patterns.
222 return str.find('*') != std::string::npos;
223 }
224
219 bool LabelPattern::Matches(const Label& label) const { 225 bool LabelPattern::Matches(const Label& label) const {
220 if (!toolchain_.is_null()) { 226 if (!toolchain_.is_null()) {
221 // Toolchain must match exactly. 227 // Toolchain must match exactly.
222 if (toolchain_.dir() != label.toolchain_dir() || 228 if (toolchain_.dir() != label.toolchain_dir() ||
223 toolchain_.name() != label.toolchain_name()) 229 toolchain_.name() != label.toolchain_name())
224 return false; 230 return false;
225 } 231 }
226 232
227 switch (type_) { 233 switch (type_) {
228 case MATCH: 234 case MATCH:
(...skipping 26 matching lines...) Expand all
255 break; 261 break;
256 } 262 }
257 263
258 if (!toolchain_.is_null()) { 264 if (!toolchain_.is_null()) {
259 result.push_back('('); 265 result.push_back('(');
260 result.append(toolchain_.GetUserVisibleName(false)); 266 result.append(toolchain_.GetUserVisibleName(false));
261 result.push_back(')'); 267 result.push_back(')');
262 } 268 }
263 return result; 269 return result;
264 } 270 }
OLDNEW
« tools/gn/commands.cc ('K') | « tools/gn/label_pattern.h ('k') | tools/gn/output_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698