Skip to content

Commit b0296bb

Browse files
committed
[SCons] Add option to build without threads
This is relevant for the Web platform, where builds with and without threads are incompatible.
1 parent 54fe2f9 commit b0296bb

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

test/project/example.gdextension

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ android.debug.arm64 = "res://bin/libgdexample.android.template_debug.arm64.so"
2929
android.release.arm64 = "res://bin/libgdexample.android.template_release.arm64.so"
3030
ios.debug = "res://bin/libgdexample.ios.template_debug.xcframework"
3131
ios.release = "res://bin/libgdexample.ios.template_release.xcframework"
32-
web.debug.wasm32 = "res://bin/libgdexample.web.template_debug.wasm32.wasm"
33-
web.release.wasm32 = "res://bin/libgdexample.web.template_release.wasm32.wasm"
32+
web.debug.threads.wasm32 = "res://bin/libgdexample.web.template_debug.wasm32.wasm"
33+
web.release.threads.wasm32 = "res://bin/libgdexample.web.template_release.wasm32.wasm"
34+
web.debug.wasm32 = "res://bin/libgdexample.web.template_debug.wasm32.nothreads.wasm"
35+
web.release.wasm32 = "res://bin/libgdexample.web.template_release.wasm32.nothreads.wasm"
3436

3537
[dependencies]
3638
ios.debug = {

tools/godotcpp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ def options(opts, env):
266266
)
267267
)
268268

269+
opts.Add(BoolVariable(key="threads", help="Enable threading support", default=env.get("threads", True)))
270+
269271
# compiledb
270272
opts.Add(
271273
BoolVariable(
@@ -393,6 +395,9 @@ def generate(env):
393395

394396
tool.generate(env)
395397

398+
if env["threads"]:
399+
env.Append(CPPDEFINES=["THREADS_ENABLED"])
400+
396401
if env.use_hot_reload:
397402
env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"])
398403

@@ -436,6 +441,8 @@ def generate(env):
436441
suffix += "." + env["arch"]
437442
if env["ios_simulator"]:
438443
suffix += ".simulator"
444+
if not env["threads"]:
445+
suffix += ".nothreads"
439446

440447
env["suffix"] = suffix # Exposed when included from another project
441448
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]

tools/web.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ def generate(env):
3535
env["SHLIBSUFFIX"] = ".wasm"
3636

3737
# Thread support (via SharedArrayBuffer).
38-
env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"])
39-
env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"])
38+
if env["threads"]:
39+
env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"])
40+
env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"])
4041

4142
# Build as side module (shared library).
4243
env.Append(CPPFLAGS=["-s", "SIDE_MODULE=1"])

0 commit comments

Comments
 (0)