X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinarypackage.cpp;h=514481f0066c56a3febb253a81708d3ff51c16da;hb=b067981c0da0c1a4616ed175d0ce8ac5564cbdbf;hp=c2c18867018abc32d8dd9f81c2e53e38c0d18fea;hpb=654de39b62a9a58fd8e1b5a557361d628345788b;p=builder.git diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index c2c1886..514481f 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -1,10 +1,4 @@ -/* $Id$ - -This file is part of builder -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include #include "binarypackage.h" #include "builder.h" @@ -16,58 +10,49 @@ BinaryPackage::BinaryPackage(Builder &b, const string &n): Package(b, n), need_path(false) { - use_pkgconfig=false; + use_pkgconfig = false; } -/** -Sets the path where the package files were installed. This is only useful if -the package doesn't use pkg-config. -*/ -void BinaryPackage::set_path(const Msp::Path::Path &p) +void BinaryPackage::set_path(const FS::Path &p) { - path=builder.get_cwd()/p; + path = builder.get_cwd()/p; } void BinaryPackage::create_build_info() { - for(StringList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i) - if((*i)[0]=='@') - *i=(path/i->substr(1)).str(); + for(BuildInfo::PathList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i) + if((*i)[0]=="@") + *i = path/i->subpath(1); - for(StringList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) - if((*i)[0]=='@') - *i=(path/i->substr(1)).str(); + for(BuildInfo::PathList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) + if((*i)[0]=="@") + *i = path/i->subpath(1); } -BinaryPackage *BinaryPackage::from_pkgconfig(Builder &builder, const string &name) +BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, const vector &flags) { - list argv; - argv.push_back("pkg-config"); - argv.push_back("--silence-errors"); - argv.push_back("--cflags"); - argv.push_back("--libs"); - argv.push_back(name); - string info=run_command(argv); - - if(info.empty()) - return 0; - - - BinaryPackage *pkg=new BinaryPackage(builder, name); - pkg->use_pkgconfig=true; - BuildInfo &binfo=pkg->export_binfo; + BinaryPackage *pkg = new BinaryPackage(builder, name); + pkg->use_pkgconfig = true; + BuildInfo &binfo = pkg->export_binfo; - vector flags=split(info); for(vector::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")) - binfo.defines.push_back(i->substr(2)); + { + 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; } return pkg; @@ -75,7 +60,7 @@ BinaryPackage *BinaryPackage::from_pkgconfig(Builder &builder, const string &nam BinaryPackage::Loader::Loader(BinaryPackage &p): - Package::Loader(p) + DataFile::DerivedObjectLoader(p) { add("need_path", &BinaryPackage::need_path); add("build_info", &Loader::build_info); @@ -83,5 +68,5 @@ BinaryPackage::Loader::Loader(BinaryPackage &p): void BinaryPackage::Loader::build_info() { - load_sub(static_cast(pkg).export_binfo); + load_sub(obj.export_binfo); }