From f189e03a083df9538ef914943b2cf552ee663bbb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Oct 2019 09:35:46 +0200 Subject: Add support for specifying custom load prefix and version clean patterns --- libbuild2/bin/init.cxx | 19 ++++++++++++++----- libbuild2/cc/link-rule.cxx | 15 ++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/bin/init.cxx b/libbuild2/bin/init.cxx index db9db0e..68b5fb4 100644 --- a/libbuild2/bin/init.cxx +++ b/libbuild2/bin/init.cxx @@ -59,6 +59,9 @@ namespace build2 // auto& vp (rs.ctx.var_pool.rw (rs)); + const auto vis_tgt (variable_visibility::target); + const auto vis_prj (variable_visibility::project); + vp.insert ("config.bin.target", true); vp.insert ("config.bin.pattern", true); @@ -117,18 +120,24 @@ namespace build2 // // If unspecified, defaults to false for liba{} and to true for libu*{}. // - vp.insert ("bin.whole", false, variable_visibility::target); + vp.insert ("bin.whole", false, vis_tgt); vp.insert ("bin.exe.prefix"); vp.insert ("bin.exe.suffix"); vp.insert ("bin.lib.prefix"); vp.insert ("bin.lib.suffix"); - vp.insert ("bin.lib.load_suffix", - variable_visibility::project); + // The optional custom clean patterns should be just the pattern stem, + // without the library prefix/name or extension. For example, `-[A-Z]` + // instead of `libfoo-[A-Z].so`. Note that the custom version pattern is + // only used for platform-independent versions (for platforms-specific + // versions we can always derive the pattern automatically). + // + vp.insert ("bin.lib.load_suffix", vis_prj); + vp.insert ("bin.lib.load_suffix_pattern", vis_prj); - vp.insert> ("bin.lib.version", - variable_visibility::project); + vp.insert> ("bin.lib.version", vis_prj); + vp.insert ("bin.lib.version_pattern", vis_prj); return true; } diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index a9f798a..8a3b493 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -458,7 +458,9 @@ namespace build2 // a base for the version clean pattern. // cp_l = b; - if (append_sep (cp_l, ls)) + if (auto* p = cast_null (t["bin.lib.load_suffix_pattern"])) + cp_l += *p; + else if (append_sep (cp_l, ls)) cp_l += "[0-9]*"; else cp_l.clear (); // Non-digit load suffix (use custom clean pattern). @@ -485,14 +487,17 @@ namespace build2 // we have the load clean pattern, `foo-[0-9]*-[0-9]*.dll`). // cp_v = cp_l.empty () ? b : cp_l; - if (append_sep (cp_v, ver)) - { + + if (auto* p = cast_null (t["bin.lib.version_pattern"])) + cp_v += *p; + else if (append_sep (cp_v, ver)) cp_v += "[0-9]*"; - append_ext (cp_v); - } else cp_v.clear (); // Non-digit version (use custom clean pattern). + if (!cp_v.empty ()) + append_ext (cp_v); + b += ver; } -- cgit v1.1