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():
39 void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
41 for(DefineMap::const_iterator i=bi.defines.begin(); i!=bi.defines.end(); ++i)
42 defines[i->first] = i->second;
43 incpath.insert(incpath.end(), bi.incpath.begin(), bi.incpath.end());
46 libpath.insert(libpath.end(), bi.libpath.begin(), bi.libpath.end());
47 libs.insert(libs.end(), bi.libs.begin(), bi.libs.end());
54 optimize = bi.optimize;
56 warning_level = bi.warning_level;
57 fatal_warnings = bi.fatal_warnings;
66 BuildInfo::Loader::Loader(BuildInfo &bi):
67 DataFile::ObjectLoader<BuildInfo>(bi)
69 add("debug", &BuildInfo::debug);
70 add("define", &Loader::define);
71 add("incpath", &Loader::incpath);
72 add("libpath", &Loader::libpath);
73 add("library", &Loader::library);
74 add("libmode", &BuildInfo::libmode);
75 add("optimize", &BuildInfo::optimize);
76 add("strip", &BuildInfo::strip);
77 add("threads", &BuildInfo::threads);
78 add("warning_level", &BuildInfo::warning_level);
79 add("fatal_warnings", &BuildInfo::fatal_warnings);
82 void BuildInfo::Loader::incpath(const string &s)
84 obj.incpath.push_back(s);
87 void BuildInfo::Loader::define(const string &d, const string &v)
92 void BuildInfo::Loader::libpath(const string &s)
94 obj.libpath.push_back(s);
97 void BuildInfo::Loader::library(const string &s)
99 obj.libs.push_back(s);
103 void operator>>(const LexicalConverter &conv, BuildInfo::LibraryMode &libmode)
105 if(conv.get()=="FORCE_STATIC")
106 libmode = BuildInfo::FORCE_STATIC;
107 else if(conv.get()=="STATIC")
108 libmode = BuildInfo::STATIC;
109 else if(conv.get()=="DYNAMIC")
110 libmode = BuildInfo::DYNAMIC;
111 else if(conv.get()=="FORCE_DYNAMIC")
112 libmode = BuildInfo::FORCE_DYNAMIC;
114 throw lexical_error(format("Conversion of '%s' to LibraryMode", conv.get()));