#include <msp/io/print.h>
#include <msp/strings/lexicalcast.h>
#include <msp/strings/utils.h>
+#include "booleanevaluator.h"
#include "builder.h"
-#include "misc.h"
#include "package.h"
using namespace std;
Package::Package(Builder &b, const string &n):
builder(b),
name(n),
- conf_done(false),
+ label(string(1, toupper(n[0]))+n.substr(1)),
+ prepared(false),
use_pkgconfig(true)
{
builder.get_package_manager().add_package(this);
}
-void Package::configure(const StringMap &opts, unsigned flag)
+void Package::prepare()
{
- if(conf_done)
+ if(prepared)
return;
- builder.get_logger().log("configure", format("Configuring %s", name));
+ for(Requirements::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+ (*i)->prepare();
- do_configure(opts, flag);
-
- requires.sort();
- requires.unique();
-
- for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
- (*i)->configure(opts, flag&2);
-
- create_build_info();
-
- conf_done = true;
+ do_prepare();
+ prepared = true;
}
Package::Loader::Loader(Package &p):
DataFile::ObjectLoader<Package>(p)
{
+ add("if_arch", &Loader::if_arch);
+ add("label", &Package::label);
add("require", &Loader::require);
}
+void Package::Loader::if_arch(const string &cond)
+{
+ BooleanEvaluator eval(sigc::hide<1>(sigc::mem_fun(&obj.builder.get_current_arch(), &Architecture::match_name)), false);
+ bool match = eval.evaluate(cond);
+ obj.builder.get_logger().log("configure", format("%s: arch %s %smatched", obj.name, cond, (match ? "" : "not ")));
+ if(match)
+ load_sub_with(*this);
+}
+
void Package::Loader::require(const string &n)
{
Package *req = obj.builder.get_package_manager().find_package(n);
if(req)
obj.requires.push_back(req);
+ else
+ obj.problems.push_back(format("Required package %s not found", n));
}