Skip to content

Commit

Permalink
Build action.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Oct 23, 2023
1 parent 2432c77 commit bdb05ac
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Placeholder
run: true
- uses: actions/checkout@v4

- name: Build artifact
run: ./build.sh

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: dcraw.wasm.gz
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build*/
libjpeg-turbo*/
binaryen*/
wasi-sdk*/
42 changes: 42 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -Eeuo pipefail

JVER=3.0.1
if [ ! -d "libjpeg-turbo-$JVER" ]; then
url="https://downloads.sourceforge.net/project/libjpeg-turbo/$JVER/libjpeg-turbo-$JVER.tar.gz"
curl -#L "$url" | tar xz
fi

BVER=version_116
if [ ! -d "binaryen-$BVER" ]; then
url="https://github.com/WebAssembly/binaryen/releases/download/$BVER/binaryen-$BVER-x86_64-linux.tar.gz"
curl -#L "$url" | tar xz
fi
PATH="$PWD/binaryen-$BVER/bin:$PATH"

WVER=20
if [ ! -d "wasi-sdk-$WVER.0" ]; then
url="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WVER/wasi-sdk-$WVER.0-linux.tar.gz"
curl -#L "$url" | tar xz
fi
WASI_SDK_PREFIX="$PWD/wasi-sdk-$WVER.0"
PATH="$WASI_SDK_PREFIX/bin:$PATH"

mkdir -p build_wasm
pushd build_wasm
cmake "-DWASI_SDK_PREFIX=$WASI_SDK_PREFIX" "-DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PREFIX/share/cmake/wasi-sdk.cmake" \
-G"Unix Makefiles" "../libjpeg-turbo-$JVER" \
-D"CMAKE_C_FLAGS_RELEASE=-Oz -g0 -DNDEBUG" \
-D"WITH_SIMD=0" \
-D"WITH_TURBOJPEG=0"

make -j jpeg-static
clang --target=wasm32-wasi -g0 -flto \
-Oz -o dcraw.wasm ../dcraw.c -DNO_JASPER -DNO_LCMS \
-I. -I"../libjpeg-turbo-$JVER" \
CMakeFiles/jpeg*-static.dir/*.obj
popd

wasm-opt build_wasm/dcraw.wasm -O4 -o dcraw.wasm
gzip -9f dcraw.wasm

0 comments on commit bdb05ac

Please sign in to comment.