]> git.tdb.fi Git - builder.git/commitdiff
Add support for specifying the language standard to use
authorMikko Rasa <tdb@tdb.fi>
Mon, 6 Oct 2014 20:49:40 +0000 (23:49 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 6 Oct 2014 21:00:15 +0000 (00:00 +0300)
source/buildinfo.cpp
source/buildinfo.h
source/gnucompiler.cpp

index 2246ad4b2d7a5ce97ac35997b951f427ab61982c..0e06a5908ff984d1e67def75d64e643106e47ace 100644 (file)
@@ -62,6 +62,8 @@ void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
                libmode = bi.libmode;
                for(LibModeMap::const_iterator i=bi.libmodes.begin(); i!=bi.libmodes.end(); ++i)
                        libmodes[i->first] = i->second;
+               for(StandardMap::const_iterator i=bi.standards.begin(); i!=bi.standards.end(); ++i)
+                       standards[i->first] = i->second;
                debug = bi.debug;
                optimize = bi.optimize;
                strip = bi.strip;
@@ -87,6 +89,7 @@ BuildInfo::Loader::Loader(BuildInfo &bi):
        add("libmode",  &Loader::libmode_for_lib);
        add("local_incpath", &Loader::local_incpath);
        add("optimize", &BuildInfo::optimize);
+       add("standard", &Loader::standard);
        add("strip",    &BuildInfo::strip);
        add("sysroot",  &Loader::sysroot);
        add("threads",  &BuildInfo::threads);
@@ -124,6 +127,11 @@ void BuildInfo::Loader::local_incpath(const string &s)
        obj.local_incpath.push_back(s);
 }
 
+void BuildInfo::Loader::standard(DataFile::Symbol tag, const string &std)
+{
+       obj.standards[tag.name] = std;
+}
+
 void BuildInfo::Loader::sysroot(const string &s)
 {
        obj.sysroot = s;
index 691ec549589889aeca464aab8be32c3c88892af0..0af7374575e1a5979111ea12c999d99e8a288b45 100644 (file)
@@ -32,6 +32,7 @@ public:
                void libpath(const std::string &);
                void library(const std::string &);
                void local_incpath(const std::string &);
+               void standard(Msp::DataFile::Symbol, const std::string &);
                void sysroot(const std::string &);
        };
        
@@ -72,6 +73,7 @@ public:
        typedef std::list<Msp::FS::Path> PathList;
        typedef std::list<std::string> WordList;
        typedef std::map<std::string, LibraryMode> LibModeMap;
+       typedef std::map<std::string, std::string> StandardMap;
 
        Tracked<Msp::FS::Path> sysroot;
        DefineMap defines;
@@ -81,6 +83,7 @@ public:
        WordList libs;
        Tracked<LibraryMode> libmode;
        LibModeMap libmodes;
+       StandardMap standards;
        Tracked<bool> threads;
        Tracked<bool> debug;
        Tracked<int> optimize;
index a86cb59d0567b06f4e88c07a72e2ddbd4dd17d49..051722832ea66402e515733fb51cd5c6ad78aa8e 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/core/maputils.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/utils.h>
 #include <msp/strings/format.h>
@@ -89,6 +90,12 @@ Task *GnuCompiler::run(const Target &target) const
        BuildInfo binfo;
        target.collect_build_info(binfo);
 
+       string tag_for_std = (tag=="OBJC" ? "CC" : tag);
+       if(binfo.standards.count(tag_for_std))
+               argv.push_back("-std="+get_item(binfo.standards, tag_for_std));
+       if(tag=="OBJC" && binfo.standards.count(tag))
+               argv.push_back("-fobjc-std="+get_item(binfo.standards, tag));
+
        if(binfo.warning_level>=1)
        {
                argv.push_back("-Wall");