-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·53 lines (43 loc) · 1.32 KB
/
build.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
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS=${OPTIMIZE}
export CFLAGS=${OPTIMIZE}
export CXXFLAGS=${OPTIMIZE}
ENTRY_POINT="rnnoise.js"
echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
(
cd rnnoise
# Clean possible autotools clutter that might affect the configurations step
git clean -f -d
./autogen.sh
# For some reason setting the CFLAGS export doesn't apply optimization to all compilation steps
# so we need to explicitly pass it to configure.
emconfigure ./configure CFLAGS=${OPTIMIZE}
emmake make clean
emmake make V=1
# Compile librnnoise generated LLVM bytecode to wasm
emcc \
${OPTIMIZE} \
-s STRICT=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s EXPORT_ES6=1 \
-s EXPORTED_FUNCTIONS="['_rnnoise_process_frame', '_rnnoise_init', '_rnnoise_destroy', '_rnnoise_create', '_malloc', '_free']" \
.libs/librnnoise.so \
-o ./$ENTRY_POINT
# Create output folder
rm -rf ../dist
mkdir -p ../dist
# Move artifacts
mv $ENTRY_POINT ../dist/index.js
mv rnnoise.wasm ../dist/
# Clean cluttter
git clean -f -d
)
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="