Dockerize mozjpeg (#169)

* Dockerize mozjpeg build process

* Update README
This commit is contained in:
Surma
2018-09-26 12:31:26 +01:00
committed by Jake Archibald
parent 09e60284cb
commit 1b630a092f
5 changed files with 55 additions and 13 deletions

View File

@@ -6,8 +6,6 @@
## Dependencies
- Docker
- Automake
- pkg-config
## Example

39
codecs/mozjpeg_enc/build.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
set -e
apt-get update
apt-get install -qqy autoconf libtool libpng-dev pkg-config
echo "============================================="
echo "Compiling mozjpeg"
echo "============================================="
(
cd node_modules/mozjpeg
autoreconf -fiv
emconfigure ./configure --without-simd
emmake make libjpeg.la
)
echo "============================================="
echo "Compiling mozjpeg done"
echo "============================================="
echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
emcc \
--bind -O3 \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="mozjpeg_enc"' \
-I node_modules/mozjpeg \
-o ./mozjpeg_enc.js \
-Wno-deprecated-register -Wno-writable-strings \
node_modules/mozjpeg/rdswitch.c \
-x c++ -std=c++11 \
mozjpeg_enc.cpp \
node_modules/mozjpeg/.libs/libjpeg.a
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -2,9 +2,7 @@
"name": "mozjpeg_enc",
"scripts": {
"install": "napa",
"build": "npm run build:library && npm run build:wasm",
"build:library": "cd node_modules/mozjpeg && autoreconf -fiv && docker run --rm -v $(pwd):/src trzeci/emscripten emconfigure ./configure --without-simd && docker run --rm -v $(pwd):/src trzeci/emscripten emmake make libjpeg.la",
"build:wasm": "docker run --rm -v $(pwd):/src trzeci/emscripten emcc --bind -O3 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME=\"mozjpeg_enc\"' -I node_modules/mozjpeg -o ./mozjpeg_enc.js -Wno-deprecated-register -Wno-writable-strings node_modules/mozjpeg/rdswitch.c -x c++ -std=c++11 mozjpeg_enc.cpp node_modules/mozjpeg/.libs/libjpeg.a"
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
},
"napa": {
"mozjpeg": "mozilla/mozjpeg#v3.3.1"