- 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 Flags &flags, const Flags &static_flags)
-{
- BinaryPackage *pkg = new BinaryPackage(builder, name);
- pkg->use_pkgconfig = true;
-
- 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));
- else if(!i->compare(0, 2, "-D"))
- {
- string::size_type equals = i->find('=');
- if(equals!=string::npos)
- binfo.defines[i->substr(2, equals-2)] = i->substr(equals+1);
- else
- binfo.defines[i->substr(2)] = string();
- }
- else if(!i->compare(0, 2, "-L"))
- binfo.libpath.push_back(i->substr(2));
- else if(!i->compare(0, 2, "-l"))
- binfo.libs.push_back(i->substr(2));
- else if(*i=="-pthread")
- binfo.threads = true;
+ for(const string &l: export_binfo.libs)
+ if(Target *lib = builder.get_vfs().find_library(l, export_binfo.libpath, BuildInfo::FORCE_STATIC, system))
+ if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(lib))
+ {
+ for(const string &s: static_binfo.libs)
+ stlib->add_required_library(s);
+ for(const FS::Path &p: combined_libpath)
+ stlib->add_library_path(p);
+ }