diff options
Diffstat (limited to 'premake5.lua')
| -rw-r--r-- | premake5.lua | 104 |
1 files changed, 94 insertions, 10 deletions
diff --git a/premake5.lua b/premake5.lua index d0678d6..27a11e2 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,4 +1,5 @@ output_dir = "%{cfg.buildcfg}-%{cfg.system}" + include_dir = { glm = "ext/glm", glfw = "ext/glfw/include", @@ -20,12 +21,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 {} @@ -34,12 +63,38 @@ end function setup_cpp_target() setup_target() + filter { "system:macosx or system:linux" } + buildoptions { + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wconversion", + "-Wsign-conversion", + "-Wshadow", + } + 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 {} @@ -66,6 +121,39 @@ 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/** " .. + "--enable=warning,style,performance,portability " .. + "--error-exitcode=1" + ) + + if result ~= true and result ~= 0 then + error("cppcheck found issues") + end + end +} + workspace "donut" architecture "x64" startproject "donut" @@ -87,6 +175,7 @@ workspace "donut" filter {} group "dependencies" + project "glad" kind "StaticLib" language "C" @@ -215,6 +304,7 @@ project "glfw" "_CRT_SECURE_NO_WARNINGS", } filter {} + project "imgui" kind "StaticLib" language "C++" @@ -246,6 +336,7 @@ project "imgui" filter "system:windows" systemversion "latest" filter {} + project "imguizmo" kind "StaticLib" language "C++" @@ -268,6 +359,7 @@ project "imguizmo" filter "system:windows" systemversion "latest" filter {} + group "" project "donut" @@ -275,7 +367,7 @@ project "donut" language "C++" cppdialect "C++20" - setup_target() + setup_cpp_target() defines { "_CRT_SECURE_NO_WARNINGS", @@ -315,15 +407,6 @@ project "donut" "imguizmo", } - filter { "system:macosx or system:linux" } - buildoptions { - "-Wall", - "-Wextra", - "-Werror", - "-pedantic", - } - - filter {} filter { "system:macosx or system:linux", "files:src/platform/vulkan/**" } buildoptions "-Wno-missing-field-initializers" filter {} @@ -357,3 +440,4 @@ project "donut" filter "configurations:dist" defines "DONUT_DIST" filter {} + |
