]> git.tdb.fi Git - builder.git/blobdiff - source/binarypackage.cpp
Move package management to a separate class
[builder.git] / source / binarypackage.cpp
index 8cfc87404343cf4704e5dad4c4734e99f70a1a6e..8c3571d103ac4fb9cc955e7178d3a8b745d26d95 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of builder
-Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <msp/io/print.h>
 #include <msp/strings/utils.h>
 #include "binarypackage.h"
@@ -17,44 +10,49 @@ 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)
+BinaryPackage *BinaryPackage::from_flags(Builder &builder, const std::string &name, const vector<string> &flags)
 {
-       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<string> flags=split(info);
        for(vector<string>::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;