X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsourcepackage.cpp;h=b84b22a58f0a33ea326cfc99845e9363ade5081c;hb=50baabc242633d531d3f9542e9a64491b6e12c6c;hp=8ad12d37c7f78ccc533e4366df613709c637902e;hpb=373e9bb43c24d38316c5bb0393f4a369563319d3;p=builder.git diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 8ad12d3..b84b22a 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -42,7 +42,7 @@ 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 +58,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 +67,27 @@ 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(value)!=negate; + } +} + void SourcePackage::do_prepare() { BuildInfo final_build_info; @@ -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(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);