]> git.tdb.fi Git - builder.git/commitdiff
Support default values for features
authorMikko Rasa <tdb@tdb.fi>
Thu, 3 Dec 2009 08:31:27 +0000 (08:31 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 3 Dec 2009 08:31:27 +0000 (08:31 +0000)
Use textual values for features rather than numeric

source/feature.cpp [new file with mode: 0644]
source/feature.h
source/sourcepackage.cpp

diff --git a/source/feature.cpp b/source/feature.cpp
new file mode 100644 (file)
index 0000000..7c19af5
--- /dev/null
@@ -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<Feature>(f)
+{
+       add("description", &Feature::descr);
+       add("default",     &Feature::def_value);
+}
index 274f8e91bc7eade318fcaa3e4c355e1d62e89619..1d4bf51a90bf46348a0278640de00ccbdc9fbce8 100644 (file)
@@ -8,12 +8,21 @@ Distributed under the LGPL
 #ifndef FEATURE_H_
 #define FEATURE_H_
 
+#include <msp/datafile/loader.h>
+
 struct Feature
 {
+       class Loader: public Msp::DataFile::BasicLoader<Feature>
+       {
+       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<Feature> FeatureList;
index f5b9f09b533d7f4abbfc9336b4bddf91d6ea6bce..889bf7baab3ff0735037b3e2809bcc8273066e70 100644 (file)
@@ -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<SourcePackage &>(pkg).features.push_back(Feature(n, d));
+       Feature feat(n);
+       feat.descr = d;
+       feat.def_value = "no";
+       load_sub(feat);
+       static_cast<SourcePackage &>(pkg).features.push_back(feat);
 }
 
 void SourcePackage::Loader::condition(const string &c)