]> git.tdb.fi Git - builder.git/blob - source/buildinfo.h
Move library mode into BuildInfo
[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         enum LibraryMode
17         {
18                 FORCE_STATIC,  //< Only accept static libraries
19                 STATIC,        //< Prefer static libraries but accept dynamic as well
20                 DYNAMIC,       //< Prefer dynamic libraries but accept static as well
21                 FORCE_DYNAMIC  //< Only accept dynamic libraries
22         };
23
24         class Loader: public Msp::DataFile::ObjectLoader<BuildInfo>
25         {
26         public:
27                 Loader(BuildInfo &);
28         private:
29                 void incpath(const std::string &);
30                 void define(const std::string &, const std::string &);
31                 void libpath(const std::string &);
32                 void library(const std::string &);
33                 void warning(const std::string &);
34         };
35         
36         enum UpdateLevel
37         {
38                 LOCAL,       //< Include all information
39                 DEPENDENCY,  //< Include all but code generation options
40                 CHAINED      //< Include only compilation options
41         };
42
43         typedef std::map<std::string, std::string> DefineMap;
44         typedef std::list<Msp::FS::Path> PathList;
45         typedef std::list<std::string> WordList;
46
47         DefineMap defines;
48         PathList incpath;
49         PathList libpath;
50         WordList libs;
51         LibraryMode libmode;
52         WordList warnings;
53         bool threads;
54         bool debug;
55         int optimize;
56         bool strip;
57
58         BuildInfo();
59
60         /** Updates the BuildInfo from another one.  Lists are concatenated, with
61         the first occurrence of each item preserved.  Scalars are overwritten.
62         
63         The update level determines what information is updated. */
64         void update_from(const BuildInfo &, UpdateLevel = LOCAL);
65
66 private:
67         /** Makes sure there are no duplicate entries in the lists.  For warnings,
68         contradicting flags are eliminated and the last one stays in effect. */
69         void unique();
70 };
71
72 #endif