X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinarypackage.cpp;h=bc3e5c929ec41af7d6a5b515f2ac2a17501c50b1;hb=4facd021514ab372c23b1b132d6b4b62baa4efbf;hp=4589e2440337e7a5095bea223f5b1004be7a8abc;hpb=5622fc20f0be8bff0938d24f6f45d3ab384288ca;p=builder.git diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index 4589e24..bc3e5c9 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of builder -Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include "binarypackage.h" @@ -17,56 +10,52 @@ BinaryPackage::BinaryPackage(Builder &b, const string &n): Package(b, n), need_path(false) { - use_pkgconfig=false; + use_pkgconfig = false; } -void BinaryPackage::set_path(const Msp::FS::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(); + *i = (path/i->substr(1)).str(); for(StringList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) if((*i)[0]=='@') - *i=(path/i->substr(1)).str(); + *i = (path/i->substr(1)).str(); } BinaryPackage *BinaryPackage::from_pkgconfig(Builder &builder, const string &name) { - list argv; - argv.push_back("pkg-config"); - argv.push_back("--silence-errors"); - argv.push_back("--cflags"); - argv.push_back("--libs"); - argv.push_back(name); - if(builder.get_verbose()>=4) - IO::print("Running %s\n", join(argv.begin(), argv.end())); - string info=run_command(argv); - - if(info.empty()) - return 0; - + string info = builder.run_pkgconfig(name, "flags"); - 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); + 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;