| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Resolve the part of the path that's not the wildcard. | 176 // Resolve the part of the path that's not the wildcard. |
| 177 if (!path.empty()) { | 177 if (!path.empty()) { |
| 178 // The non-wildcard stuff better not have a wildcard. | 178 // The non-wildcard stuff better not have a wildcard. |
| 179 if (path.find('*') != base::StringPiece::npos) { | 179 if (path.find('*') != base::StringPiece::npos) { |
| 180 *err = Err(value, "Label patterns only support wildcard suffixes.", | 180 *err = Err(value, "Label patterns only support wildcard suffixes.", |
| 181 "The pattern contained a '*' that wasn't at the end."); | 181 "The pattern contained a '*' that wasn't at the end."); |
| 182 return LabelPattern(); | 182 return LabelPattern(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Resolve the non-wildcard stuff. | 185 // Resolve the non-wildcard stuff. |
| 186 dir = current_dir.ResolveRelativeDir(path); | 186 dir = current_dir.ResolveRelativeDir(value, path, err); |
| 187 if (dir.is_null()) { | 187 if (err->has_error()) |
| 188 *err = Err(value, "Label pattern didn't resolve to a dir.", | |
| 189 "The directory name \"" + path.as_string() + "\" didn't\n" | |
| 190 "resolve to a directory."); | |
| 191 return LabelPattern(); | 188 return LabelPattern(); |
| 192 } | |
| 193 } | 189 } |
| 194 | 190 |
| 195 // Resolve the name. At this point, we're doing wildcard matches so the | 191 // Resolve the name. At this point, we're doing wildcard matches so the |
| 196 // name should either be empty ("foo/*") or a wildcard ("foo:*"); | 192 // name should either be empty ("foo/*") or a wildcard ("foo:*"); |
| 197 if (colon != std::string::npos && name != "*") { | 193 if (colon != std::string::npos && name != "*") { |
| 198 *err = Err(value, "Invalid label pattern.", | 194 *err = Err(value, "Invalid label pattern.", |
| 199 "You seem to be using the wildcard more generally that is supported.\n" | 195 "You seem to be using the wildcard more generally that is supported.\n" |
| 200 "Did you mean \"foo:*\" to match everything in the file, or\n" | 196 "Did you mean \"foo:*\" to match everything in the file, or\n" |
| 201 "\"./*\" to recursively match everything in the currend subtree."); | 197 "\"./*\" to recursively match everything in the currend subtree."); |
| 202 return LabelPattern(); | 198 return LabelPattern(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 break; | 257 break; |
| 262 } | 258 } |
| 263 | 259 |
| 264 if (!toolchain_.is_null()) { | 260 if (!toolchain_.is_null()) { |
| 265 result.push_back('('); | 261 result.push_back('('); |
| 266 result.append(toolchain_.GetUserVisibleName(false)); | 262 result.append(toolchain_.GetUserVisibleName(false)); |
| 267 result.push_back(')'); | 263 result.push_back(')'); |
| 268 } | 264 } |
| 269 return result; | 265 return result; |
| 270 } | 266 } |
| OLD | NEW |