From 445fd7c1968112664b1fbbe6215ed76609cfb8ac Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 21 Oct 2021 11:06:17 +0200 Subject: Add lang.cpp.enable_exceptions option to enable/disable options, add c20, add c++03, c++98 and c++20 --- src/Conf.cpp | 40 +++++++++++++++++++++++++++++++++++++--- src/main.cpp | 6 ++++++ 2 files changed, 43 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Conf.cpp b/src/Conf.cpp index 543c8d9..c2302e4 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -1125,9 +1125,13 @@ namespace sibs { cVersion = CVersion::C11; } + else if(cVersionStr.equals("c20")) + { + cVersion = CVersion::C20; + } else { - string errMsg = "Expected lang.c.version to be ansi, c89, c99 or c11, was "; + string errMsg = "Expected lang.c.version to be ansi, c89, c99, c11, c20, was "; errMsg += string(cVersionStr.data, cVersionStr.size); throw ParserException(errMsg); } @@ -1147,7 +1151,15 @@ namespace sibs if(fieldValue.isSingle()) { const StringView &cppVersionStr = fieldValue.asSingle(); - if(cppVersionStr.equals("c++11")) + if(cppVersionStr.equals("c++03")) + { + cppVersion = CPPVersion::CPP03; + } + else if(cppVersionStr.equals("c++98")) + { + cppVersion = CPPVersion::CPP98; + } + else if(cppVersionStr.equals("c++11")) { cppVersion = CPPVersion::CPP11; } @@ -1159,9 +1171,13 @@ namespace sibs { cppVersion = CPPVersion::CPP17; } + else if(cppVersionStr.equals("c++20")) + { + cppVersion = CPPVersion::CPP20; + } else { - string errMsg = "Expected lang.cpp.version to be c++11, c++14 or c++17, was "; + string errMsg = "Expected lang.cpp.version to be c++03, c++98, c++11, c++14, c++17 or c++20, was "; errMsg += string(cppVersionStr.data, cppVersionStr.size); throw ParserException(errMsg); } @@ -1169,6 +1185,24 @@ namespace sibs else throw ParserException("Expected lang.cpp.version to be a single value, was a list"); } + else if(fieldName.equals("enable_exceptions")) + { + if (fieldValue.isSingle()) + { + StringView value_str = fieldValue.asSingle(); + bool value_bool = false; + if(value_str.equals("true")) + value_bool = true; + else if(value_str.equals("false")) + value_bool = false; + else + throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".enable_exceptions to be either true or false"); + + enableExceptions = value_bool; + } + else + throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".enable_exceptions to be a single value, was a list"); + } else failInvalidFieldUnderObject(fieldName); } diff --git a/src/main.cpp b/src/main.cpp index 5c3ad8c..00b7e92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -368,6 +368,12 @@ static int buildProject(const FileString &projectPath, const FileString &project { FileString buildPath; readSibsConfig(projectPath, projectConfFilePath, sibsConfig, buildPath); + + if(run && sibsConfig.getPackageType() != PackageType::EXECUTABLE) { + ferr << "Error: sibs run can only be used with executable projects" << endl; + exit(7); + } + // Test project has the main project as dependency, and therefore the main project can't be built as an executable if(sibsConfig.shouldBuildTests()) { -- cgit v1.2.3