-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild-emscripten.sh
executable file
·86 lines (74 loc) · 1.87 KB
/
build-emscripten.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -e
set -x
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
BUILDFOLDER="$SCRIPTPATH/_build/embuild"
DISTFOLDER="$SCRIPTPATH/dist"
if [ -z "$EMSCRIPTEN" ]
then
EMSCRIPTEN_PATH=${EMSCRIPTEN_PATH:-/emsdk}
if [ ! -f "$EMSCRIPTEN_PATH/emsdk_env.sh" ]; then
echo "emscripten installation not found" ;
exit 1 ;
fi
. "$EMSCRIPTEN_PATH/emsdk_env.sh"
fi
if [ -z "$BUILD_TYPE" ]
then
. ./config.release
fi
# Emscripten compiler:
AR=emar
CC=emcc
CXX=em++
. ./build-common.sh
name_0="wasm"
flags_0="-s TOTAL_MEMORY=128KB -s TOTAL_STACK=64KB -s WASM=1 -s EXPORT_NAME='ModuleWasm'"
name_1="asmjs"
flags_1="-s WASM=0 -s EXPORT_NAME='ModuleAsmjs'"
rm -rf $DISTFOLDER;
for emidx in 0 1
do
EMNAME="name_$emidx"
EMNAME=${!EMNAME}
EMFLAGS="flags_$emidx"
EMFLAGS=${!EMFLAGS}
( mkdir -p $DISTFOLDER && \
emcc ${EMFLAGS} \
--pre-js pre.js \
-s SINGLE_FILE=1 \
-s MODULARIZE=1 \
-s NO_EXIT_RUNTIME=1 \
-s ASSERTIONS=$EMCC_ASSERTIONS \
$EMCC_FLAGS \
-std=c11 -Wall -Wextra -Wno-strict-prototypes -Wunused-value -Wcast-align \
-Wunused-variable -Wundef -Wformat-security -Wshadow \
-o "$DISTFOLDER/group-sign-$EMNAME.js" \
-rdynamic \
$BUILDFOLDER/group-sign.o \
$BUILDFOLDER/core.a \
-s EXPORTED_FUNCTIONS="[\
'_GS_seed', \
'_GS_setupGroup', \
'_GS_loadGroupPrivKey', \
'_GS_loadGroupPubKey', \
'_GS_loadUserCredentials', \
'_GS_exportGroupPrivKey', \
'_GS_exportGroupPubKey', \
'_GS_exportUserCredentials', \
'_GS_processJoin', \
'_GS_sign', \
'_GS_verify', \
'_GS_getSignatureTag', \
'_GS_initState', \
'_GS_startJoin', \
'_GS_finishJoin', \
'_GS_version', \
'_GS_curve', \
'_GS_success', \
'_GS_failure', \
'_GS_error', \
'_GS_getStateSize', \
'_malloc', \
'_free']")
done