aboutsummaryrefslogtreecommitdiff
path: root/build2/functions-path.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/functions-path.cxx')
-rw-r--r--build2/functions-path.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/build2/functions-path.cxx b/build2/functions-path.cxx
index e21609c..243f0d7 100644
--- a/build2/functions-path.cxx
+++ b/build2/functions-path.cxx
@@ -93,6 +93,30 @@ namespace build2
return r;
};
+ // canonicalize
+ //
+ f["canonicalize"] = [](path p) {p.canonicalize (); return p;};
+ f["canonicalize"] = [](dir_path p) {p.canonicalize (); return p;};
+
+ f["canonicalize"] = [](paths v) {for (auto& p: v) p.canonicalize (); return v;};
+ f["canonicalize"] = [](dir_paths v) {for (auto& p: v) p.canonicalize (); return v;};
+
+ f[".canonicalize"] = [](names ns)
+ {
+ // For each path decide based on the presence of a trailing slash
+ // whether it is a directory. Return as untyped list of (potentially
+ // mixed) paths.
+ //
+ for (name& n: ns)
+ {
+ if (n.directory ())
+ n.dir.canonicalize ();
+ else
+ n.value = convert<path> (move (n)).canonicalize ().string ();
+ }
+ return ns;
+ };
+
// normalize
//
f["normalize"] = [](path p) {p.normalize (); return p;};