From 7a96e3b0a4bb573bb26ca8ff93b97900bdb486b3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Apr 2021 14:59:42 +0200 Subject: Add install directory substitution in addition to --- libbuild2/install/init.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'libbuild2/install') diff --git a/libbuild2/install/init.cxx b/libbuild2/install/init.cxx index 74e9301..14045e1 100644 --- a/libbuild2/install/init.cxx +++ b/libbuild2/install/init.cxx @@ -52,16 +52,31 @@ namespace build2 // Note: watch out for the small std::function optimization. // - auto subst = [prv, &rs] (const string& var, string& r) + struct data { - if (var == "project") + const dir_path* prv; + const dir_path& val; + const variable& var; + } d {prv, val, var}; + + auto subst = [&d, &rs] (const string& n, string& r) + { + if (n == "project") { r += project (rs).string (); } - else if (var == "private") + else if (n == "version") + { + if (const auto* v = cast_null (rs.vars[rs.ctx.var_version])) + r += *v; + else + fail << "no version variable in project " << project (rs) << + info << "required in " << d.var << " value '" << d.val << "'"; + } + else if (n == "private") { - if (prv != nullptr && !prv->empty ()) - r += prv->string (); + if (d.prv != nullptr && !d.prv->empty ()) + r += d.prv->string (); } else return false; -- cgit v1.1