X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.cpp;h=e2df34c06e3ec91cb56500f97c3bed1b53b23d02;hb=HEAD;hp=ec8156798d70628d0597e6936ecd39622d9fff58;hpb=50be4619cca4bb44e5abf8759720c255ef6d3b45;p=builder.git diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp deleted file mode 100644 index ec81567..0000000 --- a/source/buildinfo.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include "buildinfo.h" - -using namespace std; -using namespace Msp; - -namespace { - -/** Removes any duplicate entries from a list, leaving only the first one. The -order of other elements is preserved. O(n²) efficiency. */ -void unique(StringList &l) -{ - for(StringList::iterator i=l.begin(); i!=l.end(); ++i) - for(StringList::iterator j=i; j!=l.end();) - { - if(j!=i && *j==*i) - j = l.erase(j); - else - ++j; - } -} - -} - - -BuildInfo::BuildInfo(): - threads(false), - debug(false), - optimize(0), - strip(false) -{ } - -void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level) -{ - for(DefineMap::const_iterator i=bi.defines.begin(); i!=bi.defines.end(); ++i) - defines[i->first] = i->second; - incpath.insert(incpath.end(), bi.incpath.begin(), bi.incpath.end()); - if(level!=CHAINED) - { - libpath.insert(libpath.end(), bi.libpath.begin(), bi.libpath.end()); - libs.insert(libs.end(), bi.libs.begin(), bi.libs.end()); - } - warnings.insert(warnings.end(), bi.warnings.begin(), bi.warnings.end()); - threads = bi.threads; - if(level==LOCAL) - { - debug = bi.debug; - optimize = bi.optimize; - strip = bi.strip; - } - - unique(); -} - -void BuildInfo::unique() -{ - ::unique(incpath); - ::unique(libpath); - ::unique(libs); - - for(StringList::iterator i=warnings.begin(); i!=warnings.end(); ++i) - { - bool flag = i->compare(0, 3, "no-"); - - string warn = (flag ? *i : i->substr(3)); - string no_warn = "no-"+warn; - - for(StringList::iterator j=i; j!=warnings.end();) - { - if(j!=i && (*j==warn || *j==no_warn)) - { - flag = (*j==warn); - j = warnings.erase(j); - } - else - ++j; - } - - *i = (flag ? warn : no_warn); - } -} - - -BuildInfo::Loader::Loader(BuildInfo &bi): - DataFile::ObjectLoader(bi) -{ - add("debug", &BuildInfo::debug); - add("define", &Loader::define); - add("incpath", &Loader::incpath); - add("libpath", &Loader::libpath); - add("library", &Loader::library); - add("optimize", &BuildInfo::optimize); - add("strip", &BuildInfo::strip); - add("threads", &BuildInfo::threads); - add("warning", &Loader::warning); -} - -void BuildInfo::Loader::incpath(const std::string &s) -{ - obj.incpath.push_back(s); -} - -void BuildInfo::Loader::define(const std::string &d, const std::string &v) -{ - obj.defines[d] = v; -} - -void BuildInfo::Loader::libpath(const std::string &s) -{ - obj.libpath.push_back(s); -} - -void BuildInfo::Loader::library(const std::string &s) -{ - obj.libs.push_back(s); -} - -void BuildInfo::Loader::warning(const std::string &s) -{ - obj.warnings.push_back(s); -}