]> git.tdb.fi Git - builder.git/blobdiff - source/component.cpp
Move conditionals into helper classes
[builder.git] / source / component.cpp
index a42b81cded44229d877882c535b11c2982ecfb77..2bfa736e14ea2dc7663fcae75b5f6f8c3329395a 100644 (file)
@@ -4,7 +4,6 @@
 #include <msp/fs/utils.h>
 #include <msp/io/print.h>
 #include <msp/strings/lexicalcast.h>
-#include "booleanevaluator.h"
 #include "builder.h"
 #include "component.h"
 #include "sourcepackage.h"
@@ -133,10 +132,9 @@ Component::SourceList Component::collect_source_files() const
 
 
 Component::Loader::Loader(Component &c):
-       DataFile::ObjectLoader<Component>(c)
+       DataFile::ObjectLoader<Component>(c),
+       ConditionalLoader(c.package, format("%s/%s", c.package.get_name(), c.name))
 {
-       add("if_arch",         &Loader::if_arch);
-       add("if_feature",      &Loader::if_feature);
        add("overlay",         &Loader::overlay);
        add("source",          &Loader::source);
        add("install",         &Component::install);
@@ -151,26 +149,6 @@ void Component::Loader::build_info()
        load_sub(obj.build_info);
 }
 
-void Component::Loader::if_arch(const string &cond)
-{
-       BooleanEvaluator eval(sigc::hide<1>(sigc::mem_fun(&obj.package.get_builder().get_current_arch(), &Architecture::match_name)), false);
-       bool match = eval.evaluate(cond);
-       obj.package.get_builder().get_logger().log("configure",
-               format("%s/%s: arch %s %smatched", obj.package.get_name(), obj.name, cond, (match ? "" : "not ")));
-       if(match)
-               load_sub_with(*this);
-}
-
-void Component::Loader::if_feature(const string &cond)
-{
-       BooleanEvaluator eval(sigc::mem_fun(&obj.package, &SourcePackage::match_feature));
-       bool match = eval.evaluate(cond);
-       obj.package.get_builder().get_logger().log("configure",
-               format("%s/%s: feature %s %smatched", obj.package.get_name(), obj.name, cond, (match ? "" : "not ")));
-       if(match)
-               load_sub_with(*this);
-}
-
 void Component::Loader::install_map()
 {
        load_sub(obj.install_map, obj.package.get_source_directory());