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
+ };
+
class Loader: public Msp::DataFile::ObjectLoader<BuildInfo>
{
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 libpath(const std::string &);
void library(const std::string &);
- void warning(const std::string &);
};
enum UpdateLevel
{
- LOCAL,
- DEPENDENCY,
- CHAINED
+ LOCAL, //< Include all information
+ DEPENDENCY, //< Include all but code generation options
+ CHAINED //< Include only compilation options
};
- StringList cflags;
- StringList defines;
- StringList incpath;
- StringList ldflags;
- StringList libpath;
- StringList libs;
- StringList warnings;
+ /**
+ 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<typename T>
+ class Tracked
+ {
+ public:
+ typedef T LoadType;
+
+ private:
+ T value;
+ bool set;
- /** Adds another BuildInfo to the end of this one. */
- void update_from(const BuildInfo &, UpdateLevel = LOCAL);
+ public:
+ Tracked(): value(T()), set(false) { }
+ Tracked(T v): value(v), set(false) { }
+ Tracked &operator=(const Tracked &v) { if(v.set) { value = v.value; set = true; } return *this; }
+
+ Tracked &operator=(T v) { value = v; set = true; return *this; }
+ operator T() const { return value; }
+ };
+
+ typedef std::map<std::string, std::string> DefineMap;
+ typedef std::list<Msp::FS::Path> PathList;
+ typedef std::list<std::string> WordList;
- /** 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();
+ DefineMap defines;
+ PathList incpath;
+ PathList libpath;
+ WordList libs;
+ Tracked<LibraryMode> libmode;
+ Tracked<bool> threads;
+ Tracked<bool> debug;
+ Tracked<int> optimize;
+ Tracked<bool> strip;
+ Tracked<unsigned> warning_level;
+ Tracked<bool> fatal_warnings;
+
+ BuildInfo();
+
+ /** 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);
};
#endif