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

Unified Diff: tools/gn/function_rebase_path.cc

Issue 2346913003: Make rebase_path("//foo", "//foo") resolve to "." (not "../foo") (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | tools/gn/function_rebase_path_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/function_rebase_path.cc
diff --git a/tools/gn/function_rebase_path.cc b/tools/gn/function_rebase_path.cc
index ef5ef40f984046cab216970f62b9eaaac27ea21c..f3b14bb0dd75de2e4b17a03158127f120e31b603 100644
--- a/tools/gn/function_rebase_path.cc
+++ b/tools/gn/function_rebase_path.cc
@@ -98,13 +98,23 @@ Value ConvertOnePath(const Scope* scope,
scope->settings()->build_settings()->root_path_utf8());
MakeSlashEndingMatchInput(string_value, &result.string_value());
} else {
- result.string_value() = RebasePath(
+ SourceFile resolved_file =
from_dir.ResolveRelativeFile(value, err,
- scope->settings()->build_settings()->root_path_utf8()).value(),
- to_dir,
- scope->settings()->build_settings()->root_path_utf8());
+ scope->settings()->build_settings()->root_path_utf8());
if (err->has_error())
return Value();
+ // Special case:
+ // rebase_path("//foo", "//bar") ==> "../foo"
+ // rebase_path("//foo", "//foo") ==> "." and not "../foo"
+ if (resolved_file.value() ==
+ to_dir.value().substr(0, to_dir.value().size() - 1)) {
+ result.string_value() = ".";
+ } else {
+ result.string_value() = RebasePath(
+ resolved_file.value(),
+ to_dir,
+ scope->settings()->build_settings()->root_path_utf8());
+ }
}
return result;
« no previous file with comments | « no previous file | tools/gn/function_rebase_path_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698