aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Conf.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp
index f8b53e3..9f63833 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -792,6 +792,14 @@ namespace sibs
{
parseCmake(name, value, cmakeDirDynamic, cmakeArgsDynamic);
}
+ else if(currentObject.equals("lang.c"))
+ {
+ parseCLang(name, value);
+ }
+ else if(currentObject.equals("lang.cpp"))
+ {
+ parseCppLang(name, value);
+ }
else
{
string errMsg = "Invalid config object \"";
@@ -801,6 +809,74 @@ namespace sibs
}
}
+ void SibsConfig::parseCLang(const StringView &fieldName, const ConfigValue &fieldValue)
+ {
+ if(fieldName.equals("version"))
+ {
+ // TODO: Support several versions (a list of versions where the latest possible version is used)?
+ if(fieldValue.isSingle())
+ {
+ const StringView &cVersionStr = fieldValue.asSingle();
+ if(cVersionStr.equals("c89") || cVersionStr.equals("ansi"))
+ {
+ cVersion = CVersion::C89;
+ }
+ else if(cVersionStr.equals("c99"))
+ {
+ cVersion = CVersion::C99;
+ }
+ else if(cVersionStr.equals("c11"))
+ {
+ cVersion = CVersion::C11;
+ }
+ else
+ {
+ string errMsg = "Expected lang.c.version to be c89, c99 or c11, was ";
+ errMsg += string(cVersionStr.data, cVersionStr.size);
+ throw ParserException(errMsg);
+ }
+ }
+ else
+ throw ParserException("Expected lang.c.version to be a single value, was a list");
+ }
+ else
+ failInvalidFieldUnderObject(fieldName);
+ }
+
+ void SibsConfig::parseCppLang(const StringView &fieldName, const ConfigValue &fieldValue)
+ {
+ if(fieldName.equals("version"))
+ {
+ // TODO: Support several versions (a list of versions where the latest possible version is used)?
+ if(fieldValue.isSingle())
+ {
+ const StringView &cppVersionStr = fieldValue.asSingle();
+ if(cppVersionStr.equals("c++11"))
+ {
+ cppVersion = CPPVersion::CPP11;
+ }
+ else if(cppVersionStr.equals("c++14"))
+ {
+ cppVersion = CPPVersion::CPP14;
+ }
+ else if(cppVersionStr.equals("c++17"))
+ {
+ cppVersion = CPPVersion::CPP17;
+ }
+ else
+ {
+ string errMsg = "Expected lang.cpp.version to be c89, c99 or c11, was ";
+ errMsg += string(cppVersionStr.data, cppVersionStr.size);
+ throw ParserException(errMsg);
+ }
+ }
+ else
+ throw ParserException("Expected lang.cpp.version to be a single value, was a list");
+ }
+ else
+ failInvalidFieldUnderObject(fieldName);
+ }
+
void SibsConfig::parsePlatformConfigs(const StringView &fieldName, const ConfigValue &fieldValue)
{
for(int i = 0; i < NUM_CONFIGS; ++i)