X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.h;h=26afabffd4db6f323824ddeba99f98954c78c926;hb=d1f9551e05c9d341149eb490e05b1465d3d6b711;hp=18f33a093676a2d98c54b4a3c2c9a338d8c10df7;hpb=243d7c7355c1c5d9a0134440f340936325caaf88;p=builder.git diff --git a/source/buildinfo.h b/source/buildinfo.h index 18f33a0..26afabf 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -1,10 +1,10 @@ #ifndef BUILDINFO_H_ #define BUILDINFO_H_ -#include #include +#include #include -#include "misc.h" +#include /** Stores information about compiler command line parameters in a more abstract @@ -13,6 +13,21 @@ form. Allows combining with other BuildInfos to support package dependencies. class BuildInfo { public: + enum LibraryMode + { + FORCE_STATIC, //< Only accept static libraries + STATIC, //< Prefer static libraries but accept dynamic as well + DYNAMIC, //< Prefer dynamic libraries but accept static as well + FORCE_DYNAMIC //< Only accept dynamic libraries + }; + + enum RuntimePathMode + { + NO_RPATH, //< Do not record rpath in binaries + RELATIVE, //< Record relative rpath in binaries + ABSOLUTE //< Record absolute rpath in binaries + }; + class Loader: public Msp::DataFile::ObjectLoader { public: @@ -20,9 +35,13 @@ public: private: void incpath(const std::string &); void define(const std::string &, const std::string &); + void keep_symbol(const std::string &); + void libmode_for_lib(const std::string &, LibraryMode); void libpath(const std::string &); void library(const std::string &); - void warning(const std::string &); + void local_incpath(const std::string &); + void standard(Msp::DataFile::Symbol, const std::string &); + void sysroot(const std::string &); }; enum UpdateLevel @@ -32,29 +51,72 @@ public: CHAINED //< Include only compilation options }; - typedef std::map DefineMap; + struct LanguageStandard + { + std::string type; + unsigned year = 0; + + LanguageStandard() = default; + LanguageStandard(const std::string &); + + std::string str() const; + }; + + /** + A wrapper which tracks the set status of the wrapped variable. A default + value may be provided in initialization without causing it to be treated as + set. Assigning from a raw value flags the Tracked object as set. Assigning + from another Tracked object will only change the value of the target if the + source is set. + */ + template + class Tracked + { + public: + using LoadType = T; + + private: + T value{}; + bool set = false; + + public: + Tracked() = default; + Tracked(T v): value(v) { } + Tracked(const Tracked &t) = default; + Tracked &operator=(const Tracked &v) { if(v.set) { value = v.value; set = true; } return *this; } - DefineMap defines; - StringList incpath; - StringList libpath; - StringList libs; - StringList warnings; - bool threads; - bool debug; - int optimize; - bool strip; + Tracked &operator=(const T &v) { value = v; set = true; return *this; } + operator const T &() const { return value; } + }; - BuildInfo(); + Tracked sysroot; + std::map defines; + std::vector incpath; + std::vector local_incpath; + std::vector libpath; + std::vector libs; + Tracked libmode = DYNAMIC; + Tracked rpath_mode = NO_RPATH; + std::map libmodes; + std::vector keep_symbols; + std::map standards; + Tracked threads = false; + Tracked debug = false; + Tracked optimize = 0; + Tracked strip = false; + Tracked warning_level = 0; + Tracked fatal_warnings = false; + + /** Returns the library mode for linking a particular library. If no mode + has been specified for that library, the the global library mode is + returned. */ + LibraryMode get_libmode_for(const std::string &) const; /** Updates the BuildInfo from another one. Lists are concatenated, with the first occurrence of each item preserved. Scalars are overwritten. The update level determines what information is updated. */ void update_from(const BuildInfo &, UpdateLevel = LOCAL); - - /** Makes sure there are no duplicate entries in the lists. For warnings, - contradicting flags are eliminated and the last one stays in effect. */ - void unique(); }; #endif