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 BuildInfo::LibraryMode BuildInfo::get_libmode_for(const string &lib) const
41 LibModeMap::const_iterator i = libmodes.find(lib);
47 void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
49 for(DefineMap::const_iterator i=bi.defines.begin(); i!=bi.defines.end(); ++i)
50 defines[i->first] = i->second;
51 incpath.insert(incpath.begin(), bi.incpath.begin(), bi.incpath.end());
53 for(StandardMap::const_iterator i=bi.standards.begin(); i!=bi.standards.end(); ++i)
54 standards[i->first] = i->second;
58 libpath.insert(libpath.begin(), bi.libpath.begin(), bi.libpath.end());
59 libs.insert(libs.begin(), bi.libs.begin(), bi.libs.end());
65 local_incpath.insert(local_incpath.begin(), bi.local_incpath.begin(), bi.local_incpath.end());
67 for(LibModeMap::const_iterator i=bi.libmodes.begin(); i!=bi.libmodes.end(); ++i)
68 libmodes[i->first] = i->second;
69 keep_symbols.insert(keep_symbols.end(), bi.keep_symbols.begin(), bi.keep_symbols.end());
71 optimize = bi.optimize;
73 warning_level = bi.warning_level;
74 fatal_warnings = bi.fatal_warnings;
78 unique(local_incpath);
85 BuildInfo::Loader::Loader(BuildInfo &bi):
86 DataFile::ObjectLoader<BuildInfo>(bi)
88 add("debug", &BuildInfo::debug);
89 add("define", &Loader::define);
90 add("incpath", &Loader::incpath);
91 add("keep_symbol", &Loader::keep_symbol);
92 add("libpath", &Loader::libpath);
93 add("library", &Loader::library);
94 add("libmode", &BuildInfo::libmode);
95 add("libmode", &Loader::libmode_for_lib);
96 add("local_incpath", &Loader::local_incpath);
97 add("optimize", &BuildInfo::optimize);
98 add("standard", &Loader::standard);
99 add("strip", &BuildInfo::strip);
100 add("sysroot", &Loader::sysroot);
101 add("threads", &BuildInfo::threads);
102 add("warning_level", &BuildInfo::warning_level);
103 add("fatal_warnings", &BuildInfo::fatal_warnings);
106 void BuildInfo::Loader::incpath(const string &s)
108 obj.incpath.push_back(s);
111 void BuildInfo::Loader::define(const string &d, const string &v)
116 void BuildInfo::Loader::keep_symbol(const string &s)
118 obj.keep_symbols.push_back(s);
121 void BuildInfo::Loader::libmode_for_lib(const string &l, LibraryMode m)
126 void BuildInfo::Loader::libpath(const string &s)
128 obj.libpath.push_back(s);
131 void BuildInfo::Loader::library(const string &s)
133 obj.libs.push_back(s);
136 void BuildInfo::Loader::local_incpath(const string &s)
138 obj.local_incpath.push_back(s);
141 void BuildInfo::Loader::standard(DataFile::Symbol tag, const string &std)
143 obj.standards[tag.name] = std;
146 void BuildInfo::Loader::sysroot(const string &s)
152 void operator>>(const LexicalConverter &conv, BuildInfo::LibraryMode &libmode)
154 if(conv.get()=="FORCE_STATIC")
155 libmode = BuildInfo::FORCE_STATIC;
156 else if(conv.get()=="STATIC")
157 libmode = BuildInfo::STATIC;
158 else if(conv.get()=="DYNAMIC")
159 libmode = BuildInfo::DYNAMIC;
160 else if(conv.get()=="FORCE_DYNAMIC")
161 libmode = BuildInfo::FORCE_DYNAMIC;
163 throw lexical_error(format("Conversion of '%s' to LibraryMode", conv.get()));