From c49774454841bd5fda670e4aa26b1779595ee12f Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sun, 27 Oct 2024 20:06:39 +0100 Subject: [PATCH] Don't define DEBUG on non VS actions DEBUG is unused by pyrogenesis and unconditionally adding it to defines prevents building against a non debug version of spidermonkey. This will allow building only one copy of spidermonkey, which can be trivially be replaced with the other depending on needs independent of pyrogenesis debug or release build. This also allows to build either build configuration against system spidermonkey, which obviously is either one build type or the other. Requires a compilecheck until the pc file gets fixed upstream. A comment in the spidermonkey build.sh says on FreeBSD spidermonkey debug configuration doesn't even build and so pyrogenesis debug build wasn't possible either. Signed-off-by: Ralph Sennhauser --- build/premake/premake5.lua | 16 +++++++++++++++- build/premake/tests/mozdebug.c | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 build/premake/tests/mozdebug.c diff --git a/build/premake/premake5.lua b/build/premake/premake5.lua index fa27642edc..7b3f74fe64 100644 --- a/build/premake/premake5.lua +++ b/build/premake/premake5.lua @@ -117,6 +117,16 @@ elseif os.istarget("linux") then end end +-- Test whether system mozjs is built with --enable-debug +-- The pc file doesn't specify the required -DDEBUG needed in that case +local mozjs_is_debug_build = false +if _OPTIONS["with-system-mozjs"] then + local _, errorCode = os.outputof(cc .. " $(pkg-config mozjs-91 --cflags) ./tests/mozdebug.c -o /dev/null") + if errorCode ~= 0 then + mozjs_is_debug_build = true + end +end + -- Set up the Workspace workspace "pyrogenesis" targetdir(rootdir.."/binaries/system") @@ -175,7 +185,7 @@ function project_set_build_flags() debugenvs { "_NO_DEBUG_HEAP=1" } end - filter "Debug" + filter { "Debug", "action:vs*" } defines { "DEBUG" } filter "Release" @@ -189,6 +199,10 @@ function project_set_build_flags() filter { } + if mozjs_is_debug_build then + defines "DEBUG" + end + if _OPTIONS["gles"] then defines { "CONFIG2_GLES=1" } end diff --git a/build/premake/tests/mozdebug.c b/build/premake/tests/mozdebug.c new file mode 100644 index 0000000000..464d849e1e --- /dev/null +++ b/build/premake/tests/mozdebug.c @@ -0,0 +1,5 @@ +#include + +int main() { + return 0; +}