From d1a42f852e58918708b5b0cbd90219f6a95aa75b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 6 Oct 2014 23:49:40 +0300 Subject: [PATCH] Add support for specifying the language standard to use --- source/buildinfo.cpp | 8 ++++++++ source/buildinfo.h | 3 +++ source/gnucompiler.cpp | 7 +++++++ 3 files changed, 18 insertions(+) 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"); -- 2.43.0