From e292d79fb344f312c2f29d137aeca66fcb5057b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 4 Oct 2021 11:24:58 +0200 Subject: [PATCH] SCons: Add `DEV_ENABLED` defines for `target=debug` builds This will allow adding developer checks which will be fully compiled out in user builds, unlike `DEBUG_ENABLED` which is included in debug tempates and the editor builds. This define is not used yet, but we'll soon add code that uses it, and change some existing `DEBUG_ENABLED` checks to be performed only in dev builds. Related to https://github.com/godotengine/godot-proposals/issues/3371. --- platform/android/detect.py | 2 +- platform/iphone/detect.py | 2 +- platform/javascript/detect.py | 1 + platform/osx/detect.py | 1 + platform/server/detect.py | 1 + platform/uwp/detect.py | 1 + platform/windows/detect.py | 2 ++ platform/x11/detect.py | 1 + 8 files changed, 9 insertions(+), 2 deletions(-) diff --git a/platform/android/detect.py b/platform/android/detect.py index c190fe701cf7..8aa9e83d210a 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -207,7 +207,7 @@ def mySpawn(sh, escape, cmd, args, env): elif env["target"] == "debug": env.Append(LINKFLAGS=["-O0"]) env.Append(CCFLAGS=["-O0", "-g", "-fno-limit-debug-info"]) - env.Append(CPPDEFINES=["_DEBUG", "DEBUG_ENABLED"]) + env.Append(CPPDEFINES=["_DEBUG", "DEBUG_ENABLED", "DEV_ENABLED"]) env.Append(CPPFLAGS=["-UNDEBUG"]) # Compiler configuration diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 288dafb6c3ef..77517b0fca07 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -62,7 +62,7 @@ def configure(env): elif env["target"] == "debug": env.Append(CCFLAGS=["-gdwarf-2", "-O0"]) - env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1), "DEBUG_ENABLED"]) + env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1), "DEBUG_ENABLED", "DEV_ENABLED"]) if env["use_lto"]: env.Append(CCFLAGS=["-flto"]) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index b527336f8313..4ba88db1ef41 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -81,6 +81,7 @@ def configure(env): env.Append(LINKFLAGS=["--profiling-funcs"]) else: # "debug" env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + env.Append(CPPDEFINES=["DEV_ENABLED"]) env.Append(CCFLAGS=["-O1", "-g"]) env.Append(LINKFLAGS=["-O1", "-g"]) env["use_assertions"] = True diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 409c0e11957a..49b41a91e885 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -66,6 +66,7 @@ def configure(env): elif env["target"] == "debug": env.Prepend(CCFLAGS=["-g3"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) + env.Prepend(CPPDEFINES=["DEV_ENABLED"]) env.Prepend(LINKFLAGS=["-Xlinker", "-no_deduplicate"]) ## Architecture diff --git a/platform/server/detect.py b/platform/server/detect.py index 6b92553ae5c3..f479fcc9e87d 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -74,6 +74,7 @@ def configure(env): elif env["target"] == "debug": env.Prepend(CCFLAGS=["-g3"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) + env.Prepend(CPPDEFINES=["DEV_ENABLED"]) env.Append(LINKFLAGS=["-rdynamic"]) ## Architecture diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 564001df0d14..4f883b6e824f 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -71,6 +71,7 @@ def configure(env): env.Append(CCFLAGS=["/Zi"]) env.Append(CCFLAGS=["/MDd"]) env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + env.Append(CPPDEFINES=["DEV_ENABLED"]) env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) env.Append(LINKFLAGS=["/DEBUG"]) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 81e7cd1f7776..bde5087b810b 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -199,6 +199,7 @@ def configure_msvc(env, manual_msvc_config): elif env["target"] == "debug": env.AppendUnique(CCFLAGS=["/Zi", "/FS", "/Od", "/EHsc"]) env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED"]) + env.AppendUnique(CPPDEFINES=["DEV_ENABLED"]) env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) env.Append(LINKFLAGS=["/DEBUG"]) @@ -334,6 +335,7 @@ def configure_mingw(env): elif env["target"] == "debug": env.Append(CCFLAGS=["-g3"]) env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + env.Append(CPPDEFINES=["DEV_ENABLED"]) ## Compiler configuration diff --git a/platform/x11/detect.py b/platform/x11/detect.py index fd939f6c7e12..04bf09209b74 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -113,6 +113,7 @@ def configure(env): env.Prepend(CCFLAGS=["-ggdb"]) env.Prepend(CCFLAGS=["-g3"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) + env.Prepend(CPPDEFINES=["DEV_ENABLED"]) env.Append(LINKFLAGS=["-rdynamic"]) ## Architecture