diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index b768a2c..6fa8cd1 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -6,8 +6,21 @@ on: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + platform: [ubuntu, macos] + + runs-on: ${{ matrix.platform }}-latest steps: - - name: Placeholder - run: true \ No newline at end of file + - 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 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a2a255 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build*/ +libjpeg-turbo*/ \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..89a9768 --- /dev/null +++ b/build.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -Eeuo pipefail + +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 +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 + +else + +mkdir -p build + +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 +popd + +fi + +tar c dcraw | gzip -9 > dcraw.tgz \ No newline at end of file