Skip to content

add native support for Apple Silicon macs #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 135 additions & 45 deletions .github/workflows/github_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-11 ]

os: [ ubuntu-latest, macos-11, macos-13-xlarge ]
steps:
- name: checkout
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
check-latest: true

- run: |
unset SYSTEM
./gradlew checkFormat
Expand All @@ -64,21 +70,6 @@ jobs:
shell: bash
name: test

- run: |
set -e pipefail
# Display log files if the build failed
echo "Dumping log files for failed build"
echo "----------------------------------"
for f in $(find $BUILD_REPOSITORY_LOCALPATH -name *.dumpstream);
do echo "------"
echo $f
echo "======"
cat $f
done;
shell: bash
name: error_print
if: ${{ failure() }}

env:
ORG_GRADLE_PROJECT_TILEDB_SERIALIZATION: OFF
ORG_GRADLE_PROJECT_TILEDB_S3: OFF
Expand All @@ -103,11 +94,11 @@ jobs:
p=$(readlink -f *.jar)
cd ../../src/main/java/examples/io/tiledb/java/api
javac -cp $p *.java
for x in $(ls -1 *.java | sed 's/.java//');
do
for x in $(ls -1 *.java | sed 's/.java//');
do
echo $x;
class_name=examples.io.tiledb.java.api.$x;
java -cp $p $class_name;
class_name=examples.io.tiledb.java.api.$x;
java -cp $p $class_name;
done

env:
Expand Down Expand Up @@ -168,8 +159,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-11, ubuntu-latest ]
os: [ macos-11, ubuntu-latest, macos-13-xlarge]
steps:

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
check-latest: true

- name: checkout
uses: actions/checkout@v3

Expand All @@ -183,30 +182,30 @@ jobs:
docker run -e "CFLAGS=$CFLAGS" -e "CPPFLAGS=$CPPFLAGS" -v $(pwd):/TileDB-Java -t lib_builder_2010 /TileDB-Java/ci/build.sh
cp ./build/tiledb_jni/*.so ./build/install/lib/*.so ./build/install/lib64/*.so binaries_$RUNNER_OS/
fi

if [[ ( "$RUNNER_OS" == "macOS" ) ]]; then
./gradlew -PTILEDB_AZURE=ON assemble
cp ./build/tiledb_jni/*.dylib ./build/install/lib/*.dylib binaries_$RUNNER_OS/

if [[ "$RUNNER_OS" == "macOS" ]]; then
if [[ "$(uname -m)" == "arm64" ]]; then
mkdir -p binaries_apple_silicon/arm
./gradlew -PTILEDB_AZURE=ON assemble
cp ./build/tiledb_jni/arm/*.dylib ./build/install/arm/lib/*.dylib binaries_apple_silicon/arm
else
./gradlew -PTILEDB_AZURE=ON assemble
cp ./build/tiledb_jni/*.dylib ./build/install/lib/*.dylib binaries_$RUNNER_OS/
fi
fi

name: 'Build and Upload (Ubuntu and OSX)'

- run: |
set -e pipefail
# Display log files if the build failed
echo "Dumping log files for failed build"
echo "----------------------------------"
for f in $(find $BUILD_REPOSITORY_LOCALPATH -name *.log);
do echo "------"
echo $f
echo "======"
cat $f
done;
if: ${{ failure() }}
name: "Print log files (failed build only)"

- run: |
tar cvf tiledb-$RUNNER_OS.gz.tar binaries_$RUNNER_OS/
if [[ "$RUNNER_OS" == "macOS" ]]; then
if [[ "$(uname -m)" == "arm64" ]]; then
tar cvf tiledb-apple-silicon.gz.tar binaries_apple_silicon/
else
tar cvf tiledb-$RUNNER_OS.gz.tar binaries_$RUNNER_OS/
fi
else
tar cvf tiledb-$RUNNER_OS.gz.tar binaries_$RUNNER_OS/
fi
name: Archive_files

- uses: actions/upload-artifact@v2
Expand All @@ -219,15 +218,21 @@ jobs:
with:
name: Upload-Artifact-Mac
path: '*.gz.tar'
if: runner.os == 'macOS'
if: runner.os == 'macOS' && (runner.arch == 'X86' || runner.arch == 'X64')

- uses: actions/upload-artifact@v2
with:
name: Upload-Artifact-Mac-Arm
path: '*.gz.tar'
if: runner.os == 'macOS' && (runner.arch == 'ARM' || runner.arch == 'arm64')
env:
ORG_GRADLE_PROJECT_TILEDB_SERIALIZATION: ON
ORG_GRADLE_PROJECT_TILEDB_S3: ON

Release:
Setup-Release:
if: startsWith(github.ref, 'refs/tags/')
needs: [Create_Artifacts_Ubuntu_MacOS, Create_Artifacts_Windows]
name: Create-Release
name: Setup-Release
runs-on: ubuntu-latest
steps:

Expand All @@ -250,8 +255,10 @@ jobs:
mv Upload-*/* .

