aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-06-07 09:43:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-06-07 09:43:21 +0200
commite6bb0d21f1865a389b82296823cf2ea555580a92 (patch)
tree15db9398743d83fb4f7e5dd1fa772c5c8a647334 /build2
parentdaa35c9e4b592f055b42e482fe1398527cfdf90b (diff)
Complete and normalize paths in cxx.importable_headers
Also add more header unit include/import tests.
Diffstat (limited to 'build2')
-rw-r--r--build2/cc/module.cxx59
1 files changed, 37 insertions, 22 deletions
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index 14d3ceb..e06ddb8 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -530,40 +530,55 @@ namespace build2
if (ih != nullptr && !ih->empty ())
{
// Translate <>-style header names to absolute paths using the
- // compiler's include search paths.
+ // compiler's include search paths. Otherwise complete and normalize
+ // since when searching in this list we always use the absolute and
+ // normalized header target path.
//
for (string& h: *ih)
{
- if (h.empty () || h.front () != '<' || h.back () != '>')
+ if (h.empty ())
continue;
- h.pop_back ();
- h.erase (0, 1);
-
- path f; // Reuse the buffer.
- bool r (false);
- for (const dir_path& d: sys_inc_dirs)
+ path f;
+ if (h.front () == '<' && h.back () == '>')
{
- if ((r = file_exists ((f = d, f /= h),
- true /* follow_symlinks */,
- true /* ignore_errors */)))
+ h.pop_back ();
+ h.erase (0, 1);
+
+ for (const dir_path& d: sys_inc_dirs)
{
- h = move (f.normalize ()).string ();
- break;
+ if (file_exists ((f = d, f /= h),
+ true /* follow_symlinks */,
+ true /* ignore_errors */))
+ goto found;
}
- }
- // What should we do if not found? While we can fail, this could
- // be too drastic if, for example, the header is "optional" and
- // may or may not be present/used. So for now let's restore the
- // original form to aid debugging (it can't possibly match any
- // absolute path).
- //
- if (!r)
- {
+ // What should we do if not found? While we can fail, this could
+ // be too drastic if, for example, the header is "optional" and
+ // may or may not be present/used. So for now let's restore the
+ // original form to aid debugging (it can't possibly match any
+ // absolute path).
+ //
h.insert (0, 1, '<');
h.push_back ('>');
+ continue;
+
+ found:
+ ; // Fall through.
}
+ else
+ {
+ f = path (move (h));
+
+ if (f.relative ())
+ f.complete ();
+ }
+
+ // @@ MODHDR: should we use the more elaborate but robust
+ // normalize/realize scheme so the we get the same
+ // path? Feels right.
+ f.normalize ();
+ h = move (f).string ();
}
sort (ih->begin (), ih->end ());