X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpackage.cpp;h=5f25f1a90eb053705092d75b13f565109ffbf2a4;hb=62106ed7cef9b8ef6f07aaf491f8250f7e8d9398;hp=b35a0d8f0ab0af20eaa65acd03636592b86493ce;hpb=242c55b17e6608b29a77ca17a5b677e202a3ca90;p=builder.git diff --git a/source/package.cpp b/source/package.cpp index b35a0d8..5f25f1a 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -1,75 +1,58 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007, 2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include #include +#include "booleanevaluator.h" #include "builder.h" -#include "misc.h" #include "package.h" using namespace std; using namespace Msp; -#include - 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) -{ } - -PackageList Package::collect_requires() { - PackageList result; - result.push_back(this); - for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) - { - PackageList r=(*i)->collect_requires(); - result.splice(result.end(), r); - } - - result.sort(); - result.unique(); - - return result; + builder.get_package_manager().add_package(this); } -void Package::configure(const StringMap &opts, unsigned flag) +void Package::prepare() { - if(conf_done) + if(prepared) return; - if(builder.get_verbose()>=3) - cout<<"Configuring "<prepare(); - 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): - pkg(p) + DataFile::ObjectLoader(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=pkg.builder.get_package(n); + Package *req = obj.builder.get_package_manager().find_package(n); if(req) - pkg.requires.push_back(req); + obj.requires.push_back(req); + else + obj.problems.push_back(format("Required package %s not found", n)); }