Skip to content

Commit

Permalink
Build macOS native lib
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 committed Sep 19, 2024
1 parent 6d070eb commit bf6c544
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/macos-native-lib.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions native/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -x

# Initialize external vars - need this to get around unbound variable errors
SKIP_GRADLE="$SKIP_GRADLE"
Expand All @@ -21,10 +21,12 @@ if [ x"$OSTYPE" = x"msys" ]; then
LIBRARY_EXTENSION=dll
elif [ x"$OSTYPE" = x"GNU/Linux" ]; then
LIBRARY_EXTENSION=so
ARCHITECTURE="$(uname --machine)"
ARCHITECTURE="$(uname -m)"
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
Expand Down
4 changes: 2 additions & 2 deletions native/compress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf6c544

Please sign in to comment.