-/* $Id$
-
-This file is part of builder
-Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include <msp/strings/utils.h>
#include "builder.h"
#include "condition.h"
string::size_type token = i->find_first_of("=!");
if(token==string::npos)
- expression.insert(StringMap::value_type(*i, "!0"));
+ expression.insert(StringMap::value_type(*i, "="));
else if(token==0 && (*i)[0]=='!')
- expression.insert(StringMap::value_type(*i, "=0"));
+ expression.insert(StringMap::value_type(i->substr(1), "!"));
else
expression.insert(StringMap::value_type(i->substr(0, token), i->substr(token)));
}
unsigned start = 1;
if(i->second[1]=='=')
++start;
+ string value = i->second.substr(start);
- string value;
+ bool match = false;
if(conf.is_option(i->first))
- value = conf.get_option(i->first).value;
+ {
+ if(value.empty())
+ match = lexical_cast<bool>(conf.get_option(i->first).value);
+ else
+ match = (conf.get_option(i->first).value==value);
+ }
else if(i->first=="arch")
- value = pkg.get_builder().get_current_arch().get_name();
+ match = pkg.get_builder().get_current_arch().match_name(value);
- if((value==i->second.substr(start))==neg)
+ if(match==neg)
result = false;
}
Condition::Loader::Loader(Condition &c):
- cond(c)
+ DataFile::ObjectLoader<Condition>(c)
{
add("require", &Loader::require);
add("build_info", &Loader::build_info);
void Condition::Loader::require(const string &pkg)
{
- cond.requires.push_back(pkg);
+ obj.requires.push_back(pkg);
}
void Condition::Loader::build_info()
{
- load_sub(cond.build_info);
+ load_sub(obj.build_info);
}