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

Unified Diff: tools/gn/source_dir.cc

Issue 857163002: Absolute path fixes for gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows fixes and additional tests Created 5 years, 11 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
Index: tools/gn/source_dir.cc
diff --git a/tools/gn/source_dir.cc b/tools/gn/source_dir.cc
index 9f6c74575b186b8a0e625d403a699610118b6cb3..8798b4d8dcc946191585f080f2e1213921a5a18e 100644
--- a/tools/gn/source_dir.cc
+++ b/tools/gn/source_dir.cc
@@ -82,8 +82,15 @@ SourceFile SourceDir::ResolveRelativeFile(
p.as_string()).value());
NormalizePath(&absolute);
if (!MakeAbsolutePathRelativeIfPossible(source_root, absolute,
- &ret.value_))
- ret.value_ = absolute;
+ &ret.value_)) {
+#if defined(OS_WIN)
+ // On Windows we'll accept "C:\foo" as an absolute path, which we want
+ // to convert to "/C:..." here.
+ if (absolute[0] != '/')
+ ret.value_ = "/";
+#endif
+ ret.value_.append(absolute.data(), absolute.size());
+ }
return ret;
}
@@ -134,8 +141,14 @@ SourceDir SourceDir::ResolveRelativeDir(
FilePathToUTF8(Resolve(UTF8ToFilePath(source_root)).AppendASCII(
p.as_string()).value());
NormalizePath(&absolute);
- if (!MakeAbsolutePathRelativeIfPossible(source_root, absolute, &ret.value_))
- ret.value_ = absolute;
+ if (!MakeAbsolutePathRelativeIfPossible(source_root, absolute,
+ &ret.value_)) {
+#if defined(OS_WIN)
+ if (absolute[0] != '/') // See the file case for why we do this check.
+ ret.value_ = "/";
+#endif
+ ret.value_.append(absolute.data(), absolute.size());
+ }
if (!EndsWithSlash(ret.value_))
ret.value_.push_back('/');
return ret;

Powered by Google App Engine
This is Rietveld 408576698