for(Config::OptionMap::const_iterator i=options.begin(); i!=options.end(); ++i)
{
const Config::Option &opt = i->second;
- IO::print(" %s: %s (%s)", opt.name, opt.description, opt.value);
- if(opt.value!=opt.default_value)
- IO::print(" [%s]", opt.default_value);
- IO::print("\n");
+ string line = format(" %s: %s (%s)", opt.name, opt.description, opt.value);
+ if(!opt.choices.empty())
+ {
+ line += " {";
+ for(list<string>::const_iterator j=opt.choices.begin(); j!=opt.choices.end(); ++j)
+ {
+ if(j!=opt.choices.begin())
+ line += ' ';
+ line += *j;
+ }
+ line += '}';
+ }
+ else if(opt.value!=opt.default_value)
+ line += format(" [%s]", opt.default_value);
+ IO::print("%s\n", line);
}
}
}
#include "feature.h"
+using namespace std;
+using namespace Msp;
+
+Feature::Feature(const string &n):
+ name(n),
+ default_value("no")
+{ }
+
+
Feature::Loader::Loader(Feature &f):
Msp::DataFile::ObjectLoader<Feature>(f)
{
+ add("choice", &Loader::choice);
add("description", &Feature::description);
add("default", &Feature::default_value);
}
+
+void Feature::Loader::choice(const string &c)
+{
+ if(obj.choices.empty())
+ obj.default_value = c;
+ obj.choices.push_back(c);
+}
{
public:
Loader(Feature &);
+
+ private:
+ void choice(const std::string &);
};
std::string name;
std::string description;
std::string default_value;
+ std::list<std::string> choices;
- Feature(const std::string &n): name(n) { }
+ Feature(const std::string &);
};
#endif
build_info.libpath.push_back((builder.get_prefix()/"lib").str());
for(FeatureList::iterator i=features.begin(); i!=features.end(); ++i)
- if(lexical_cast<bool>(config.get_option("with_"+i->name).value))
- build_info.defines["WITH_"+toupper(i->name)] = "1";
+ {
+ string ident = "WITH_"+toupper(i->name);
+ string value = config.get_option("with_"+i->name).value;
+ if(!i->choices.empty())
+ build_info.defines[ident] = value;
+ else if(lexical_cast<bool>(value))
+ build_info.defines[ident] = "1";
+ }
bool export_paths = false;
for(list<Component>::iterator i=components.begin(); i!=components.end(); ++i)
{
Feature feat(n);
feat.description = d;
- feat.default_value = "no";
load_sub(feat);
obj.features.push_back(feat);