X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.cpp;h=2bf928a9ba950f4676d8b011e7010907ee252722;hb=43bd25ffcb0b4f7882773f4676b209a99cb73c04;hp=4a10872a7539cd3873e7b4afd4b6a5119603b6c6;hpb=7aeaa4ba965f596edad438c02e345a8843f7469a;p=builder.git diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 4a10872..2bf928a 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -1,17 +1,28 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include "buildinfo.h" +using namespace std; using namespace Msp; -/** -Adds another BuildInfo to the end of this one. -*/ +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; + } +} + +} + + void BuildInfo::add(const BuildInfo &bi) { cflags.insert(cflags.end(), bi.cflags.begin(), bi.cflags.end()); @@ -20,34 +31,41 @@ void BuildInfo::add(const BuildInfo &bi) ldflags.insert(ldflags.end(), bi.ldflags.begin(), bi.ldflags.end()); 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()); } -/** -Makes sure there are no duplicate entries in the lists. -*/ void BuildInfo::unique() { - unique(cflags); - unique(defines); - unique(incpath); - unique(ldflags); - unique(libpath); - unique(libs); -} + ::unique(cflags); + ::unique(defines); + ::unique(incpath); + ::unique(ldflags); + ::unique(libpath); + ::unique(libs); -/** -Removes any duplicate entries from a list, leaving only the first one. The -order of other elements is preserved. O(n²) efficiency. -*/ -void BuildInfo::unique(StringList &l) -{ - StringList l2; - for(StringList::iterator i=l.begin(); i!=l.end(); ++i) - if(find(l2.begin(), l2.end(), *i)==l2.end()) - l2.push_back(*i); - swap(l, l2); + 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): binfo(bi) { @@ -57,6 +75,40 @@ BuildInfo::Loader::Loader(BuildInfo &bi): add("ldflag", &Loader::ldflag); add("libpath", &Loader::libpath); add("library", &Loader::library); + add("warning", &Loader::warning); +} + +void BuildInfo::Loader::cflag(const std::string &s) +{ + binfo.cflags.push_back(s); +} + +void BuildInfo::Loader::incpath(const std::string &s) +{ + binfo.incpath.push_back(s); +} + +void BuildInfo::Loader::define(const std::string &s) +{ + binfo.defines.push_back(s); +} + +void BuildInfo::Loader::ldflag(const std::string &s) +{ + binfo.ldflags.push_back(s); } +void BuildInfo::Loader::libpath(const std::string &s) +{ + binfo.libpath.push_back(s); +} +void BuildInfo::Loader::library(const std::string &s) +{ + binfo.libs.push_back(s); +} + +void BuildInfo::Loader::warning(const std::string &s) +{ + binfo.warnings.push_back(s); +}