mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 01:37:26 +00:00
Further speed improvements
- Store Emscripten cache inside node_modules/.em_cache. Docker image ships without LTO libs, so Emscripten has to rebuild stdlibs on every build otherwise. - Merge webp_enc + webp_dec build scripts. Core libwebp library is same in both cases, so there's no point in storing and building two copies of it.
This commit is contained in:
committed by
Ingvar Stepanyan
parent
1542bfb7fd
commit
de543b3206
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export EM_CACHE="${PWD}/node_modules/.em_cache"
|
||||||
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
||||||
export LDFLAGS="${OPTIMIZE}"
|
export LDFLAGS="${OPTIMIZE}"
|
||||||
export CFLAGS="${OPTIMIZE}"
|
export CFLAGS="${OPTIMIZE}"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export EM_CACHE="${PWD}/node_modules/.em_cache"
|
||||||
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
||||||
export LDFLAGS="${OPTIMIZE}"
|
export LDFLAGS="${OPTIMIZE}"
|
||||||
export CFLAGS="${OPTIMIZE}"
|
export CFLAGS="${OPTIMIZE}"
|
||||||
|
|||||||
18
codecs/webp_dec/build.sh → codecs/webp/build.sh
Executable file → Normal file
18
codecs/webp_dec/build.sh → codecs/webp/build.sh
Executable file → Normal file
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export EM_CACHE="${PWD}/node_modules/.em_cache"
|
||||||
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
||||||
export LDFLAGS="${OPTIMIZE}"
|
export LDFLAGS="${OPTIMIZE}"
|
||||||
export CFLAGS="${OPTIMIZE}"
|
export CFLAGS="${OPTIMIZE}"
|
||||||
@@ -43,8 +44,21 @@ echo "============================================="
|
|||||||
-s MODULARIZE=1 \
|
-s MODULARIZE=1 \
|
||||||
-s 'EXPORT_NAME="webp_dec"' \
|
-s 'EXPORT_NAME="webp_dec"' \
|
||||||
-I node_modules/libwebp \
|
-I node_modules/libwebp \
|
||||||
-o ./webp_dec.js \
|
-o dec/webp_dec.js \
|
||||||
webp_dec.cpp \
|
dec/webp_dec.cpp \
|
||||||
|
node_modules/libwebp/src/.libs/libwebp.a
|
||||||
|
)
|
||||||
|
(
|
||||||
|
emcc \
|
||||||
|
${OPTIMIZE} \
|
||||||
|
--closure 1 \
|
||||||
|
--bind \
|
||||||
|
-s ALLOW_MEMORY_GROWTH=1 \
|
||||||
|
-s MODULARIZE=1 \
|
||||||
|
-s 'EXPORT_NAME="webp_enc"' \
|
||||||
|
-I node_modules/libwebp \
|
||||||
|
-o enc/webp_enc.js \
|
||||||
|
enc/webp_enc.cpp \
|
||||||
node_modules/libwebp/src/.libs/libwebp.a
|
node_modules/libwebp/src/.libs/libwebp.a
|
||||||
)
|
)
|
||||||
echo "============================================="
|
echo "============================================="
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
Module.onRuntimeInitialized = async _ => {
|
Module.onRuntimeInitialized = async _ => {
|
||||||
console.log('Version:', Module.version().toString(16));
|
console.log('Version:', Module.version().toString(16));
|
||||||
const image = await loadFile('../example.webp');
|
const image = await loadFile('../../example.webp');
|
||||||
const result = Module.decode(image);
|
const result = Module.decode(image);
|
||||||
const imageData = new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height);
|
const imageData = new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height);
|
||||||
Module.free_result();
|
Module.free_result();
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
module.onRuntimeInitialized = async _ => {
|
module.onRuntimeInitialized = async _ => {
|
||||||
console.log('Version:', module.version().toString(16));
|
console.log('Version:', module.version().toString(16));
|
||||||
const image = await loadImage('../example.png');
|
const image = await loadImage('../../example.png');
|
||||||
const result = module.encode(image.data, image.width, image.height, {
|
const result = module.encode(image.data, image.width, image.height, {
|
||||||
quality: 75,
|
quality: 75,
|
||||||
target_size: 0,
|
target_size: 0,
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "webp_enc",
|
"name": "webp",
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "webp_enc",
|
"name": "webp",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "napa",
|
"install": "napa",
|
||||||
"build": "docker run -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
|
"build": "docker run -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
|
||||||
1147
codecs/webp_dec/package-lock.json
generated
1147
codecs/webp_dec/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "webp_dec",
|
|
||||||
"scripts": {
|
|
||||||
"install": "napa",
|
|
||||||
"build": "docker run -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
|
|
||||||
},
|
|
||||||
"napa": {
|
|
||||||
"libwebp": "webmproject/libwebp#v1.0.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"napa": "3.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
|
||||||
export LDFLAGS="${OPTIMIZE}"
|
|
||||||
export CFLAGS="${OPTIMIZE}"
|
|
||||||
export CPPFLAGS="${OPTIMIZE}"
|
|
||||||
|
|
||||||
apt-get update
|
|
||||||
apt-get install -qqy autoconf libtool pkg-config
|
|
||||||
|
|
||||||
echo "============================================="
|
|
||||||
echo "Compiling libwebp"
|
|
||||||
echo "============================================="
|
|
||||||
test -n "$SKIP_LIBWEBP" || (
|
|
||||||
cd node_modules/libwebp
|
|
||||||
autoreconf -iv
|
|
||||||
emconfigure ./configure -C \
|
|
||||||
--disable-libwebpdemux \
|
|
||||||
--disable-wic \
|
|
||||||
--disable-gif \
|
|
||||||
--disable-tiff \
|
|
||||||
--disable-jpeg \
|
|
||||||
--disable-png \
|
|
||||||
--disable-sdl \
|
|
||||||
--disable-gl \
|
|
||||||
--disable-threading \
|
|
||||||
--disable-neon-rtcd \
|
|
||||||
--disable-neon \
|
|
||||||
--disable-sse2 \
|
|
||||||
--disable-sse4.1
|
|
||||||
emmake make -j`nproc`
|
|
||||||
)
|
|
||||||
echo "============================================="
|
|
||||||
echo "Compiling wasm bindings"
|
|
||||||
echo "============================================="
|
|
||||||
(
|
|
||||||
emcc \
|
|
||||||
${OPTIMIZE} \
|
|
||||||
--closure 1 \
|
|
||||||
--bind \
|
|
||||||
-s ALLOW_MEMORY_GROWTH=1 \
|
|
||||||
-s MODULARIZE=1 \
|
|
||||||
-s 'EXPORT_NAME="webp_enc"' \
|
|
||||||
-I node_modules/libwebp \
|
|
||||||
-o ./webp_enc.js \
|
|
||||||
webp_enc.cpp \
|
|
||||||
node_modules/libwebp/src/.libs/libwebp.a
|
|
||||||
)
|
|
||||||
echo "============================================="
|
|
||||||
echo "Compiling wasm bindings done"
|
|
||||||
echo "============================================="
|
|
||||||
|
|
||||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
||||||
echo "Did you update your docker image?"
|
|
||||||
echo "Run \`docker pull trzeci/emscripten-upstream\`"
|
|
||||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import webp_dec, { WebPModule } from '../../../codecs/webp_dec/webp_dec';
|
import webp_dec, { WebPModule } from '../../../codecs/webp/dec/webp_dec';
|
||||||
import wasmUrl from '../../../codecs/webp_dec/webp_dec.wasm';
|
import wasmUrl from '../../../codecs/webp/dec/webp_dec.wasm';
|
||||||
import { initEmscriptenModule } from '../util';
|
import { initEmscriptenModule } from '../util';
|
||||||
|
|
||||||
let emscriptenModule: Promise<WebPModule>;
|
let emscriptenModule: Promise<WebPModule>;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import webp_enc, { WebPModule } from '../../../codecs/webp_enc/webp_enc';
|
import webp_enc, { WebPModule } from '../../../codecs/webp/enc/webp_enc';
|
||||||
import wasmUrl from '../../../codecs/webp_enc/webp_enc.wasm';
|
import wasmUrl from '../../../codecs/webp/enc/webp_enc.wasm';
|
||||||
import { EncodeOptions } from './encoder-meta';
|
import { EncodeOptions } from './encoder-meta';
|
||||||
import { initEmscriptenModule } from '../util';
|
import { initEmscriptenModule } from '../util';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user