From 1d2d2930eaf34a379e7eeb54ad0de5fa6517261d Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Thu, 19 Sep 2024 14:38:23 +0200 Subject: [PATCH] Build macOS native lib Signed-off-by: Fabio Di Fabio --- .github/workflows/macos-native-lib.yml | 67 ++++++++++++++++++++++++++ native/build.sh | 2 + native/compress/build.gradle | 4 +- 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/macos-native-lib.yml diff --git a/.github/workflows/macos-native-lib.yml b/.github/workflows/macos-native-lib.yml new file mode 100644 index 00000000..24522eca --- /dev/null +++ b/.github/workflows/macos-native-lib.yml @@ -0,0 +1,67 @@ +name: macOS native lib + +on: [push] + +jobs: + macosNativeLib: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v4 + with: + go-version: stable + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: 21 + distribution: temurin + + - name: Build native lib + run: ./gradlew :native:compress:buildJNI + + - name: List built files + run: ls -lR native/compress/build + + - name: Upload macOS native lib asset + uses: actions/upload-artifact@v4 + with: + name: libcompress_jni.dylib + path: 'native/compress/build/native/darwin-aarch64/libcompress_jni.dylib' + + build: + runs-on: ubuntu-latest + needs: macosNativeLib + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: 21 + distribution: temurin + cache: 'gradle' + + - name: Create macOS native lib dir + run: mkdir -p native/compress/build/native/darwin-aarch64 + + - name: Get the built macOS native lib + uses: actions/download-artifact@v4 + with: + name: libcompress_jni.dylib + path: native/compress/build/native/darwin-aarch64 + + - name: List native resources + run: ls -lR native/compress/build/native + + - name: Build without tests + run: ./gradlew build -PreleaseNativeLibs -PreleaseVersion=0.0.0-TEST -x test -x spotlessCheck + + - name: List native resources + run: ls -lR native/compress/build/native + + - name: Upload jar + uses: actions/upload-artifact@v4 + with: + name: linea-sequencer-0.0.0-TEST.jar + path: ./sequencer/build/libs/linea-sequencer-0.0.0-TEST.jar diff --git a/native/build.sh b/native/build.sh index 47c3286f..75a2efea 100755 --- a/native/build.sh +++ b/native/build.sh @@ -25,6 +25,8 @@ elif [ x"$OSTYPE" = x"GNU/Linux" ]; then ARCH_DIR="linux-$ARCHITECTURE" elif [ x"$OSTYPE" = x"Darwin" ]; then LIBRARY_EXTENSION=dylib + ARCHITECTURE="$(uname --machine)" + ARCH_DIR="darwin-$ARCHITECTURE" else echo "*** Unknown OS: $OSTYPE" exit 1 diff --git a/native/compress/build.gradle b/native/compress/build.gradle index da36e9ce..a495e44e 100644 --- a/native/compress/build.gradle +++ b/native/compress/build.gradle @@ -61,13 +61,13 @@ dependencies { tasks.register('macArmLibCopy', Copy) { - from 'build/native/libcompress_jni.dylib' + from 'build/native/darwin-aarch64/libcompress_jni.dylib' into 'build/resources/main/darwin-aarch64' } processResources.dependsOn macArmLibCopy tasks.register('macLibCopy', Copy) { - from 'build/native/libcompress_jni.dylib' + from 'build/native/darwin-x86-64/libcompress_jni.dylib' into 'build/resources/main/darwin-x86-64' } processResources.dependsOn macLibCopy