From 988fd0eec5d88bf6534fb1f645777350c20d4723 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 30 Jul 2016 11:41:48 +0200 Subject: Actualize project root directories This solves the problem of changing path spelling on platforms with case- insensitive filesystems. For example, you may build a project in the current working directory without specifying any paths. This means the current working directory will be used as the project's root. On Windows this could be C:\x. Now you are building another project that imports the above project and you specify config.import.x variable pointing to the above build. But you are lazy to type capital C so you spell it as config.import.x=c:\x. What happens now is the value from config.import.x is used as the project root. And now it is a different spelling compared to your original build. This is not a problem when the build system itself is concerned -- it is smart enough to use case-insensitive comparison. However, we often use roots to derive other things, say, -I options that we pass to compilers. And these options are normally no longer treated as (case-insensitive) paths. If they are hashed and the result stored in depdb, then we end up with rebuilds that are triggered by changes from C:\ to c:\. --- build2/b.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'build2/b.cxx') diff --git a/build2/b.cxx b/build2/b.cxx index b2ba2c1..4efbdd2 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -358,7 +358,9 @@ main (int argc, char* argv[]) if (out_base.relative ()) out_base = work / out_base; - out_base.normalize (); + // This directory came from the command line so actualize it. + // + out_base.normalize (true); // The order in which we determine the roots depends on whether // src_base was specified explicitly. There will also be a few @@ -384,7 +386,9 @@ main (int argc, char* argv[]) if (src_base.relative ()) src_base = work / src_base; - src_base.normalize (); + // Also came from the command line, so actualize. + // + src_base.normalize (true); // If the src_base was explicitly specified, search for src_root. // @@ -427,7 +431,7 @@ main (int argc, char* argv[]) // if (out_root.empty ()) { - src_root = find_src_root (work); + src_root = find_src_root (work); // Work is actualized. if (!src_root.empty ()) { @@ -512,7 +516,7 @@ main (int argc, char* argv[]) // If not, then assume we are running from src_base // and calculate src_root based on out_root/out_base. // - src_base = work; + src_base = work; // Work is actualized. src_root = src_base.directory (out_base.leaf (out_root)); guessing = true; } -- cgit v1.1