From ae1ab287b544cc19d185024fa64e475a957313e4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 13 Oct 2015 22:55:10 +0300 Subject: [PATCH] Allow features to be exported 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 | 4 +++- source/feature.h | 1 + source/sourcepackage.cpp | 15 +++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/feature.cpp b/source/feature.cpp index 712004f..7bf9a57 100644 --- a/source/feature.cpp +++ b/source/feature.cpp @@ -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) diff --git a/source/feature.h b/source/feature.h index 5bcaa4d..f0134db 100644 --- a/source/feature.h +++ b/source/feature.h @@ -18,6 +18,7 @@ struct Feature std::string description; std::string default_value; std::list choices; + bool exported; Feature(const std::string &); }; diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 9e1b68d..bb99994 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -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(value)) - build_info.defines[ident] = "1"; + + if(i->choices.empty()) + { + if(!lexical_cast(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) -- 2.43.0