From: Mikko Rasa Date: Mon, 6 Oct 2014 20:49:40 +0000 (+0300) Subject: Add support for specifying the language standard to use X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;h=d1a42f852e58918708b5b0cbd90219f6a95aa75b;hp=11b4732f81396aa3d8b0fc8928b8e1981032e743;p=builder.git Add support for specifying the language standard to use --- diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 2246ad4..0e06a59 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -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; diff --git a/source/buildinfo.h b/source/buildinfo.h index 691ec54..0af7374 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -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 PathList; typedef std::list WordList; typedef std::map LibModeMap; + typedef std::map StandardMap; Tracked sysroot; DefineMap defines; @@ -81,6 +83,7 @@ public: WordList libs; Tracked libmode; LibModeMap libmodes; + StandardMap standards; Tracked threads; Tracked debug; Tracked optimize; diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index a86cb59..0517228 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -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");