summaryrefslogtreecommitdiffstats
path: root/tools/godotcpp.py
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-10-22 10:06:34 -0500
committerGitHub <noreply@github.com>2023-10-22 10:06:34 -0500
commit379ce2b5e5dd5d15bf0a633f86f60686dee35176 (patch)
treeedc6f759871b75909539b829a809dfc7b89b93d2 /tools/godotcpp.py
parent0a6a19e33bb75d9f6f23adf16b4e695d009b0fc6 (diff)
parentbf1c03ab5f079d0931cf4390e7435a20cfaacfbd (diff)
downloadredot-cpp-379ce2b5e5dd5d15bf0a633f86f60686dee35176.tar.gz
Merge pull request #1216 from akien-mga/scons-disable-exception-handling
SCons: Disable C++ exception handling by default
Diffstat (limited to 'tools/godotcpp.py')
-rw-r--r--tools/godotcpp.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/godotcpp.py b/tools/godotcpp.py
index 329fffc..8e7e1c6 100644
--- a/tools/godotcpp.py
+++ b/tools/godotcpp.py
@@ -183,6 +183,12 @@ def options(opts, env):
)
)
+ opts.Add(
+ BoolVariable(
+ "disable_exceptions", "Force disabling exception handling code", default=env.get("disable_exceptions", True)
+ )
+ )
+
# Add platform options
for pl in platforms:
tool = Tool(pl, toolpath=["tools"])
@@ -242,6 +248,16 @@ def generate(env):
if env["use_hot_reload"]:
env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"])
+ # Disable exception handling. Godot doesn't use exceptions anywhere, and this
+ # saves around 20% of binary size and very significant build time.
+ if env["disable_exceptions"]:
+ if env.get("is_msvc", False):
+ env.Append(CPPDEFINES=[("_HAS_EXCEPTIONS", 0)])
+ else:
+ env.Append(CXXFLAGS=["-fno-exceptions"])
+ elif env.get("is_msvc", False):
+ env.Append(CXXFLAGS=["/EHsc"])
+
tool = Tool(env["platform"], toolpath=["tools"])
if tool is None or not tool.exists(env):