X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.h;h=f84315c74369b7b73f6f4e839ff0a8701193627f;hb=3938f8030b1f62802decce19777ce70fdafaff10;hp=a967bbd7535aa7b83256856092fb867c2ab1fd6f;hpb=242c55b17e6608b29a77ca17a5b677e202a3ca90;p=builder.git diff --git a/source/buildinfo.h b/source/buildinfo.h index a967bbd..f84315c 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -1,17 +1,10 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef BUILDINFO_H_ #define BUILDINFO_H_ #include #include -#include -#include "misc.h" +#include +#include /** Stores information about compiler command line parameters in a more abstract @@ -20,37 +13,112 @@ form. Allows combining with other BuildInfos to support package dependencies. class BuildInfo { public: - class Loader: public Msp::DataFile::Loader + 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 { - private: - BuildInfo &binfo; - public: Loader(BuildInfo &); private: - void cflag(const std::string &); void incpath(const std::string &); - void define(const std::string &); - void ldflag(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 + { + LOCAL, //< Include all information + DEPENDENCY, //< Include all but code generation options + CHAINED //< Include only compilation options }; + + struct LanguageStandard + { + std::string type; + unsigned year; + + LanguageStandard(): year(0) { } + 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; + + public: + Tracked(): value(T()), set(false) { } + Tracked(T v): value(v), set(false) { } + Tracked(const Tracked &t): value(t.value), set(t.set) { } + Tracked &operator=(const Tracked &v) { if(v.set) { value = v.value; set = true; } return *this; } + + Tracked &operator=(const T &v) { value = v; set = true; return *this; } + operator const T &() const { return value; } + }; + + Tracked sysroot; + std::map defines; + std::list incpath; + std::list local_incpath; + std::list libpath; + std::list libs; + Tracked libmode; + Tracked rpath_mode; + std::map libmodes; + std::list keep_symbols; + std::map standards; + Tracked threads; + Tracked debug; + Tracked optimize; + Tracked strip; + Tracked warning_level; + Tracked fatal_warnings; + + BuildInfo(); + + /** 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. - StringList cflags; - StringList defines; - StringList incpath; - StringList ldflags; - StringList libpath; - StringList libs; - StringList warnings; - - /** Adds another BuildInfo to the end of this one. */ - void add(const BuildInfo &); - - /** 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(); + The update level determines what information is updated. */ + void update_from(const BuildInfo &, UpdateLevel = LOCAL); }; #endif