3 This file is part of builder
4 Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
16 /** Removes any duplicate entries from a list, leaving only the first one. The
17 order of other elements is preserved. O(n²) efficiency. */
18 void unique(StringList &l)
20 for(StringList::iterator i=l.begin(); i!=l.end(); ++i)
21 for(StringList::iterator j=i; j!=l.end();)
33 void BuildInfo::add(const BuildInfo &bi)
35 cflags.insert(cflags.end(), bi.cflags.begin(), bi.cflags.end());
36 defines.insert(defines.end(), bi.defines.begin(), bi.defines.end());
37 incpath.insert(incpath.end(), bi.incpath.begin(), bi.incpath.end());
38 ldflags.insert(ldflags.end(), bi.ldflags.begin(), bi.ldflags.end());
39 libpath.insert(libpath.end(), bi.libpath.begin(), bi.libpath.end());
40 libs.insert(libs.end(), bi.libs.begin(), bi.libs.end());
41 warnings.insert(warnings.end(), bi.warnings.begin(), bi.warnings.end());
44 void BuildInfo::unique()
53 for(StringList::iterator i=warnings.begin(); i!=warnings.end(); ++i)
55 bool flag = i->compare(0, 3, "no-");
57 string warn = (flag ? *i : i->substr(3));
58 string no_warn = "no-"+warn;
60 for(StringList::iterator j=i; j!=warnings.end();)
62 if(j!=i && (*j==warn || *j==no_warn))
65 j = warnings.erase(j);
71 *i = (flag ? warn : no_warn);
76 BuildInfo::Loader::Loader(BuildInfo &bi):
79 add("cflag", &Loader::cflag);
80 add("incpath", &Loader::incpath);
81 add("define", &Loader::define);
82 add("ldflag", &Loader::ldflag);
83 add("libpath", &Loader::libpath);
84 add("library", &Loader::library);
85 add("warning", &Loader::warning);
88 void BuildInfo::Loader::cflag(const std::string &s)
90 binfo.cflags.push_back(s);
93 void BuildInfo::Loader::incpath(const std::string &s)
95 binfo.incpath.push_back(s);
98 void BuildInfo::Loader::define(const std::string &s)
100 binfo.defines.push_back(s);
103 void BuildInfo::Loader::ldflag(const std::string &s)
105 binfo.ldflags.push_back(s);
108 void BuildInfo::Loader::libpath(const std::string &s)
110 binfo.libpath.push_back(s);
113 void BuildInfo::Loader::library(const std::string &s)
115 binfo.libs.push_back(s);
118 void BuildInfo::Loader::warning(const std::string &s)
120 binfo.warnings.push_back(s);