Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 44018eb

Browse files
Add Gyp rules for Javascript-ifying the Emscripten engine
1 parent 2f31501 commit 44018eb

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed

engine/emscripten-javascriptify.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# This script runs the command that javascript-ifies the bitcode files produced
4+
# by the Emscripten compiler.
5+
6+
set -e
7+
8+
# Parameters:
9+
# input: bitcode file to javascriptify
10+
# output: the output HTML file
11+
# exports: JSON file containing list of exported functions
12+
# whitelist: JSON file containing list of emterpreted functions
13+
# other args: additional javascript libraries to include
14+
#
15+
input=$1
16+
output=$2
17+
exports=$3
18+
whitelist=$4
19+
shift 4
20+
21+
for lib in $@ ; do
22+
libs+=\ --js-library\ "${lib}"
23+
done
24+
25+
26+
emcc -O2 -g ${CFLAGS} \
27+
"${input}" \
28+
-o "${output}" \
29+
-s EXPORTED_FUNCTIONS=@"${exports}" \
30+
-s EMTERPRETIFY_WHITELIST=@"${whitelist}" \
31+
-s ASSERTIONS=1 \
32+
-s EMTERPRETIFY=1 \
33+
-s EMTERPRETIFY_ASYNC=1 \
34+
-s ALLOW_MEMORY_GROWTH=1 \
35+
-s TOTAL_MEMORY=67108864 \
36+
--preload-file boot \
37+
${libs}
38+

engine/engine.gyp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@
367367
},
368368
},
369369
],
370+
[
371+
'OS == "emscripten"',
372+
{
373+
'product_name': 'standalone-community.bc',
374+
},
375+
],
370376
],
371377

372378
'all_dependent_settings':
@@ -652,5 +658,56 @@
652658
],
653659
}
654660
],
661+
[
662+
'OS == "emscripten"',
663+
{
664+
'targets':
665+
[
666+
{
667+
'target_name': 'javascriptify',
668+
'type': 'none',
669+
670+
'dependencies':
671+
[
672+
'standalone',
673+
],
674+
675+
'actions':
676+
[
677+
{
678+
'action_name': 'javascriptify',
679+
'message': 'Javascript-ifying the Emscripten engine',
680+
681+
'inputs':
682+
[
683+
'<(PRODUCT_DIR)/standalone-community.bc',
684+
'src/em-exported.json',
685+
'src/em-whitelist.json',
686+
'src/em-async.js',
687+
'src/em-event.js',
688+
'boot',
689+
],
690+
691+
'outputs':
692+
[
693+
'<(PRODUCT_DIR)/standalone-community.html',
694+
],
695+
696+
'action':
697+
[
698+
'./emscripten-javascriptify.sh',
699+
'<(PRODUCT_DIR)/standalone-community.bc',
700+
'<(PRODUCT_DIR)/standalone-community.html',
701+
'src/em-exported.json',
702+
'src/em-whitelist.json',
703+
'src/em-async.js',
704+
'src/em-event.js',
705+
],
706+
},
707+
],
708+
},
709+
],
710+
},
711+
],
655712
],
656713
}

livecode.gyp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,23 @@
8888
},
8989
],
9090
[
91-
'OS != "android"',
91+
'OS != "android" and OS != "emscripten"',
9292
{
9393
'dependencies':
9494
[
9595
'revpdfprinter/revpdfprinter.gyp:external-revpdfprinter',
9696
],
9797
},
9898
],
99+
[
100+
'OS == "emscripten"',
101+
{
102+
'dependencies':
103+
[
104+
'engine/engine.gyp:javascriptify',
105+
],
106+
},
107+
],
99108
],
100109
},
101110

0 commit comments

Comments
 (0)