From 3a8972b42f75e10e9a833bba58d65009e7bed7f3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Aug 2016 15:41:54 +0200 Subject: Handle *.export.libs, distinguish interface and implementation dependencies A library dependency on another libraries is either "interface" or "implementation". If it is interface, then everyone who links to this library should also link to the interface dependency, explicitly. A good example of an interface dependency is a library API that is called in inline functions. Interface dependencies of a library should be explicitly listed in the *.export.libs (where we can also list target names). So the typical usage will be along these lines: import int_libs = libfoo%lib{foo} import int_libs += ... import imp_libs = libbar%lib{bar} import imp_libs += ... lib{baz}: ... $int_libs $imp_libs lib{baz}: cxx.export.libs = $int_libs --- build2/cc/msvc.cxx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'build2/cc/msvc.cxx') diff --git a/build2/cc/msvc.cxx b/build2/cc/msvc.cxx index 84f5853..d088c5b 100644 --- a/build2/cc/msvc.cxx +++ b/build2/cc/msvc.cxx @@ -219,7 +219,7 @@ namespace build2 msvc_search_library (const char* mod, const process_path& ld, const dir_path& d, - prerequisite& p, + const prerequisite_key& p, otype lt, const char* pfx, const char* sfx) @@ -228,6 +228,9 @@ namespace build2 // tracer trace (mod, "msvc_search_library"); + const string* ext (p.tk.ext); + const string& name (*p.tk.name); + // Assemble the file path. // path f (d); @@ -235,18 +238,18 @@ namespace build2 if (*pfx != '\0') { f /= pfx; - f += p.name; + f += name; } else - f /= p.name; + f /= name; if (*sfx != '\0') f += sfx; const string& e ( - p.ext == nullptr || p.is_a () // Only for liba/libs. + ext == nullptr || p.is_a () // Only for liba/libs. ? extension_pool.find ("lib") - : *p.ext); + : *ext); if (!e.empty ()) { @@ -262,7 +265,7 @@ namespace build2 { // Enter the target. // - T& t (targets.insert (d, dir_path (), p.name, &e, trace)); + T& t (targets.insert (d, dir_path (), name, &e, trace)); if (t.path ().empty ()) t.path (move (f)); @@ -277,7 +280,7 @@ namespace build2 liba* link:: msvc_search_static (const process_path& ld, const dir_path& d, - prerequisite& p) const + const prerequisite_key& p) const { liba* r (nullptr); @@ -304,7 +307,7 @@ namespace build2 libs* link:: msvc_search_shared (const process_path& ld, const dir_path& d, - prerequisite& p) const + const prerequisite_key& p) const { tracer trace (x, "link::msvc_search_shared"); @@ -316,7 +319,8 @@ namespace build2 if (libi* i = msvc_search_library (x, ld, d, p, otype::s, pf, sf)) { - r = &targets.insert (d, dir_path (), p.name, nullptr, trace); + r = &targets.insert ( + d, dir_path (), *p.tk.name, nullptr, trace); if (r->member == nullptr) { -- cgit v1.1