Skip to content

Commit

Permalink
Build action.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Jul 8, 2024
1 parent 2432c77 commit 027e868
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -Eeuo pipefail

JVER=3.0.3
if [ ! -d "libjpeg-turbo-$JVER" ]; then
url="https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/$JVER/libjpeg-turbo-$JVER.tar.gz"
curl -#L "$url" | tar xz
fi

BVER=version_118
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=22
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
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: .github/workflows/build.sh

- name: Upload artifact
uses: actions/upload-artifact@v4
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*/

0 comments on commit 027e868

Please sign in to comment.