]> git.tdb.fi Git - builder.git/commitdiff
Allow features to be exported
authorMikko Rasa <tdb@tdb.fi>
Tue, 13 Oct 2015 19:55:10 +0000 (22:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 13 Oct 2015 19:55:10 +0000 (22:55 +0300)
While overlay directories are generally preferred, sometimes it's not
worth the effort for a small feature.  In those cases the -D switch needs
to be applied to any package that might use the library's headers.

source/feature.cpp
source/feature.h
source/sourcepackage.cpp

index 712004fc6125a9b5f3fb616b6464bb91d70d80c1..7bf9a578e0344a6321a1b1e9516af565221b3c6a 100644 (file)
@@ -5,7 +5,8 @@ using namespace Msp;
 
 Feature::Feature(const string &n):
        name(n),
-       default_value("no")
+       default_value("no"),
+       exported(false)
 { }
 
 
@@ -15,6 +16,7 @@ Feature::Loader::Loader(Feature &f):
        add("choice",      &Loader::choice);
        add("description", &Feature::description);
        add("default",     &Feature::default_value);
+       add("export",      &Feature::exported);
 }
 
 void Feature::Loader::choice(const string &c)
index 5bcaa4df53a3be6a91d538883c1a51701786e85c..f0134db8dbdb712d9b276d57addd4203a96359db 100644 (file)
@@ -18,6 +18,7 @@ struct Feature
        std::string description;
        std::string default_value;
        std::list<std::string> choices;
+       bool exported;
 
        Feature(const std::string &);
 };
index 9e1b68dd43d60b4b81d61f2c65051412d7286fa6..bb9999476d0041f3529aacc44b7a3a60b3d8b960 100644 (file)
@@ -107,10 +107,17 @@ void SourcePackage::do_prepare()
        {
                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";
+
+               if(i->choices.empty())
+               {
+                       if(!lexical_cast<bool>(value))
+                               continue;
+                       value = "1";
+               }
+
+               build_info.defines[ident] = value;
+               if(i->exported)
+                       export_binfo.defines[ident] = value;
        }
 
        for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)