Skip to content

Commit

Permalink
fix emscripten to sdk-1.37.40-64bit for now, because later versions r…
Browse files Browse the repository at this point in the history
…equire updates I dont have time for now
  • Loading branch information
ianmaclarty committed Sep 17, 2019
1 parent e68f9ed commit 4efda2b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ C99_OPT = -std=c99

EMSCRIPTEN_LIBS = html/library_sdl.js
EMSCRIPTEN_LIBS_OPTS = $(patsubst %,--js-library %,$(EMSCRIPTEN_LIBS))
EMSCRIPTEN_EXPORTS_OPT = -s EXPORTED_FUNCTIONS="['_main', '_am_emscripten_run', '_am_emscripten_run_waiting', '_am_emscripten_pause', '_am_emscripten_resume', '_am_emscripten_resize']" -s EXTRA_EXPORTED_RUNTIME_METHODS="['Pointer_stringify', 'ccall', 'writeStringToMemory']" -s BINARYEN_TRAP_MODE=clamp
EMSCRIPTEN_EXPORTS_OPT = -s EXPORTED_FUNCTIONS="['_main', '_am_emscripten_run', '_am_emscripten_run_waiting', '_am_emscripten_pause', '_am_emscripten_resume', '_am_emscripten_resize']" -s EXTRA_EXPORTED_RUNTIME_METHODS="['Pointer_stringify', 'ccall', 'stringToUTF8', 'lengthBytesUTF8']" -s BINARYEN_TRAP_MODE=clamp

TARGET_CFLAGS=-ffast-math

Expand Down
2 changes: 1 addition & 1 deletion scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ else

# build emscripten
# (building on osx, because the pre-built llvm binaries don't work on linux due to incompatible glibc version)
EMSDK=latest
EMSDK=sdk-1.37.40-64bit
git clone https://github.com/juj/emsdk.git emscripten
cd emscripten
./emsdk install $EMSDK
Expand Down
5 changes: 3 additions & 2 deletions src/am_browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ static int eval_js(lua_State *L) {
} else {
res_str = JSON.stringify(res);
}
var buffer = Module._malloc(res_str.length+1);
Module.writeStringToMemory(res_str, buffer);
var len = Module.lengthBytesUTF8(res_str) + 1;
var buffer = Module._malloc(len);
Module.stringToUTF8(res_str, buffer, len);
return buffer;
}, (int)js);
char *res_str = (char*)res_ptr;
Expand Down
5 changes: 3 additions & 2 deletions src/am_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ static void get_response(lua_State *L, void *obj) {
var xhr = window.amulet.http_reqs[$0];
var txt = xhr.responseText;
if (txt == null) return 0;
var buffer = Module._malloc(txt.length+1);
Module.writeStringToMemory(txt, buffer);
var len = Module.lengthBytesUTF8(txt) + 1;
var buffer = Module._malloc(len);
Module.stringToUTF8(txt, buffer, len);
return buffer;
}, req->id);
if (text_ptr == 0) {
Expand Down

0 comments on commit 4efda2b

Please sign in to comment.