| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |