From: Mikko Rasa Date: Thu, 3 Dec 2009 08:31:27 +0000 (+0000) Subject: Support default values for features X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=55a110c49b85482c4079745211cc599f4508945f;p=builder.git Support default values for features Use textual values for features rather than numeric --- diff --git a/source/feature.cpp b/source/feature.cpp new file mode 100644 index 0000000..7c19af5 --- /dev/null +++ b/source/feature.cpp @@ -0,0 +1,15 @@ +/* $Id$ + +This file is part of builder +Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#include "feature.h" + +Feature::Loader::Loader(Feature &f): + Msp::DataFile::BasicLoader(f) +{ + add("description", &Feature::descr); + add("default", &Feature::def_value); +} diff --git a/source/feature.h b/source/feature.h index 274f8e9..1d4bf51 100644 --- a/source/feature.h +++ b/source/feature.h @@ -8,12 +8,21 @@ Distributed under the LGPL #ifndef FEATURE_H_ #define FEATURE_H_ +#include + struct Feature { + class Loader: public Msp::DataFile::BasicLoader + { + public: + Loader(Feature &); + }; + std::string name; std::string descr; + std::string def_value; - Feature(const std::string &n, const std::string &d): name(n), descr(d) { } + Feature(const std::string &n): name(n) { } }; typedef std::list FeatureList; diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index f5b9f09..889bf7b 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -130,13 +130,13 @@ void SourcePackage::init_config() config.add_option("tempdir", "temp", "Directory for storing temporary files"); config.add_option("outdir", ".", "Directory to put build results in"); config.add_option("optimize", "0", "Apply compiler optimizations"); - config.add_option("strip", "0", "Strip symbols from programs"); - config.add_option("debug", "0", "Produce debugging symbols"); + config.add_option("strip", "no", "Strip symbols from programs"); + config.add_option("debug", "no", "Produce debugging symbols"); config.add_option("cpu", "none", "CPU type to optimize for"); config.add_option("staticlibs", "local", "Use static libraries"); for(FeatureList::iterator i=features.begin(); i!=features.end(); ++i) - config.add_option("with_"+i->name, "0", i->descr); + config.add_option("with_"+i->name, i->def_value, i->descr); for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) { @@ -235,7 +235,11 @@ void SourcePackage::Loader::finish() void SourcePackage::Loader::feature(const string &n, const string &d) { - static_cast(pkg).features.push_back(Feature(n, d)); + Feature feat(n); + feat.descr = d; + feat.def_value = "no"; + load_sub(feat); + static_cast(pkg).features.push_back(feat); } void SourcePackage::Loader::condition(const string &c)