diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-16 11:47:19 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-22 12:45:46 +0200 |
commit | bf1c03ab5f079d0931cf4390e7435a20cfaacfbd (patch) | |
tree | edc6f759871b75909539b829a809dfc7b89b93d2 /tools | |
parent | 0a6a19e33bb75d9f6f23adf16b4e695d009b0fc6 (diff) | |
download | redot-cpp-bf1c03ab5f079d0931cf4390e7435a20cfaacfbd.tar.gz |
SCons: Disable C++ exception handling by default
Counterpart to https://github.com/godotengine/godot/pull/80612.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/godotcpp.py | 16 | ||||
-rw-r--r-- | tools/windows.py | 2 |
2 files changed, 17 insertions, 1 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): diff --git a/tools/windows.py b/tools/windows.py index e156aef..d5a729c 100644 --- a/tools/windows.py +++ b/tools/windows.py @@ -31,7 +31,7 @@ def generate(env): env.Tool("mslink") env.Append(CPPDEFINES=["TYPED_METHOD_BIND", "NOMINMAX"]) - env.Append(CCFLAGS=["/EHsc", "/utf-8"]) + env.Append(CCFLAGS=["/utf-8"]) env.Append(LINKFLAGS=["/WX"]) if env["use_clang_cl"]: |