From 864d84abcf1579b81f54d8d3f79520137d81f629 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 3 Dec 2020 14:33:25 +0200 Subject: Add ability to get absolute library paths from ${c,cxx}.lib_libs() --- libbuild2/cc/functions.cxx | 9 +++++++-- libbuild2/cc/link-rule.cxx | 13 +++++++++---- libbuild2/cc/link-rule.hxx | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/cc/functions.cxx b/libbuild2/cc/functions.cxx index 78ee212..98f7f97 100644 --- a/libbuild2/cc/functions.cxx +++ b/libbuild2/cc/functions.cxx @@ -175,7 +175,9 @@ namespace build2 // // The following flags are supported: // - // whole - link the specified libraries in the whole archive mode + // whole - link the specified libraries in the whole archive mode + // + // absolute - return absolute paths to the libraries // // If the last argument is false, then do not return the specified // libraries themselves. @@ -197,6 +199,7 @@ namespace build2 action a, const file& l, bool la, linfo li) { lflags lf (0); + bool rel (true); if (vs.size () > 2) { for (const name& f: vs[2].as ()) @@ -205,6 +208,8 @@ namespace build2 if (s == "whole") lf |= lflag_whole; + else if (s == "absolute") + rel = false; else fail << "invalid flag '" << s << "'"; } @@ -214,7 +219,7 @@ namespace build2 m.append_libraries (*static_cast (ls), r, bs, - a, l, la, lf, li, self); + a, l, la, lf, li, self, rel); }}); // $.lib_rpaths(, [, [, ]]) diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 8175489..dea5879 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -1492,7 +1492,7 @@ namespace build2 append_libraries (appended_libraries& ls, strings& args, const scope& bs, action a, const file& l, bool la, lflags lf, linfo li, - bool self) const + bool self, bool rel) const { struct data { @@ -1501,8 +1501,9 @@ namespace build2 const file& l; action a; linfo li; + bool rel; compile_target_types tts; - } d {ls, args, l, a, li, compile_types (li.type)}; + } d {ls, args, l, a, li, rel, compile_types (li.type)}; auto imp = [] (const file&, bool la) { @@ -1637,7 +1638,9 @@ namespace build2 // if (const file* f = pt->is_a ()) { - string p (relative (f->path ()).string ()); + const string& p (d.rel + ? relative (f->path ()).string () + : f->path ().string ()); if (find (d.args.begin (), d.args.end (), p) == d.args.end ()) d.args.push_back (move (p)); } @@ -1661,7 +1664,9 @@ namespace build2 l = li; } - string p (relative (l->path ()).string ()); + string p (d.rel + ? relative (l->path ()).string () + : l->path ().string ()); if (f & lflag_whole) { diff --git a/libbuild2/cc/link-rule.hxx b/libbuild2/cc/link-rule.hxx index b192914..6d0649c 100644 --- a/libbuild2/cc/link-rule.hxx +++ b/libbuild2/cc/link-rule.hxx @@ -111,7 +111,8 @@ namespace build2 void append_libraries (appended_libraries&, strings&, const scope&, action, - const file&, bool, lflags, linfo, bool = true) const; + const file&, bool, lflags, linfo, + bool = true, bool = true) const; void append_libraries (sha256&, bool&, timestamp, -- cgit v1.1