Skip to content

Dart bindings

Dart bindings #4

Workflow file for this run

name: Dart bindings
on:
push:
tags: [ 'v*.*.*', 'dart-build*' ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [android, linux]
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install dependencies (Linux)
if: matrix.platform == 'linux'
run: sudo apt-get install -y libssl-dev pkg-config
- name: Install Android NDK and toolchain (Android)
if: matrix.platform == 'android'
run: |
sudo apt-get update
sudo apt-get install -y wget unzip
wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip -O android-ndk.zip
unzip android-ndk.zip
export ANDROID_NDK_HOME=$PWD/android-ndk-r25b
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
rustup target add x86_64-linux-android
- name: Build Rust library for Linux
if: matrix.platform == 'linux'
run: cargo build --release --target-dir target/linux-target
- name: Verify NDK Installation
if: matrix.platform == 'android'
run: |
ls -l $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
ls -l $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang
ls -l $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang
ls -l $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang
- name: Build Rust library for Android
if: matrix.platform == 'android'
env:
ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }}
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: ${{ env.ANDROID_NDK_HOME }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER: ${{ env.ANDROID_NDK_HOME }}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang
CARGO_TARGET_I686_LINUX_ANDROID_LINKER: ${{ env.ANDROID_NDK_HOME }}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER: ${{ env.ANDROID_NDK_HOME }}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang
run: |
cargo build --release --target aarch64-linux-android
cargo build --release --target armv7-linux-androideabi
cargo build --release --target i686-linux-android
cargo build --release --target x86_64-linux-android
- name: Package Rust library for Dart
run: |
mkdir -p lib/native/${{ matrix.platform }}
if [ ${{ matrix.platform }} == 'linux' ]; then
cp target/linux-target/release/libdartmesagkesto.so lib/native/linux/
elif [ ${{ matrix.platform }} == 'android' ]; then
cp target/aarch64-linux-android/release/libdartmesagkesto.so lib/native/android/aarch64/
cp target/armv7-linux-androideabi/release/libdartmesagkesto.so lib/native/android/armv7/
cp target/i686-linux-android/release/libdartmesagkesto.so lib/native/android/i686/
cp target/x86_64-linux-android/release/libdartmesagkesto.so lib/native/android/x86_64/
fi
# Note: This workflow uses the latest stable version of the Dart SDK.
# You can specify other versions if desired, see documentation here:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
# - uses: dart-lang/setup-dart@v1
- uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
- name: Install dependencies
run: dart pub get
# Consider passing '--fatal-infos' for slightly stricter analysis.
- name: Analyze project source
run: dart analyze
- name: Prepare Dart package for pub.dev
run: |
dart pub get
dart pub publish --dry-run
- name: Publish Dart package to pub.dev
run: dart pub publish -f
env:
PUB_DEV_TOKEN: ${{ secrets.PUB_DEV_TOKEN }}