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