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

Unified Diff: tools/gn/label.cc

Issue 857163002: Absolute path fixes for gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve error message 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/function_get_path_info_unittest.cc ('k') | tools/gn/label_pattern.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/label.cc
diff --git a/tools/gn/label.cc b/tools/gn/label.cc
index 095128d81e2014856e9bee4d4e45ebd509f0c162..89cd3356c1bc302b64d9389a18f1f86ecc5537f4 100644
--- a/tools/gn/label.cc
+++ b/tools/gn/label.cc
@@ -5,7 +5,9 @@
#include "tools/gn/label.h"
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "tools/gn/err.h"
+#include "tools/gn/filesystem_utils.h"
#include "tools/gn/parse_tree.h"
#include "tools/gn/value.h"
@@ -93,8 +95,23 @@ bool Resolve(const SourceDir& current_dir,
Err* err) {
// To workaround the problem that StringPiece operator[] doesn't return a ref.
const char* input_str = input.data();
-
- size_t path_separator = input.find_first_of(":(");
+ size_t offset = 0;
+#if defined(OS_WIN)
+ if (IsPathAbsolute(input)) {
+ if (input[0] != '/') {
+ *err = Err(original_value, "Bad absolute path.",
+ "Absolute paths must be of the form /C:\\ but this is \"" +
+ input.as_string() + "\".");
+ return false;
+ }
+ if (input.size() > 3 && input[2] == ':' && IsSlash(input[3]) &&
+ IsAsciiAlpha(input[1])) {
+ // Skip over the drive letter colon.
+ offset = 3;
+ }
+ }
+#endif
+ size_t path_separator = input.find_first_of(":(", offset);
base::StringPiece location_piece;
base::StringPiece name_piece;
base::StringPiece toolchain_piece;
« no previous file with comments | « tools/gn/function_get_path_info_unittest.cc ('k') | tools/gn/label_pattern.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698