summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authoreska <eska@eska.me>2016-11-11 03:58:03 +0100
committereska <eska@eska.me>2016-11-13 15:29:03 +0100
commit82addf2ffe18c49d437ee6d425e3470817f0dc85 (patch)
tree04848c780b95e5929d972342d568593a05220253 /platform
parent31f929caa2bc8422c0a6bb50f81500e1f4db101b (diff)
Enable memory growth in WebAssembly builds
This allows setting TOTAL_MEMORY during runtime at the cost of reserving a bit more memory.
Diffstat (limited to 'platform')
-rw-r--r--platform/javascript/detect.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 9bc204a94a..1ee3358888 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -76,6 +76,7 @@ def configure(env):
if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
env.opus_fixed_point = "yes"
+ # These flags help keep the file size down
env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti'])
env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS'])
env.Append(CPPFLAGS=['-DGLES2_ENABLED'])
@@ -86,6 +87,12 @@ def configure(env):
if env['wasm'] == 'yes':
env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
env.Append(LINKFLAGS=['-s', '\'BINARYEN_METHOD="native-wasm"\''])
+ # Maximum memory size is baked into the WebAssembly binary during
+ # compilation, so we need to enable memory growth to allow setting
+ # TOTAL_MEMORY at runtime. The value set at runtime must be higher than
+ # what is set during compilation, check TOTAL_MEMORY in Emscripten's
+ # src/settings.js for the default.
+ env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
env["PROGSUFFIX"] += ".webassembly"
else:
env.Append(CPPFLAGS=['-s', 'ASM_JS=1'])