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