-
Notifications
You must be signed in to change notification settings - Fork 12
/
make.sh
executable file
·105 lines (90 loc) · 2.57 KB
/
make.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
function read_link {
( cd $(dirname $1); echo $PWD/$(basename $1) )
}
PREV_DIR="$(pwd)"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
FLAC_VARIANT=
cd $DIR
export FLACDIR=$(read_link flac)
export FLACOUTDIR=$(read_link flac/src/flac/.libs/)
export OGGDIR=$(read_link libogg)
function make_ogg {
cd $OGGDIR
echo -----------------------------------
echo Making libogg
echo -----------------------------------
./autogen.sh
emconfigure ./configure
emmake make
}
function make_flac {
cd $FLACDIR
echo -----------------------------------
echo Making flac
echo -----------------------------------
./autogen.sh
emconfigure ./configure --with-ogg=$OGGDIR
cd $OGGDIR
ln -s src/.libs lib
ln -s include/ogg ogg
cd $FLACDIR
# fix issue #7: "bad ioctl syscall"
sed -i.bak '/#define GWINSZ_IN_SYS_IOCTL 1/d' config.h
emmake make
}
function checkout_flacfull {
cd $FLACDIR
git clean -fdx
git checkout rr/18/flacjs
FLAC_VARIANT=
}
function checkout_flacenc {
cd $FLACDIR
git clean -fdx
git checkout rr/18/flacencjs
FLAC_VARIANT=.encoder
}
function make_js {
cd $FLACOUTDIR
if [ -d "$FLACOUTDIR" ]; then
mv flac flac.so
echo -----------------------------------
echo Building JavaScript
echo -----------------------------------
echo WASM ...
# ALLOW_MEMORY_GROWTH=1 does not cause performance penalties
# for WASM build and changing TOTAL_MEMORY at runtime is not
# supported.
em++ -O3 "${OGGDIR}/lib/libogg.so" "${FLACDIR}/src/libFLAC/.libs/libFLAC.so" flac.so -o flac.html -s EXPORTED_FUNCTIONS="['_main_js']" -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s RESERVED_FUNCTION_POINTERS=1 -s "BINARYEN_TRAP_MODE='clamp'"
cp -f flac.js "${DIR}/worker/wasm/flac${FLAC_VARIANT}.js"
cp -f flac.wasm "${DIR}/worker/wasm/flac${FLAC_VARIANT}.wasm.png"
echo ASM.JS ...
em++ -O3 "${OGGDIR}/lib/libogg.so" "${FLACDIR}/src/libFLAC/.libs/libFLAC.so" flac.so -o flac.html -s EXPORTED_FUNCTIONS="['_main_js']" -s RESERVED_FUNCTION_POINTERS=1
cp -f flac.js "${DIR}/worker/asm/flac${FLAC_VARIANT}.js"
cp -f flac.html.mem "${DIR}/worker/asm/flac${FLAC_VARIANT}.mem.png"
else
echo $FLACOUTDIR is not a directory. Aborting.
fi
}
function run_js {
echo -----------------------------------
echo Running Press Ctrl+C to abort
echo -----------------------------------
cd $DIR
emrun iframe.html
}
function clean {
cd $OGGDIR && git clean -fdx
cd $FLACDIR && git clean -fdx
}
make_ogg
checkout_flacfull
make_flac
make_js
checkout_flacenc
make_flac
make_js
checkout_flacfull
run_js
cd $PREV_DIR