Skip to content

Commit

Permalink
Build action.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Mar 27, 2023
1 parent b512870 commit c6d15fe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 45 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@ on:
jobs:

build:
strategy:
matrix:
platform: [ubuntu, macos]

runs-on: ${{ matrix.platform }}-latest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: ilammy/setup-nasm@v1

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

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: dcraw-${{ matrix.platform }}.tgz
path: dcraw.tgz
path: dcraw.wasm.gz
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build*/
libjpeg-turbo*/
binaryen*/
libjpeg-turbo*/
zig*/
63 changes: 27 additions & 36 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,40 @@

set -Eeuo pipefail

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

if [[ "$OSTYPE" == "darwin"* ]]; then

mkdir -p build_arm
pushd build_arm
cmake -G"Unix Makefiles" "../libjpeg-turbo-$JVER" \
-D"CMAKE_OSX_DEPLOYMENT_TARGET=11" \
-D"CMAKE_OSX_ARCHITECTURES=arm64"
make -j jpeg-static
cc -O3 -o dcraw ../dcraw.c -DNO_JASPER -DNO_LCMS \
-I. -I"../libjpeg-turbo-$JVER" libjpeg.a \
--target=arm64-apple-macos11
popd

mkdir -p build_x86
pushd build_x86
cmake -G"Unix Makefiles" "../libjpeg-turbo-$JVER" \
-D"CMAKE_OSX_DEPLOYMENT_TARGET=10.13" \
-D"CMAKE_OSX_ARCHITECTURES=x86_64"
make -j jpeg-static
cc -O3 -o dcraw ../dcraw.c -DNO_JASPER -DNO_LCMS \
-I. -I"../libjpeg-turbo-$JVER" libjpeg.a \
--target=x86_64-apple-macos10.13
popd

lipo -create -output dcraw build_arm/dcraw build_x86/dcraw
ZVER=0.10.0
if [ ! -d "zig-linux-x86_64-$ZVER" ]; then
url="https://ziglang.org/download/$ZVER/zig-linux-x86_64-$ZVER.tar.xz"
curl -sL "$url" | tar vxJ
fi
PATH="$PWD/zig-linux-x86_64-$ZVER:$PATH"

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

mkdir -p build
mkdir -p build_wasm
pushd build_wasm
CC="zig cc --target=wasm32-wasi" cmake -G"Unix Makefiles" "../libjpeg-turbo-$JVER" \
-D"CMAKE_C_FLAGS_RELEASE=-Oz -g0 -DNDEBUG" \
-D"WITH_SIMD=0" \
-D"WITH_TURBOJPEG=0"

pushd build
cmake -G"Unix Makefiles" "../libjpeg-turbo-$JVER"
make -j jpeg-static
cc -O3 -o ../dcraw ../dcraw.c -lm -DNO_JASPER -DNO_LCMS \
-I. -I"../libjpeg-turbo-$JVER" libjpeg.a
zig cc --target=wasm32-wasi -g0 -flto \
-Oz -o dcraw.wasm ../dcraw.c -DNO_JASPER -DNO_LCMS \
-I. -I"../libjpeg-turbo-$JVER" \
CMakeFiles/jpeg-static.dir/*.o \
CMakeFiles/simd.dir/*.o
popd

fi

tar c dcraw | gzip -9 > dcraw.tgz
wasm-opt build_wasm/dcraw.wasm -O4 -o dcraw.wasm
gzip -9f dcraw.wasm

0 comments on commit c6d15fe

Please sign in to comment.