Skip to content

Commit

Permalink
Added web support and wasm binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-maltbie committed Sep 20, 2023
1 parent 0279705 commit 9322e9f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gdextension_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
target: [template_debug, template_release]

env:
EM_VERSION: 1.39.18
EM_VERSION: 3.1.46

steps:
- name: Checkout
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 19 additions & 5 deletions patches/fixed_javascript_build.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
diff --git a/tools/javascript.py b/tools/javascript.py
index 42c601d..2dbb4dc 100644
index 42c601d..8fcb921 100644
--- a/tools/javascript.py
+++ b/tools/javascript.py
@@ -1,8 +1,8 @@
@@ -1,18 +1,14 @@
import os
-
+from SCons.Util import WhereIs

def exists(env):
- return "EM_CONFIG" in os.environ
-
+ return WhereIs("emcc") is not None


def generate(env):
@@ -10,9 +10,6 @@ def generate(env):
if env["arch"] not in ("wasm32"):
print("Only wasm32 supported on web. Exiting.")
Exit()

Expand All @@ -23,7 +23,21 @@ index 42c601d..2dbb4dc 100644
env["CC"] = "emcc"
env["CXX"] = "em++"
env["AR"] = "emar"
@@ -39,9 +36,9 @@ def generate(env):
@@ -26,6 +22,13 @@ def generate(env):
env["ARCOM_POSIX"] = env["ARCOM"].replace("$TARGET", "$TARGET.posix").replace("$SOURCES", "$SOURCES.posix")
env["ARCOM"] = "${TEMPFILE(ARCOM_POSIX)}"

+ # Thread support (via SharedArrayBuffer).
+ env.Append(CPPDEFINES=["PTHREAD_NO_RENAME"])
+ env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"])
+ env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"])
+ env.Append(LINKFLAGS=["-s", "PTHREAD_POOL_SIZE=8"])
+ env.Append(LINKFLAGS=["-s", "WASM_MEM_MAX=2048MB"])
+
# All intermediate files are just LLVM bitcode.
env["OBJPREFIX"] = ""
env["OBJSUFFIX"] = ".bc"
@@ -39,9 +42,9 @@ def generate(env):
env.Replace(SHLINKFLAGS="$LINKFLAGS")
env.Replace(SHLINKFLAGS="$LINKFLAGS")

Expand Down

0 comments on commit 9322e9f

Please sign in to comment.