X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcondition.cpp;h=5cce44462d3e984b9f61e85f2152e9c994a70d07;hb=0f5283a54fd188072eca23fbd980a43c6c869913;hp=97e93f1b1c6d5d3780df328a0dfc3925e1e44923;hpb=445edbc3c42bbd7880cc414cf153ddfd196bfc1c;p=builder.git diff --git a/source/condition.cpp b/source/condition.cpp index 97e93f1..5cce444 100644 --- a/source/condition.cpp +++ b/source/condition.cpp @@ -1,13 +1,19 @@ +/* $Id$ + +This file is part of builder +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include +#include "builder.h" #include "condition.h" -#include "package.h" +#include "sourcepackage.h" using namespace std; using namespace Msp; -#include - -Condition::Condition(Package &p, const string &expr): +Condition::Condition(SourcePackage &p, const string &expr): pkg(p) { vector parts=split(expr); @@ -16,7 +22,7 @@ Condition::Condition(Package &p, const string &expr): { if(*i=="and") continue; - + unsigned token=i->find_first_of("=!"); if(token==string::npos) expression.insert(StringMap::value_type(*i, "!0")); @@ -27,12 +33,6 @@ Condition::Condition(Package &p, const string &expr): } } -void Condition::resolve_refs() -{ - for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) - i->resolve(); -} - bool Condition::eval() { const Config &conf=pkg.get_config(); @@ -45,7 +45,13 @@ bool Condition::eval() if(i->second[1]=='=') ++start; - if((conf.get_option(i->first).value==i->second.substr(start))==neg) + string value; + if(conf.is_option(i->first)) + value=conf.get_option(i->first).value; + else if(i->first=="arch") + value=pkg.get_builder().get_current_arch().get_name(); + + if((value==i->second.substr(start))==neg) result=false; } @@ -62,7 +68,7 @@ Condition::Loader::Loader(Condition &c): void Condition::Loader::require(const string &pkg) { - cond.requires.push_back(PackageRef(cond.pkg.get_builder(), pkg)); + cond.requires.push_back(pkg); } void Condition::Loader::build_info()