Skip to content

Commit 340dde3

Browse files
authored
Merge pull request #1451 from Faless/build/to_threads_or_not_to_threads
[SCons] Add option to build without threads
2 parents 6b39ed0 + b0296bb commit 340dde3

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(
@@ -438,6 +440,9 @@ def generate(env):
438440

439441
tool.generate(env)
440442

443+
if env["threads"]:
444+
env.Append(CPPDEFINES=["THREADS_ENABLED"])
445+
441446
if env.use_hot_reload:
442447
env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"])
443448

@@ -481,6 +486,8 @@ def generate(env):
481486
suffix += "." + env["arch"]
482487
if env["ios_simulator"]:
483488
suffix += ".simulator"
489+
if not env["threads"]:
490+
suffix += ".nothreads"
484491

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