3 #include <msp/strings/format.h>
11 /** Removes any duplicate entries from a list, leaving only the first one. The
12 order of other elements is preserved. O(nlogn) efficiency. */
14 void unique(list<T> &l)
17 for(typename list<T>::iterator i=l.begin(); i!=l.end(); )
29 BuildInfo::BuildInfo():
37 void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
39 for(DefineMap::const_iterator i=bi.defines.begin(); i!=bi.defines.end(); ++i)
40 defines[i->first] = i->second;
41 incpath.insert(incpath.end(), bi.incpath.begin(), bi.incpath.end());
44 libpath.insert(libpath.end(), bi.libpath.begin(), bi.libpath.end());
45 libs.insert(libs.end(), bi.libs.begin(), bi.libs.end());
47 warnings.insert(warnings.end(), bi.warnings.begin(), bi.warnings.end());
53 optimize = bi.optimize;
60 void BuildInfo::unique()
66 for(WordList::iterator i=warnings.begin(); i!=warnings.end(); ++i)
68 bool flag = i->compare(0, 3, "no-");
70 string warn = (flag ? *i : i->substr(3));
71 string no_warn = "no-"+warn;
73 for(WordList::iterator j=i; j!=warnings.end();)
75 if(j!=i && (*j==warn || *j==no_warn))
78 j = warnings.erase(j);
84 *i = (flag ? warn : no_warn);
89 BuildInfo::Loader::Loader(BuildInfo &bi):
90 DataFile::ObjectLoader<BuildInfo>(bi)
92 add("debug", &BuildInfo::debug);
93 add("define", &Loader::define);
94 add("incpath", &Loader::incpath);
95 add("libpath", &Loader::libpath);
96 add("library", &Loader::library);
97 add("libmode", &BuildInfo::libmode);
98 add("optimize", &BuildInfo::optimize);
99 add("strip", &BuildInfo::strip);
100 add("threads", &BuildInfo::threads);
101 add("warning", &Loader::warning);
104 void BuildInfo::Loader::incpath(const string &s)
106 obj.incpath.push_back(s);
109 void BuildInfo::Loader::define(const string &d, const string &v)
114 void BuildInfo::Loader::libpath(const string &s)
116 obj.libpath.push_back(s);
119 void BuildInfo::Loader::library(const string &s)
121 obj.libs.push_back(s);
124 void BuildInfo::Loader::warning(const string &s)
126 obj.warnings.push_back(s);
130 void operator>>(LexicalConverter &conv, BuildInfo::LibraryMode &libmode)
132 if(conv.get()=="FORCE_STATIC")
133 libmode = BuildInfo::FORCE_STATIC;
134 else if(conv.get()=="STATIC")
135 libmode = BuildInfo::STATIC;
136 else if(conv.get()=="DYNAMIC")
137 libmode = BuildInfo::DYNAMIC;
138 else if(conv.get()=="FORCE_DYNAMIC")
139 libmode = BuildInfo::FORCE_DYNAMIC;
141 throw lexical_error(format("Conversion of '%s' to LibraryMode", conv.get()));