]> git.tdb.fi Git - builder.git/blob - source/buildinfo.h
Make BuildInfo uniquify things implicitly after update
[builder.git] / source / buildinfo.h
1 #ifndef BUILDINFO_H_
2 #define BUILDINFO_H_
3
4 #include <list>
5 #include <string>
6 #include <msp/datafile/objectloader.h>
7 #include "misc.h"
8
9 /**
10 Stores information about compiler command line parameters in a more abstract
11 form.  Allows combining with other BuildInfos to support package dependencies.
12 */
13 class BuildInfo
14 {
15 public:
16         class Loader: public Msp::DataFile::ObjectLoader<BuildInfo>
17         {
18         public:
19                 Loader(BuildInfo &);
20         private:
21                 void incpath(const std::string &);
22                 void define(const std::string &, const std::string &);
23                 void libpath(const std::string &);
24                 void library(const std::string &);
25                 void warning(const std::string &);
26         };
27         
28         enum UpdateLevel
29         {
30                 LOCAL,       //< Include all information
31                 DEPENDENCY,  //< Include all but code generation options
32                 CHAINED      //< Include only compilation options
33         };
34
35         typedef std::map<std::string, std::string> DefineMap;
36
37         DefineMap defines;
38         StringList incpath;
39         StringList libpath;
40         StringList libs;
41         StringList warnings;
42         bool threads;
43         bool debug;
44         int optimize;
45         bool strip;
46
47         BuildInfo();
48
49         /** Updates the BuildInfo from another one.  Lists are concatenated, with
50         the first occurrence of each item preserved.  Scalars are overwritten.
51         
52         The update level determines what information is updated. */
53         void update_from(const BuildInfo &, UpdateLevel = LOCAL);
54
55 private:
56         /** Makes sure there are no duplicate entries in the lists.  For warnings,
57         contradicting flags are eliminated and the last one stays in effect. */
58         void unique();
59 };
60
61 #endif