6 #include <msp/datafile/objectloader.h>
7 #include <msp/fs/path.h>
8 #include "libbuilder_api.h"
11 Stores information about compiler command line parameters in a more abstract
12 form. Allows combining with other BuildInfos to support package dependencies.
14 class LIBBUILDER_API BuildInfo
19 FORCE_STATIC, //< Only accept static libraries
20 STATIC, //< Prefer static libraries but accept dynamic as well
21 DYNAMIC, //< Prefer dynamic libraries but accept static as well
22 FORCE_DYNAMIC //< Only accept dynamic libraries
27 NO_RPATH, //< Do not record rpath in binaries
28 RELATIVE, //< Record relative rpath in binaries
29 ABSOLUTE //< Record absolute rpath in binaries
32 class LIBBUILDER_API Loader: public Msp::DataFile::ObjectLoader<BuildInfo>
37 void incpath(const std::string &);
38 void define(const std::string &, const std::string &);
39 void keep_symbol(const std::string &);
40 void libmode_for_lib(const std::string &, LibraryMode);
41 void libpath(const std::string &);
42 void library(const std::string &);
43 void local_incpath(const std::string &);
44 void standard(Msp::DataFile::Symbol, const std::string &);
45 void sysroot(const std::string &);
50 LOCAL, //< Include all information
51 DEPENDENCY, //< Include all but code generation options
52 CHAINED //< Include only compilation options
55 struct LIBBUILDER_API LanguageStandard
60 LanguageStandard() = default;
61 LanguageStandard(const std::string &);
63 std::string str() const;
67 A wrapper which tracks the set status of the wrapped variable. A default
68 value may be provided in initialization without causing it to be treated as
69 set. Assigning from a raw value flags the Tracked object as set. Assigning
70 from another Tracked object will only change the value of the target if the
85 Tracked(T v): value(v) { }
86 Tracked(const Tracked &t) = default;
87 Tracked &operator=(const Tracked &v) { if(v.set) { value = v.value; set = true; } return *this; }
89 Tracked &operator=(const T &v) { value = v; set = true; return *this; }
90 operator const T &() const { return value; }
93 Tracked<Msp::FS::Path> sysroot;
94 std::map<std::string, std::string> defines;
95 std::vector<Msp::FS::Path> incpath;
96 std::vector<Msp::FS::Path> local_incpath;
97 std::vector<Msp::FS::Path> libpath;
98 std::vector<std::string> libs;
99 Tracked<LibraryMode> libmode = DYNAMIC;
100 Tracked<RuntimePathMode> rpath_mode = NO_RPATH;
101 std::map<std::string, LibraryMode> libmodes;
102 std::vector<std::string> keep_symbols;
103 std::map<std::string, LanguageStandard> standards;
104 Tracked<bool> threads = false;
105 Tracked<bool> debug = false;
106 Tracked<int> optimize = 0;
107 Tracked<bool> strip = false;
108 Tracked<unsigned> warning_level = 0;
109 Tracked<bool> fatal_warnings = false;
111 /** Returns the library mode for linking a particular library. If no mode
112 has been specified for that library, the the global library mode is
114 LibraryMode get_libmode_for(const std::string &) const;
116 /** Updates the BuildInfo from another one. Lists are concatenated, with
117 the first occurrence of each item preserved. Scalars are overwritten.
119 The update level determines what information is updated. */
120 void update_from(const BuildInfo &, UpdateLevel = LOCAL);