]> git.tdb.fi Git - builder.git/blob - source/buildinfo.cpp
Adjust requires to library changes
[builder.git] / source / buildinfo.cpp
1 #include "buildinfo.h"
2
3 using namespace Msp;
4
5 /**
6 Adds another BuildInfo to the end of this one.
7 */
8 void BuildInfo::add(const BuildInfo &bi)
9 {
10         cflags.insert(cflags.end(), bi.cflags.begin(), bi.cflags.end());
11         defines.insert(defines.end(), bi.defines.begin(), bi.defines.end());
12         incpath.insert(incpath.end(), bi.incpath.begin(), bi.incpath.end());
13         ldflags.insert(ldflags.end(), bi.ldflags.begin(), bi.ldflags.end());
14         libpath.insert(libpath.end(), bi.libpath.begin(), bi.libpath.end());
15         libs.insert(libs.end(), bi.libs.begin(), bi.libs.end());
16 }
17
18 /**
19 Makes sure there are no duplicate entries in the lists.
20 */
21 void BuildInfo::unique()
22 {
23         unique(cflags);
24         unique(defines);
25         unique(incpath);
26         unique(ldflags);
27         unique(libpath);
28         unique(libs);
29 }
30
31 /**
32 Removes any duplicate entries from a list, leaving only the first one.  The
33 order of other elements is preserved.  O(n²) efficiency.
34 */
35 void BuildInfo::unique(StringList &l)
36 {
37         StringList l2;
38         for(StringList::iterator i=l.begin(); i!=l.end(); ++i)
39                 if(find(l2.begin(), l2.end(), *i)==l2.end())
40                         l2.push_back(*i);
41         swap(l, l2);
42 }
43
44 BuildInfo::Loader::Loader(BuildInfo &bi):
45         binfo(bi)
46 {
47         add("cflag",   &Loader::cflag);
48         add("incpath", &Loader::incpath);
49         add("define",  &Loader::define);
50         add("ldflag",  &Loader::ldflag);
51         add("libpath", &Loader::libpath);
52         add("library", &Loader::library);
53 }
54
55