Skip to content

Commit

Permalink
Native driver based on the Rust SDK (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel-keller authored Oct 5, 2024
1 parent 0a9b9f5 commit 9e3e898
Show file tree
Hide file tree
Showing 179 changed files with 11,782 additions and 6,349 deletions.
17 changes: 5 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# EditorConfig coding styles definitions. For more information about the
# properties used in this file, please see the EditorConfig documentation:
# http://editorconfig.org/
# EditorConfig: https://EditorConfig.org

root = true

[*]
# Java files
[*.java]
charset = utf-8
end_of_line = LF
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yml,json}]
indent_size = 2
indent_style = space

[*.{md,diff}]
trim_trailing_whitespace = false
max_line_length = 100
354 changes: 354 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,354 @@
name: Cross-Compile

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:

android:
strategy:
matrix:
include:
- target: x86_64-linux-android
ndk: x86_64
- target: aarch64-linux-android
ndk: arm64-v8a
- target: i686-linux-android
ndk: x86
- target: armv7-linux-androideabi
ndk: armeabi-v7a

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Rust
uses: Swatinem/rust-cache@v2

- name: Install dependencies
run: sudo apt-get update -y

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Install cargo-ndk
run: cargo install cargo-ndk

- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: cargo ndk -t ${{ matrix.ndk }} build --release

- name: Upload so lib
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/*.so

linux:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
linker: CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=gcc
apt-get: gcc
- target: aarch64-unknown-linux-gnu
linker: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
apt-get: gcc-aarch64-linux-gnu
- target: i686-unknown-linux-gnu
linker: CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=gcc
apt-get: gcc-multilib
- target: armv7-unknown-linux-gnueabihf
linker: CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
apt-get: gcc-arm-linux-gnueabihf

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Rust
uses: Swatinem/rust-cache@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.apt-get }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: |
export ${{ matrix.linker }}
cargo build --target ${{ matrix.target }} --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/*.so

windows:
strategy:
matrix:
arch: [ x86_64, i686 ]
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Rust
uses: Swatinem/rust-cache@v2

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.arch }}-pc-windows-msvc

- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: cargo build --target ${{ matrix.arch }}-pc-windows-msvc --release

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}-pc-windows-msvc
path: target/${{ matrix.arch }}-pc-windows-msvc/release/*.dll

macos:
strategy:
matrix:
include:
- arch: x86_64
runs-on: macos-12
- arch: aarch64
runs-on: macos-latest
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Rust
uses: Swatinem/rust-cache@v2

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: cargo build --target ${{ matrix.arch }}-apple-darwin --release

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}-apple-darwin
path: target/${{ matrix.arch }}-apple-darwin/release/*.dylib

aggregated-jar:
runs-on: ubuntu-latest
needs:
- android
- windows
- macos
steps:
- name: Install dependencies
run: sudo apt-get update

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 22
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 22

- name: Gradle
run: chmod +x gradlew

- name: Create directories for artifacts
run: |
mkdir -p src/main/resources/natives/android_64
mkdir -p src/main/resources/natives/android_32
mkdir -p src/main/resources/natives/android_arm64
mkdir -p src/main/resources/natives/android_arm32
mkdir -p src/main/resources/natives/linux_64
mkdir -p src/main/resources/natives/linux_32
mkdir -p src/main/resources/natives/linux_arm64
mkdir -p src/main/resources/natives/linux_arm32
mkdir -p src/main/resources/natives/osx_64
mkdir -p src/main/resources/natives/osx_arm64
mkdir -p src/main/resources/natives/windows_64
mkdir -p src/main/resources/natives/windows_32
- name: Download Android 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-linux-android
path: src/main/resources/natives/android_64

- name: Download Android 32 intel
uses: actions/download-artifact@v4
with:
name: i686-linux-android
path: src/main/resources/natives/android_32

- name: Download Android 64 arm
uses: actions/download-artifact@v4
with:
name: aarch64-linux-android
path: src/main/resources/natives/android_arm64

- name: Download Android 32 arm
uses: actions/download-artifact@v4
with:
name: armv7-linux-androideabi
path: src/main/resources/natives/android_arm32

- name: Download Linux 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-unknown-linux-gnu
path: src/main/resources/natives/linux_64

- name: Download Linux 32 intel
uses: actions/download-artifact@v4
with:
name: i686-unknown-linux-gnu
path: src/main/resources/natives/linux_32

- name: Download Linux 64 arm
uses: actions/download-artifact@v4
with:
name: aarch64-unknown-linux-gnu
path: src/main/resources/natives/linux_arm64

- name: Download Linux 32 arm
uses: actions/download-artifact@v4
with:
name: armv7-unknown-linux-gnueabihf
path: src/main/resources/natives/linux_arm32

- name: Download Darwin 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-apple-darwin
path: src/main/resources/natives/osx_64

- name: Download Darwin 64 arm
uses: actions/download-artifact@v4
with:
name: aarch64-apple-darwin
path: src/main/resources/natives/osx_arm64

- name: Download Windows 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-pc-windows-msvc
path: src/main/resources/natives/windows_64

- name: Download Windows 32 intel
uses: actions/download-artifact@v4
with:
name: i686-pc-windows-msvc
path: src/main/resources/natives/windows_32

- name: Build JAR
run: ./gradlew jar

- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: surrealdb
path: build/libs/surrealdb-0.2-SNAPSHOT.jar

- name: Linux Integration Test
run: ./gradlew -i integrationTest

integration-tests:
strategy:
matrix:
os: [ macos-12, macos-latest, windows-latest, ubuntu-latest ]

runs-on: ${{ matrix.os }}
needs:
- aggregated-jar
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 22
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 22

- name: Gradle
run: chmod +x gradlew

- name: Create directory build/libs
run: mkdir -p build/libs

- name: Download JAR
uses: actions/download-artifact@v4
with:
name: surrealdb
path: build/libs

- name: Tests
run: ./gradlew -i integrationTest

publish:
needs:
- aggregated-jar
- integration-tests
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- name: Set up JDK 22
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 22

- name: Download JAR
uses: actions/download-artifact@v4
with:
name: surrealdb
path: build/libs

- name: Publish release package
uses: softprops/action-gh-release@v2
with:
name: "Release ${{ github.ref_name }}"
files: |
LICENSE
build/libs/*.jar
- name: Publish Jar (Maven)
run: ./gradlew publish
Loading

0 comments on commit 9e3e898

Please sign in to comment.