X-Git-Url: http://git.tdb.fi/?p=builder.git;a=blobdiff_plain;f=source%2Fbinarypackage.cpp;h=679fb636132127ab39195a101e2ce93204277d2a;hp=94667c989dede480f3b36afbddb04108f84881cb;hb=21ca3e98081c0dc0430d8e5301591aa71ec4fca2;hpb=41fdd69eb3f7c28ba91be3699d89ba1c2328cfdf diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index 94667c9..679fb63 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -1,7 +1,9 @@ +#include #include #include #include "binarypackage.h" #include "builder.h" +#include "filetarget.h" using namespace std; using namespace Msp; @@ -91,15 +93,45 @@ void BinaryPackage::do_prepare() for(BuildInfo::PathList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) *i = base_path/ *i; } + + if(!static_binfo.libs.empty()) + { + BuildInfo::PathList combined_libpath = static_binfo.libpath; + combined_libpath.insert(combined_libpath.end(), export_binfo.libpath.begin(), export_binfo.libpath.end()); + + Target::Dependencies static_dep_libs; + for(BuildInfo::WordList::const_iterator i=static_binfo.libs.begin(); i!=static_binfo.libs.end(); ++i) + if(Target *lib = builder.get_vfs().find_library(*i, combined_libpath, BuildInfo::STATIC, system)) + static_dep_libs.push_back(lib); + + for(BuildInfo::WordList::const_iterator i=export_binfo.libs.begin(); i!=export_binfo.libs.end(); ++i) + if(Target *lib = builder.get_vfs().find_library(*i, export_binfo.libpath, BuildInfo::FORCE_STATIC, system)) + { + for(Target::Dependencies::const_iterator j=static_dep_libs.begin(); j!=static_dep_libs.end(); ++j) + lib->add_transitive_dependency(**j); + } + } } -BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, const vector &flags) +BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, const Flags &flags, const Flags &static_flags) { BinaryPackage *pkg = new BinaryPackage(builder, name); pkg->use_pkgconfig = true; - BuildInfo &binfo = pkg->export_binfo; - for(vector::const_iterator i=flags.begin(); i!=flags.end(); ++i) + process_flags(flags, pkg->export_binfo); + + Flags exclusive_static_flags; + for(Flags::const_iterator i=static_flags.begin(); i!=static_flags.end(); ++i) + if(find(flags.begin(), flags.end(), *i)==flags.end()) + exclusive_static_flags.push_back(*i); + process_flags(exclusive_static_flags, pkg->static_binfo); + + return pkg; +} + +void BinaryPackage::process_flags(const Flags &flags, BuildInfo &binfo) +{ + for(Flags::const_iterator i=flags.begin(); i!=flags.end(); ++i) { if(!i->compare(0, 2, "-I")) binfo.incpath.push_back(i->substr(2)); @@ -118,8 +150,6 @@ BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, c else if(*i=="-pthread") binfo.threads = true; } - - return pkg; }