aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--backend/ninja/Ninja.cpp8
-rw-r--r--include/Conf.hpp2
-rw-r--r--src/Conf.cpp18
4 files changed, 32 insertions, 0 deletions
diff --git a/README.md b/README.md
index d776c31..b6b562a 100644
--- a/README.md
+++ b/README.md
@@ -115,6 +115,7 @@ BOOST_COMPILE_DYNAMIC = "1"
include_dirs = ["include"]
ignore_dirs = ["examples"]
expose_include_dirs = ["include"]
+error_on_warning = "true"
[config.win32.static.debug]
lib = "windows/x86/static/debug"
@@ -192,6 +193,9 @@ Optional. A list of directories which should be specified as global include dire
Optional. A list of directories to ignore. This means that if the ignored directory contains source files, then they wont be included in the build
### expose_include_dirs
Optional. A list of directories which contains (header) files which should be exposed to dependencies as directories to include globally. This means that dependencies can include (header) files from the dependency without specifying path to the dependency
+### error_on_warning
+Optional. This option should be either "true" or "false" and specifies if compiler warnings for the project (and not its dependencies) should work warnings as errors.
+Default value is "false".
## config.*
Optional. The name is structured in the following way: config.platform.libraryType.optimizationLevel
where platform is any of the platforms specified under \[package] (or if package contains "any", then it can be any other platform). LibraryType is either "static" or "dynamic" - different configurations depending on if the package is included as a static or dynamic library by a dependant package. OptimizationLevel is either "debug" or "release", depending on which optimization level the "root" package was built with ("root" package is usually the project which is an executable)
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index e05b7b9..69b480e 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -1013,6 +1013,11 @@ namespace backend
compileCCommand.push_back(ninja::NinjaArg("-w"));
}
+ if(config.errorOnWarning)
+ {
+ compileCCommand.push_back(ninja::NinjaArg("-Werror"));
+ }
+
vector<ninja::NinjaArg> optimizationFlags = getCompilerOptimizationFlags(config);
compileCCommand.insert(compileCCommand.end(), optimizationFlags.begin(), optimizationFlags.end());
@@ -1049,6 +1054,9 @@ namespace backend
else
compileCCommand.push_back(ninja::NinjaArg("/w"));
+ if(config.errorOnWarning)
+ compileCCommand.push_back(ninja::NinjaArg("/WX"));
+
// TODO: Remove this once locate_windows_sdk has been updated to locate multiple arch windows sdk
#if OS_TYPE == OS_TYPE_WINDOWS && defined(SIBS_ENV_32BIT)
#error "sibs is currently not supported on windows 32-bit because locate_windows_sdk can only locate x64 windows sdk"
diff --git a/include/Conf.hpp b/include/Conf.hpp
index 03b2e46..892b7b6 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -216,6 +216,7 @@ namespace sibs
mainProject(false),
sanitize(false),
showWarnings(false),
+ errorOnWarning(false),
zigTestAllFiles(false),
packaging(false),
bundling(false),
@@ -412,6 +413,7 @@ namespace sibs
std::vector<FileString> zigTestFiles;
bool showWarnings;
+ bool errorOnWarning;
bool zigTestAllFiles;
bool packaging;
bool bundling;
diff --git a/src/Conf.cpp b/src/Conf.cpp
index 1962517..e3c894a 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -1067,6 +1067,24 @@ namespace sibs
else
throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".ignore_dirs to be a list, was a single value");
}
+ else if(name.equals("error_on_warning"))
+ {
+ if (value.isSingle())
+ {
+ StringView value_str = value.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) + ".error_on_warning to be either true or false");
+
+ errorOnWarning = value_bool;
+ }
+ else
+ throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".error_on_warning to be a single value, was a list");
+ }
else
failInvalidFieldUnderObject(name);
}