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

Unified Diff: tools/gn/setup.cc

Issue 1708513002: GN: Normalize the build directory path (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/setup.cc
diff --git a/tools/gn/setup.cc b/tools/gn/setup.cc
index 79814e602fe7a2f14a152ce9dae5d3d361d5f2d7..831e4e4db3e33cf54351849f3a4acac28e6649d6 100644
--- a/tools/gn/setup.cc
+++ b/tools/gn/setup.cc
@@ -521,10 +521,23 @@ bool Setup::FillSourceDir(const base::CommandLine& cmdline) {
}
bool Setup::FillBuildDir(const std::string& build_dir, bool require_exists) {
+#if defined(OS_POSIX)
+ // Expand all ./, ../, and symbolic links in build_dir.
+ char realpath_buf[PATH_MAX];
+ if (!realpath(build_dir.c_str(), realpath_buf)) {
+ Err(Location(), "Can't normalize the build directory path.",
+ strerror(errno)) .PrintToStdout();
+ return false;
+ }
+ const std::string build_dir_realpath = realpath_buf;
+#else
+ const std::string& build_dir_realpath = build_dir;
+#endif
+
Err err;
SourceDir resolved =
SourceDirForCurrentDirectory(build_settings_.root_path()).
- ResolveRelativeDir(Value(nullptr, build_dir), &err,
+ ResolveRelativeDir(Value(nullptr, build_dir_realpath), &err,
build_settings_.root_path_utf8());
if (err.has_error()) {
err.PrintToStdout();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698