]> git.tdb.fi Git - builder.git/blobdiff - source/sourcepackage.cpp
Resolve cmdline targets and what-ifs the same way
[builder.git] / source / sourcepackage.cpp
index 8ad12d37c7f78ccc533e4366df613709c637902e..faf3bfe3c062d1948af5dd57c7086f3697ae8465 100644 (file)
@@ -37,12 +37,7 @@ SourcePackage::SourcePackage(Builder &b, const string &n, const FS::Path &f):
        source_tarball = &components.back();
 }
 
-void SourcePackage::set_build_type(const BuildType &t)
-{
-       build_type = &t;
-}
-
-FS::Path SourcePackage::get_temp_dir() const
+FS::Path SourcePackage::get_temp_directory() const
 {
        string subdir = builder.get_current_arch().get_name();
        if(build_type)
@@ -58,7 +53,7 @@ FS::Path SourcePackage::get_temp_dir() const
                return source_dir/temp/subdir;
 }
 
-FS::Path SourcePackage::get_out_dir() const
+FS::Path SourcePackage::get_output_directory() const
 {
        const Architecture &arch = builder.get_current_arch();
        if(arch.is_native())
@@ -67,6 +62,32 @@ FS::Path SourcePackage::get_out_dir() const
                return source_dir/arch.get_name();
 }
 
+bool SourcePackage::match_feature(const string &cond) const
+{
+       string::size_type equals = cond.find('=');
+       if(equals!=string::npos)
+       {
+               if(equals==0)
+                       throw invalid_argument("SourcePackage::match_feature");
+               bool negate = cond[equals-1]=='!';
+               string feat = cond.substr(0, equals-negate);
+               string value = config.get_option("with_"+feat).value;
+               return (value==cond.substr(equals+1))!=negate;
+       }
+       else
+       {
+               bool negate = (cond[0]=='!');
+               string feat = cond.substr(negate);
+               string value = config.get_option("with_"+feat).value;
+               return lexical_cast<bool>(value)!=negate;
+       }
+}
+
+void SourcePackage::set_build_type(const BuildType &t)
+{
+       build_type = &t;
+}
+
 void SourcePackage::do_prepare()
 {
        BuildInfo final_build_info;
@@ -153,7 +174,7 @@ void SourcePackage::Loader::init(const Config::InputOptions *o)
        add("headers",     &Loader::headers);
        add("install",     &Loader::component<Component::INSTALL>);
        add("interface_version", &Loader::interface_version);
-       add("datafile",    &Loader::component<Component::DATAFILE>);
+       add("datapack",    &Loader::component<Component::DATAPACK>);
        add("source_tarball", &Loader::source_tarball);
        add("tarball",     &Loader::tarball);
        add("tar_file",    &Loader::tar_file);
@@ -231,25 +252,7 @@ void SourcePackage::Loader::headers(const string &n)
 
 void SourcePackage::Loader::if_feature(const string &cond)
 {
-       bool match = false;
-       string::size_type equals = cond.find('=');
-       if(equals!=string::npos)
-       {
-               if(equals==0)
-                       throw invalid_argument("SourcePackage::Loader::if_feature");
-               bool negate = cond[equals-1]=='!';
-               string name = cond.substr(0, equals-negate);
-               string value = obj.config.get_option("with_"+name).value;
-               match = (value==cond.substr(equals+1))!=negate;
-               value = cond.substr(equals+1);
-       }
-       else
-       {
-               bool negate = (cond[0]=='!');
-               string name = cond.substr(negate);
-               string value = obj.config.get_option("with_"+name).value;
-               match = lexical_cast<bool>(value)!=negate;
-       }
+       bool match = obj.match_feature(cond);
        obj.builder.get_logger().log("configure", format("%s: feature %s %smatched", obj.name, cond, (match ? "" : "not ")));
        if(match)
                load_sub_with(*this);