diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-08-04 06:20:42 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-08-04 06:20:42 +0200 |
commit | e6bdc9158d1951e6c29a024568c2d5a285d1bd65 (patch) | |
tree | 3746810271b103bc9c0d819435b3538b195003b7 | |
parent | 936f511c53ec79d507a0993950f913ccf8b5e30d (diff) |
Split liba{} dependencies into Libs and Libs.private
This way we can distinguish between interface and implementation dependencies
even if we have no shared variant.
-rw-r--r-- | build2/cc/pkgconfig.cxx | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx index ce72132..b83ad66 100644 --- a/build2/cc/pkgconfig.cxx +++ b/build2/cc/pkgconfig.cxx @@ -575,6 +575,13 @@ namespace build2 if (ap.empty () && sp.empty ()) return false; + // First sort out the interface dependencies (which we are setting on + // lib{}). If we have the shared .pc variant, then we use that. + // Otherwise -- static but extract without the --static option (see also + // the saving logic). + // + parse_libs (lt, sp.empty () ? sp : ap, false); + if (at != nullptr && !ap.empty ()) { parse_cflags (*at, ap, true); @@ -582,10 +589,7 @@ namespace build2 } if (st != nullptr && !sp.empty ()) - { parse_cflags (*st, sp, false); - parse_libs (lt, sp, false); // Note: setting on lib{} (interface). - } // For now we assume static and shared variants export the same set of // modules. While technically possible, having a different set will @@ -755,23 +759,31 @@ namespace build2 // Libs. // + // While we generate split shared/static .pc files, in case of static + // we still want to sort things out into Libs/Libs.private. This is + // necessary to distinguish between interface and implementation + // dependencies if we don't have the shared variant (see the load + // logic for details). + // + //@@ TODO: would be nice to weed out duplicates. But is it always + // safe? Think linking archives: will have to keep duplicates in + // the second position, not first. Gets even trickier with + // Libs.private split. + // os << "Libs:"; os << " -L" << escape (ld.string ()); // Now process ourselves as if we were being linked to something (so // pretty similar to link::append_libraries()). // - auto imp = [] (const file&, bool la) {return la;}; + bool priv (false); + auto imp = [&priv] (const file&, bool la) {return priv && la;}; auto lib = [&os, &save_library] (const file* l, const string& p, lflags, bool) { - //@@ TODO: would be nice to weed out duplicates. But is it always - // safe? Think linking archives: will have to keep duplicates in - // the second position, not first. - if (l != nullptr) { if (l->is_a<libs> () || l->is_a<liba> ()) // See through libux. @@ -786,6 +798,7 @@ namespace build2 bool, bool) { //@@ TODO: should we filter -L similar to -I? + //@@ TODO: how will the Libs/Libs.private work? //@@ TODO: remember to use escape() /* @@ -805,18 +818,27 @@ namespace build2 */ }; - process_libraries ( - act, - bs, - linfo {otype::e, la ? lorder::a_s : lorder::s_a}, // System-default. - sys_lib_dirs, - l, la, - 0, // Link flags. - imp, lib, opt, - true); + // Pretend we are linking an executable using what would be normal, + // system-default link order. + // + linfo li {otype::e, la ? lorder::a_s : lorder::s_a}; + process_libraries (act, bs, li, sys_lib_dirs, + l, la, 0, // Link flags. + imp, lib, opt, true); os << endl; + if (la) + { + os << "Libs.private:"; + + priv = true; + process_libraries (act, bs, li, sys_lib_dirs, + l, la, 0, // Link flags. + imp, lib, opt, false); + os << endl; + } + // If we have modules, list them in the modules variable. This code // is pretty similar to compiler::search_modules(). // |