3 This file is part of builder
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/strings/utils.h>
9 #include "binarypackage.h"
15 BinaryPackage::BinaryPackage(Builder &b, const string &n):
23 Sets the path where the package files were installed. This is only useful if
24 the package doesn't use pkg-config.
26 void BinaryPackage::set_path(const Msp::Path::Path &p)
28 path=builder.get_cwd()/p;
31 void BinaryPackage::create_build_info()
33 for(StringList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i)
35 *i=(path/i->substr(1)).str();
37 for(StringList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i)
39 *i=(path/i->substr(1)).str();
42 BinaryPackage *BinaryPackage::from_pkgconfig(Builder &builder, const string &name)
45 argv.push_back("pkg-config");
46 argv.push_back("--silence-errors");
47 argv.push_back("--cflags");
48 argv.push_back("--libs");
50 string info=run_command(argv);
56 BinaryPackage *pkg=new BinaryPackage(builder, name);
57 pkg->use_pkgconfig=true;
58 BuildInfo &binfo=pkg->export_binfo;
60 vector<string> flags=split(info);
61 for(vector<string>::const_iterator i=flags.begin(); i!=flags.end(); ++i)
63 if(!i->compare(0, 2, "-I"))
64 binfo.incpath.push_back(i->substr(2));
65 else if(!i->compare(0, 2, "-D"))
66 binfo.defines.push_back(i->substr(2));
67 else if(!i->compare(0, 2, "-L"))
68 binfo.libpath.push_back(i->substr(2));
69 else if(!i->compare(0, 2, "-l"))
70 binfo.libs.push_back(i->substr(2));
77 BinaryPackage::Loader::Loader(BinaryPackage &p):
80 add("need_path", &BinaryPackage::need_path);
81 add("build_info", &Loader::build_info);
84 void BinaryPackage::Loader::build_info()
86 load_sub(static_cast<BinaryPackage &>(pkg).export_binfo);