-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·71 lines (50 loc) · 1.57 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env sh
JPEGLIB_VERSION=9c
LIBWEBP_VERSION=1.0.2
JPEGLIB_DIR=`pwd`/jpeg-9c
LIBPNG_DIR=${HOME}/.emscripten_cache/asmjs/ports-builds/libpng
configure="emconfigure ./configure --host=wasm32"
make="emmake make -j"
echo "Dependency: JpegLib"
rm -rf jpeg-${JPEGLIB_VERSION} jpegsrc.v${JPEGLIB_VERSION}*
wget http://www.ijg.org/files/jpegsrc.v${JPEGLIB_VERSION}.tar.gz
tar xf jpegsrc.v${JPEGLIB_VERSION}.tar.gz
(
cd ${JPEGLIB_DIR}
$configure || exit $?
$make || exit $?
) || exit $?
echo "Download libWebP source code"
rm -rf libwebp-${LIBWEBP_VERSION} v${LIBWEBP_VERSION}*
wget https://github.com/webmproject/libwebp/archive/v${LIBWEBP_VERSION}.tar.gz
tar xf v${LIBWEBP_VERSION}.tar.gz
cd libwebp-${LIBWEBP_VERSION}
echo "Configure"
./autogen.sh
CFLAGS="-s USE_LIBPNG=1" \
LDFLAGS="-s USE_LIBPNG=1" \
$configure \
--enable-jpeg \
--enable-png \
--with-jpegincludedir=${JPEGLIB_DIR} \
--with-jpeglibdir=${JPEGLIB_DIR}/.libs \
--with-pngincludedir=${LIBPNG_DIR} \
--with-pnglibdir=${LIBPNG_DIR} \
|| exit $?
echo "Build"
$make || exit $?
# Generate `.wasm` files
OPTIONS="-s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912 -s USE_LIBPNG=1"
echo "Link"
mv examples/cwebp examples/cwebp.o
emcc examples/cwebp.o -o ../cwebp.wasm $OPTIONS || exit $?
mv examples/dwebp examples/dwebp.o
emcc examples/dwebp.o -o ../dwebp.wasm $OPTIONS || exit $?
echo "Clean"
cd ..
rm -rf jpeg-${JPEGLIB_VERSION} jpegsrc.v${JPEGLIB_VERSION}*
rm -rf libwebp-${LIBWEBP_VERSION} v${LIBWEBP_VERSION}*
echo "Add executable permissions"
chmod +x cwebp.wasm
chmod +x dwebp.wasm
echo "Done"