From 1bb9cc99e8926825a2daae0f0d1e2c3d15d778a5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 24 Nov 2017 15:29:58 +0200 Subject: Fix few bugs in generated header path remapping logic --- build2/cc/compile.cxx | 17 +++++++++++------ build2/cli/target.cxx | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 1317fcb..65c1362 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -1549,7 +1549,7 @@ namespace build2 // // This is a nasty problem that doesn't seem to have a perfect solution // (except, perhaps, C++ modules). So what we are going to do is try to - // rectify the situation by detecting and automatically re-mapping such + // rectify the situation by detecting and automatically remapping such // mis-inclusions. It works as follows. // // First we will build a map of src/out pairs that were specified with @@ -1686,9 +1686,13 @@ namespace build2 { // Note that we don't normalize the paths since it would be // quite expensive and normally the pairs we are inerested in - // are already normalized (since usually specified as - // -I$src/out_*). + // are already normalized (since they are usually specified as + // -I$src/out_*). We just need to add a trailing directory + // separator if it's not already there. // + if (!dir_path::traits::is_separator (ds.back ())) + ds += dir_path::traits::directory_separator; + dir_path d (move (ds), dir_path::exact); // Move the buffer in. // Ignore invalid paths (buffer is not moved). @@ -1715,6 +1719,7 @@ namespace build2 // We've got a pair. // so_map.emplace (move (d), s->out_path () / p); + s = nullptr; // Taken. continue; } } @@ -2131,8 +2136,8 @@ namespace build2 // First try the whole file. Then just the directory. // - // @@ Has to be a separate map since the prefix can be - // the same as the file name. + // @@ Has to be a separate map since the prefix can be the same as + // the file name. // // auto i (pfx_map->find (f)); @@ -2216,7 +2221,7 @@ namespace build2 if (pt != nullptr) { path p (d / f.leaf ()); - l4 ([&]{trace << "re-mapping " << f << " to " << p;}); + l4 ([&]{trace << "remapping " << f << " to " << p;}); f = move (p); } } diff --git a/build2/cli/target.cxx b/build2/cli/target.cxx index c50c0b4..10aab5e 100644 --- a/build2/cli/target.cxx +++ b/build2/cli/target.cxx @@ -55,7 +55,7 @@ namespace build2 // this is to avoid searching for existing files in src_base if the // buildfile mentions some of them explicitly as prerequisites. // - // Also required for the src-out re-mapping logic. + // Also required for the src-out remapping logic. // targets.insert (d, o, n, trace); targets.insert (d, o, n, trace); -- cgit v1.1