]> git.tdb.fi Git - builder.git/blobdiff - source/buildinfo.h
Target::prepare shouldn't be virtual
[builder.git] / source / buildinfo.h
index ccd4b86798db7cc4a8c96eafffaef56c0ea82f82..9805e0a2ec0aa5d1c6f140d775e1c68019758225 100644 (file)
@@ -3,38 +3,70 @@
 
 #include <list>
 #include <string>
-#include <msp/parser/loader.h>
+#include <msp/datafile/objectloader.h>
 #include "misc.h"
 
+/**
+Stores information about compiler command line parameters in a more abstract
+form.  Allows combining with other BuildInfos to support package dependencies.
+*/
 class BuildInfo
 {
 public:
-       class Loader: public Msp::Parser::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
+       };
+
+       class Loader: public Msp::DataFile::ObjectLoader<BuildInfo>
        {
        public:
                Loader(BuildInfo &);
        private:
-               BuildInfo &binfo;
-               
-               void cflag(const std::string &s)   { binfo.cflags.push_back(s); }
-               void incpath(const std::string &s) { binfo.incpath.push_back(s); }
-               void define(const std::string &s)  { binfo.defines.push_back(s); }
-               void ldflag(const std::string &s)  { binfo.ldflags.push_back(s); }
-               void libpath(const std::string &s) { binfo.libpath.push_back(s); }
-               void library(const std::string &s) { binfo.libs.push_back(s); }
+               void incpath(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 &);
        };
        
-       StringList cflags;
-       StringList defines;
-       StringList incpath;
-       StringList ldflags;
-       StringList libpath;
-       StringList libs;
-
-       void add(const BuildInfo &);
-       void unique();
+       enum UpdateLevel
+       {
+               LOCAL,       //< Include all information
+               DEPENDENCY,  //< Include all but code generation options
+               CHAINED      //< Include only compilation options
+       };
+
+       typedef std::map<std::string, std::string> DefineMap;
+       typedef std::list<Msp::FS::Path> PathList;
+       typedef std::list<std::string> WordList;
+
+       DefineMap defines;
+       PathList incpath;
+       PathList libpath;
+       WordList libs;
+       LibraryMode libmode;
+       WordList warnings;
+       bool threads;
+       bool debug;
+       int optimize;
+       bool strip;
+
+       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);
+
 private:
-       void unique(StringList &);
+       /** 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