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

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: 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/label_unittest.cc ('k') | tools/gn/substitution_writer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « tools/gn/label_unittest.cc ('k') | tools/gn/substitution_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698