forked from lovell/sharp-libvips
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwasm.sh
More file actions
executable file
·43 lines (35 loc) · 1.28 KB
/
wasm.sh
File metadata and controls
executable file
·43 lines (35 loc) · 1.28 KB
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
#!/usr/bin/env bash
set -e
source ./versions.properties
VERSION_WASM_VIPS="${1:-HEAD}"
DIR="wasm-vips-${VERSION_WASM_VIPS}"
TAG="wasm-vips:${VERSION_WASM_VIPS}"
echo "Using ${TAG} to build libvips ${VERSION_VIPS}"
cd "${0%/*}"
# Download specific version of wasm-vips
if [ ! -d "$DIR" ]; then
mkdir "${DIR}"
curl -Ls https://github.com/kleisauke/wasm-vips/archive/${VERSION_WASM_VIPS}.tar.gz | tar xzC "${DIR}" --strip-components=1
fi
# Check libvips versions match
VERSION_VIPS_UPSTREAM=$(grep -Po "^VERSION_VIPS=\K[^ ]*" "${DIR}/build.sh")
if [ "$VERSION_VIPS" != "$VERSION_VIPS_UPSTREAM" ]; then
echo "Expected libvips $VERSION_VIPS, found $VERSION_VIPS_UPSTREAM upstream" # TODO: modify build.sh on-the-fly?
exit 1
fi
# Create container with emscripten
pushd "${DIR}"
docker build -t "${TAG}" .
popd
# Build libvips and dependencies as static Wasm libraries via emscripten
if [ ! -d "$DIR/build/target/lib" ]; then
docker run --rm -v "$PWD/${DIR}":/src "${TAG}" -c "./build.sh --disable-bindings --disable-modules --disable-jxl --enable-libvips-cpp"
else
echo "Skipping build: found existing files in $DIR/build/target"
fi
echo "Creating tarball"
tar chzf \
../sharp-libvips-dev-wasm32.tar.gz \
--directory="${DIR}/build/target" \
--exclude="cmake/*" \
{include,lib,versions.json}