From a9cadecf15385f93ad3eb6b6b0bdeaafd741b0a7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 31 Jan 2020 15:34:13 +0200 Subject: Propagate installed library out (tag) when converting to name --- libbuild2/cc/common.cxx | 26 ++++++++++++++++++-------- libbuild2/cc/common.hxx | 3 ++- libbuild2/cc/pkgconfig.cxx | 15 +++++++++++---- 3 files changed, 31 insertions(+), 13 deletions(-) (limited to 'libbuild2/cc') diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx index e1a2385..1af64c8 100644 --- a/libbuild2/cc/common.cxx +++ b/libbuild2/cc/common.cxx @@ -299,8 +299,10 @@ namespace build2 if (ns == nullptr || ns->empty ()) return; - for (const name& n: *ns) + for (auto i (ns->begin ()), e (ns->end ()); i != e; ++i) { + const name& n (*i); + if (n.simple ()) { // This is something like -lpthread or shell32.lib so should be @@ -318,7 +320,13 @@ namespace build2 if (sysd == nullptr) find_sysd (); if (!li) find_linfo (); - const file& t (resolve_library (a, bs, n, *li, *sysd, usrd)); + const file& t ( + resolve_library (a, + bs, + n, + (n.pair ? (++i)->dir : dir_path ()), + *li, + *sysd, usrd)); if (proc_lib) { @@ -433,30 +441,32 @@ namespace build2 const file& common:: resolve_library (action a, const scope& s, - name n, + const name& cn, + const dir_path& out, linfo li, const dir_paths& sysd, optional& usrd) const { - if (n.type != "lib" && n.type != "liba" && n.type != "libs") - fail << "target name " << n << " is not a library"; + if (cn.type != "lib" && cn.type != "liba" && cn.type != "libs") + fail << "target name " << cn << " is not a library"; const target* xt (nullptr); - if (!n.qualified ()) + if (!cn.qualified ()) { // Search for an existing target with this name "as if" it was a // prerequisite. // - xt = search_existing (n, s); + xt = search_existing (cn, s, out); if (xt == nullptr) - fail << "unable to find library " << n; + fail << "unable to find library " << cn; } else { // This is import. // + name n (cn); auto rp (s.find_target_type (n, location ())); // Note: changes name. const target_type* tt (rp.first); optional& ext (rp.second); diff --git a/libbuild2/cc/common.hxx b/libbuild2/cc/common.hxx index 76c8cff..a17442a 100644 --- a/libbuild2/cc/common.hxx +++ b/libbuild2/cc/common.hxx @@ -290,7 +290,8 @@ namespace build2 const file& resolve_library (action, const scope&, - name, + const name&, + const dir_path&, linfo, const dir_paths&, optional&) const; diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx index 9d372e2..775b055 100644 --- a/libbuild2/cc/pkgconfig.cxx +++ b/libbuild2/cc/pkgconfig.cxx @@ -846,8 +846,9 @@ namespace build2 bool all (true); optional usrd; // Populate lazily. - for (name& n: libs) + for (auto i (libs.begin ()); i != libs.end (); ++i) { + name& n (*i); string& l (n.value); // These ones are common/standard/POSIX. @@ -913,10 +914,10 @@ namespace build2 // resolve_library(). // dir_path out; - string name (l, 2); // Sans -l. + string nm (l, 2); // Sans -l. prerequisite_key pk { - nullopt, {&lib::static_type, &out, &out, &name, nullopt}, &s}; + nullopt, {&lib::static_type, &out, &out, &nm, nullopt}, &s}; if (const target* lt = search_library (a, top_sysd, usrd, pk)) { @@ -927,6 +928,12 @@ namespace build2 n.type = lib::static_type.name; n.value = lt->name; + if (!lt->out.empty ()) + { + n.pair = true; + i = libs.insert (i + 1, name (lt->out)); + } + if (ps != nullptr) ps->push_back (prerequisite (*lt)); } @@ -940,7 +947,7 @@ namespace build2 { // Translate -l to .lib. // - l = move (name += ".lib"); + l = move (nm += ".lib"); } } } -- cgit v1.1