diff options
Diffstat (limited to 'libbuild2/cc')
-rw-r--r-- | libbuild2/cc/common.cxx | 26 | ||||
-rw-r--r-- | libbuild2/cc/common.hxx | 3 | ||||
-rw-r--r-- | libbuild2/cc/pkgconfig.cxx | 15 |
3 files changed, 31 insertions, 13 deletions
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<dir_paths>& 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<string>& 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<dir_paths>&) 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<dir_paths> 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<name> to <name>.lib. // - l = move (name += ".lib"); + l = move (nm += ".lib"); } } } |