3 This file is part of builder
4 Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/io/print.h>
9 #include <msp/strings/utils.h>
10 #include "binarypackage.h"
16 BinaryPackage::BinaryPackage(Builder &b, const string &n):
20 use_pkgconfig = false;
23 void BinaryPackage::set_path(const FS::Path &p)
25 path = builder.get_cwd()/p;
28 void BinaryPackage::create_build_info()
30 for(StringList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i)
32 *i = (path/i->substr(1)).str();
34 for(StringList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i)
36 *i = (path/i->substr(1)).str();
39 BinaryPackage *BinaryPackage::from_pkgconfig(Builder &builder, const string &name)
41 string info = builder.run_pkgconfig(name, "flags");
43 BinaryPackage *pkg = new BinaryPackage(builder, name);
44 pkg->use_pkgconfig = true;
45 BuildInfo &binfo = pkg->export_binfo;
47 vector<string> flags = split(info);
48 for(vector<string>::const_iterator i=flags.begin(); i!=flags.end(); ++i)
50 if(!i->compare(0, 2, "-I"))
51 binfo.incpath.push_back(i->substr(2));
52 else if(!i->compare(0, 2, "-D"))
53 binfo.defines.push_back(i->substr(2));
54 else if(!i->compare(0, 2, "-L"))
55 binfo.libpath.push_back(i->substr(2));
56 else if(!i->compare(0, 2, "-l"))
57 binfo.libs.push_back(i->substr(2));
64 BinaryPackage::Loader::Loader(BinaryPackage &p):
67 add("need_path", &BinaryPackage::need_path);
68 add("build_info", &Loader::build_info);
71 void BinaryPackage::Loader::build_info()
73 load_sub(static_cast<BinaryPackage &>(pkg).export_binfo);