diff options
Diffstat (limited to 'premake5.lua')
| -rw-r--r-- | premake5.lua | 88 |
1 files changed, 70 insertions, 18 deletions
diff --git a/premake5.lua b/premake5.lua index d8f2aec..178c730 100644 --- a/premake5.lua +++ b/premake5.lua @@ -9,12 +9,40 @@ end function setup_c_target() setup_target() + filter { "system:macosx or system:linux" } + buildoptions { + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wconversion", + "-Wsign-conversion", + "-Wshadow", + "-Wstrict-prototypes", + "-Wmissing-prototypes", + } + filter {} + filter "configurations:debug" runtime "Debug" symbols "On" + + filter { "system:macosx or system:linux" } + buildoptions { + "-g", + "-fno-omit-frame-pointer", + "-fsanitize=address,undefined", + } + + linkoptions { + "-fsanitize=address,undefined", + } + filter {} + filter { "configurations:release", "configurations:dist" } runtime "Release" optimize "Speed" + filter {} + filter "configurations:dist" symbols "Off" filter {} @@ -37,6 +65,40 @@ newaction { end } +newaction { + trigger = "check", + description = "Run static analysis with cppcheck", + + execute = function() + local result = os.execute("make clean") + + if result ~= true and result ~= 0 then + error("Failed to clean project") + end + + result = os.execute( + "bear -- make config=debug" + ) + + if result ~= true and result ~= 0 then + error("Failed to generate compile_commands.json") + end + + result = os.execute( + "cppcheck " .. + "--project=compile_commands.json " .. + "--file-filter=src/** " .. + "--file-filter=tests/** " .. + "--enable=warning,style,performance,portability " .. + "--error-exitcode=1" + ) + + if result ~= true and result ~= 0 then + error("cppcheck found issues") + end + end +} + workspace "hdass" architecture "x64" startproject "hdass" @@ -50,11 +112,14 @@ workspace "hdass" filter "system:windows" defines "HDASS_WINDOWS" + filter "system:linux" defines "HDASS_LINUX" + filter "system:macosx" architecture "ARM64" defines "HDASS_MACOS" + filter {} project "hdass" @@ -71,24 +136,18 @@ project "hdass" includedirs "src" - filter { "system:macosx or system:linux" } - buildoptions { - "-Wall", - "-Wextra", - "-Werror", - "-pedantic", - } - filter {} - filter "system:windows" systemversion "latest" filter "configurations:debug" defines "HDASS_DEBUG" + filter "configurations:release" defines "HDASS_RELEASE" + filter "configurations:dist" defines "HDASS_DIST" + filter {} project "tests" @@ -112,15 +171,8 @@ project "tests" "tests", } - filter { "system:macosx or system:linux" } - buildoptions { - "-Wall", - "-Wextra", - "-Werror", - "-pedantic", - } - filter {} - filter "system:windows" systemversion "latest" + filter {} + |