mkdir -p ./build/install/lib
mkdir -p ./build/install/arm/lib
mkdir ./build/install/lib64
mkdir ./build/tiledb_jni/
mkdir ./build/tiledb_jni/arm
mkdir ./build/tiledb_jni/Release
mkdir ./build/install/bin

Expand All @@ -266,7 +273,9 @@ jobs:
# OSX
mv libtiledb.dylib ./build/install/lib
mv libtiledbjni.dylib ./build/tiledb_jni

mv arm/libtiledb.dylib ./build/install/arm/lib
mv arm/libtiledbjni.dylib ./build/tiledb_jni/arm

# Linux
cp libtiledb.so ./build/install/lib
mv libtiledb.so ./build/install/lib64
Expand All @@ -282,6 +291,87 @@ jobs:
mkdir jars
cp ./build/libs/*.jar jars

- uses: actions/upload-artifact@v3
with:
name: jars
path: ./jars

env:
ORG_GRADLE_PROJECT_TILEDB_SERIALIZATION: ON
ORG_GRADLE_PROJECT_TILEDB_S3: ON


Test-Release:
if: startsWith(github.ref, 'refs/tags/')
needs: [ Setup-Release ]
name: Test-Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-11, ubuntu-latest, macos-13-xlarge, windows-2019 ]
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Set-up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
check-latest: true

- uses: actions/download-artifact@v2
with:
name: jars

- shell: bash
name: Run examples with release jar
run: |

if [[ "$RUNNER_OS" == "macOS" ]]; then
brew install coreutils;
fi

rm *javadoc* *sources*

p=$(realpath *.jar)

# Change directory to the specified path
cd src/main/java/examples/io/tiledb/java/api

# Compile all Java files in the current directory using the classpath obtained earlier
javac -cp "$p" *.java

# Loop through all compiled Java files and run them
for x in $(ls -1 *.java | sed 's/.java//'); do
echo $x;
class_name=examples.io.tiledb.java.api.$x;
java -cp "$p" $class_name;
done
env:
ORG_GRADLE_PROJECT_TILEDB_SERIALIZATION: ON
ORG_GRADLE_PROJECT_TILEDB_S3: ON

Release:
if: startsWith(github.ref, 'refs/tags/')
needs: [ Test-Release ]
name: Release
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

- uses: actions/download-artifact@v2
with:
name: jars

- name: Package jars
run: |
mkdir jars;
mv *.jar ./jars;

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ if (TILEDB_JNI_SUPERBUILD)
project(TileDB-JNI-Superbuild)

# Path to install everything to, for embedding in the jar.
set(RESOURCE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/install")
if (APPLE) # macOS
if (CMAKE_OSX_ARCHITECTURES STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
set(RESOURCE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/install")
else()
set(RESOURCE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/install/arm")
endif()
else()
set(RESOURCE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/install")
endif()

message(STATUS "Starting TileDB-JNI superbuild.")
include("cmake/TileDB-JNI-Superbuild.cmake")
Expand Down
42 changes: 36 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,19 @@ dependencies {
}

task cmakeTask(type: Exec) {
File jniLibs = new File(buildDir.path + "/tiledb_jni")
File tiledbLibs = new File(buildDir.path + "/install/lib")
def osName = System.getProperty('os.name').toLowerCase()
def arch = System.getProperty('os.arch').toLowerCase()

File jniLibs;
File tiledbLibs;

if (osName.contains("mac") && arch.equals("aarch64")) {
jniLibs = new File(buildDir.path + "/tiledb_jni/arm")
tiledbLibs = new File(buildDir.path + "/install/arm/lib")
}else{
jniLibs = new File(buildDir.path + "/tiledb_jni")
tiledbLibs = new File(buildDir.path + "/install/lib")
}

onlyIf { !buildDir.exists() || !jniLibs.exists() || !tiledbLibs.exists() }
doFirst {
Expand Down Expand Up @@ -83,8 +94,19 @@ task cmakeTask(type: Exec) {
}

task cmakeBuildTask(type: Exec) {
File jniLibs = new File(buildDir.path + "/tiledb_jni")
File tiledbLibs = new File(buildDir.path + "/install/lib")
def osName = System.getProperty('os.name').toLowerCase()
def arch = System.getProperty('os.arch').toLowerCase()

File jniLibs;
File tiledbLibs;

if (osName.contains("mac") && arch.equals("aarch64")) {
jniLibs = new File(buildDir.path + "/tiledb_jni/arm")
tiledbLibs = new File(buildDir.path + "/install/arm/lib")
}else{
jniLibs = new File(buildDir.path + "/tiledb_jni")
tiledbLibs = new File(buildDir.path + "/install/lib")
}

onlyIf { !buildDir.exists() || !jniLibs.exists() || !tiledbLibs.exists() }
doFirst {
Expand Down Expand Up @@ -116,7 +138,7 @@ test {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
systemProperty "java.library.path", "$buildDir\\install\\bin;$buildDir\\tiledb_jni\\Release"
} else {
systemProperty "java.library.path", "$buildDir/install/lib:$buildDir/install/lib64:$buildDir/tiledb_jni"
systemProperty "java.library.path", "$buildDir/install/lib:$buildDir/install/lib64:$buildDir/tiledb_jni:$buildDir/install/arm/lib:$buildDir/tiledb_jni/arm"
}

testLogging {
Expand All @@ -125,12 +147,19 @@ test {
}

jar {
// macOS arm
into(new File('arm/lib').toString()) {
from file("$buildDir/install/arm/lib/libtiledb.dylib")
from file("$buildDir/tiledb_jni/arm/libtiledbjni.dylib")
}

into(new File('lib').toString()) {
// Linux and macOS
// Linux
from file("$buildDir/install/lib/libtiledb.so")
from file("$buildDir/install/lib64/libtiledb.so")
from file("$buildDir/tiledb_jni/libtiledbjni.so")

// macOS intel
from file("$buildDir/install/lib/libtiledb.dylib")
from file("$buildDir/install/lib64/libtiledb.dylib")
from file("$buildDir/tiledb_jni/libtiledbjni.dylib")
Expand All @@ -141,6 +170,7 @@ jar {
from file("$buildDir/tiledb_jni/Release/tiledbjni.dll")
}


manifest {
attributes("Implementation-Title": "Gradle",
"Implementation-Version": archiveVersion)
Expand Down
14 changes: 12 additions & 2 deletions cmake/Modules/FindTileDB_EP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,18 @@ if (NOT TILEDB_FOUND)
SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.17.1/tiledb-windows-x86_64-2.17.1-7c8c73b.zip")
SET(DOWNLOAD_SHA1 "c3757a9205299a4184bd4de7621ff9f5118f14ca")
elseif(APPLE) # macOS
SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.17.1/tiledb-macos-x86_64-2.17.1-7c8c73b.tar.gz")
SET(DOWNLOAD_SHA1 "998c099297c0441af40729634642bd358c962da6")

if (CMAKE_OSX_ARCHITECTURES STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
message(STATUS "Building for intel mac")
SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.17.1/tiledb-macos-x86_64-2.17.1-7c8c73b.tar.gz")
SET(DOWNLOAD_SHA1 "998c099297c0441af40729634642bd358c962da6")

elseif (CMAKE_OSX_ARCHITECTURES STREQUAL arm64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
message(STATUS "Building for apple silicon mac")
SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.17.1/tiledb-macos-arm64-2.17.1-7c8c73b.tar.gz")
SET(DOWNLOAD_SHA1 "23b2c8a18b7ad4198516f7975b51ce47e7dee56d")
endif()

else() # Linux
SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.17.1/tiledb-linux-x86_64-2.17.1-7c8c73b.tar.gz")
SET(DOWNLOAD_SHA1 "c01bf6898ef5bd108d49b378aa30aadfc3131b75")
Expand Down
Loading