Skip to content

Commit a17134c

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 a17134c

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ def options(opts, env):
266266
)
267267
)
268268

269+
opts.Add(
270+
BoolVariable(
271+
key="threads",
272+
help="Enable threading support",
273+
default=env.get("threads", True)
274+
)
275+
)
276+
269277
# compiledb
270278
opts.Add(
271279
BoolVariable(
@@ -393,6 +401,9 @@ def generate(env):
393401

394402
tool.generate(env)
395403

404+
if env["threads"]:
405+
env.Append(CPPDEFINES=["THREADS_ENABLED"])
406+
396407
if env.use_hot_reload:
397408
env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"])
398409

@@ -436,6 +447,8 @@ def generate(env):
436447
suffix += "." + env["arch"]
437448
if env["ios_simulator"]:
438449
suffix += ".simulator"
450+
if not env["threads"]:
451+
suffix += ".nothreads"
439452

440453
env["suffix"] = suffix # Exposed when included from another project
441454
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)