Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit a79b58c

Browse files
committed
Add script for installing emscripten
1 parent afd2299 commit a79b58c

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build
44
.clang_complete
55

66
/browser.js
7+
emsdk_portable

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
test
22
build
33
.gitignore
4+
emsdk_portable

package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@
66
"browser": "./browser",
77
"scripts": {
88
"build:node": "node-gyp configure build",
9-
"build:browser": "em++ --bind -o browser.js -O3 -std=c++14 -I src/bindings/em -I src/core --pre-js src/bindings/em/prologue.js --post-js src/bindings/em/epilogue.js src/core/*.cc src/bindings/em/*.cc -s TOTAL_MEMORY=134217728 --memory-init-file 0",
10-
"build:browser:maybe": "test -f browser.js || test -n \"$CI\" || ! command -v em++ 2>&1 > /dev/null || npm run build:browser",
11-
"build:all": "npm run build:node && npm run build:browser",
12-
"install": "npm run build:node && npm run build:browser:maybe",
13-
"test-native": "script/test-native.js",
9+
"build:browser": "script/build-browser-version.sh",
10+
"build": "npm run build:node && npm run build:browser",
11+
"test:native": "script/test-native.js",
1412
"test:node": "mocha test/js/*.js",
1513
"test:browser": "FORCE_BROWSER_FALLBACK=1 mocha test/js/*.js",
16-
"test:all": "npm run test:node && npm run test:browser",
17-
"test": "npm run test:all",
14+
"test": "npm run test:node && npm run test:browser",
1815
"benchmark": "node benchmark/marker-index.benchmark.js",
19-
"prepublish": "npm run standard",
16+
"prepublish": "not-in-install && npm run build:browser || in-install",
2017
"standard": "standard --recursive src test",
21-
"ci": "npm run standard && node-gyp rebuild --debug --tests && npm run test"
18+
"ci": "script/install-emscripten.sh && npm run standard && node-gyp rebuild --debug --tests && npm run test"
2219
},
2320
"repository": {
2421
"type": "git",
@@ -39,6 +36,7 @@
3936
},
4037
"devDependencies": {
4138
"chai": "^2.0.0",
39+
"in-publish": "^2.0.0",
4240
"mocha": "^2.3.4",
4341
"random-seed": "^0.2.0",
4442
"segfault-handler": "^1.0.0",

script/build-browser-version.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
EM_COMPILER_PATH=$(find ./emsdk_portable/emscripten -name em++ | head -n1)
4+
5+
ONEONEONEONE
6+
echo "Running ${EM_COMPILER_PATH}"
7+
${EM_COMPILER_PATH} \
8+
--bind \
9+
-o browser.js \
10+
-O3 \
11+
-std=c++14 \
12+
-I src/bindings/em \
13+
-I src/core \
14+
--pre-js src/bindings/em/prologue.js \
15+
--post-js src/bindings/em/epilogue.js \
16+
src/core/*.cc \
17+
src/bindings/em/*.cc \
18+
-s TOTAL_MEMORY=134217728 \
19+
--memory-init-file 0 \

script/install-emscripten.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
EMSCRIPTEN_DOWNLOAD_URL='https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz'
4+
EMSDK_PATH="./emsdk_portable/emsdk"
5+
6+
if [ -d $EMSDK_PATH ]; then
7+
echo 'Downloading emscripten SDK installer...'
8+
curl $EMSCRIPTEN_DOWNLOAD_URL | tar xz
9+
fi
10+
11+
echo 'Installing emscripten SDK...'
12+
13+
$EMSDK_PATH update
14+
$EMSDK_PATH install latest
15+
$EMSDK_PATH activate latest

0 commit comments

Comments
 (0)