Skip to content

update ndk to 0.8

update ndk to 0.8 #250

Workflow file for this run

name: Rust
on:
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
env:
SDK_BUILD_TOOLS_VERSION: '33.0.2'
SDK_CMDLINE_TOOLS_VERSION: '9.0'
NDK_VERSION: '25.2.9519653'
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --all -- --check
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
targets: x86_64-linux-android
components: rust-docs
- uses: Swatinem/rust-cache@v2
- name: Documentation
env:
DOCS_RS: 1
run: cargo doc --target x86_64-linux-android --features java-interface,doc-cfg
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Set Up Android tools
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;${{ env.SDK_BUILD_TOOLS_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "cmdline-tools;${{ env.SDK_CMDLINE_TOOLS_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "ndk;${{ env.NDK_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "platforms;android-30"
- name: Config Android NDK
env:
TRIPLE: x86_64-linux-android
run: |
echo "$ANDROID_SDK_ROOT/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
for var in ANDROID_NDK ANDROID_NDK_HOME ANDROID_NDK_LATEST_HOME ANDROID_NDK_ROOT; do
echo "$var=$ANDROID_SDK_ROOT/ndk/$NDK_VERSION" >> $GITHUB_ENV
done
TRIPLE_ENV=$(echo $TRIPLE | tr '-' '_')
echo "CC_${TRIPLE_ENV}=${TRIPLE}21-clang" >> $GITHUB_ENV
echo "CXX_${TRIPLE_ENV}=${TRIPLE}21-clang++" >> $GITHUB_ENV
echo "AR_${TRIPLE_ENV}=llvm-ar" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
target: x86_64-linux-android
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all --features java-interface --all-targets --target x86_64-linux-android
build:
needs:
- format
- docs
- check
- cargo-ndk
runs-on: ubuntu-latest
strategy:
fail-fast: ${{ github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/') }}
matrix:
rust:
- stable
- nightly
profile:
- debug
- release
target:
- armv7-linux-androideabi
- aarch64-linux-android
- i686-linux-android
- x86_64-linux-android
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Set Up Android tools
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;${{ env.SDK_BUILD_TOOLS_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "cmdline-tools;${{ env.SDK_CMDLINE_TOOLS_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "ndk;${{ env.NDK_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "platforms;android-30"
- name: Config Android NDK
run: |
echo "$ANDROID_SDK_ROOT/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
for var in ANDROID_NDK ANDROID_NDK_HOME ANDROID_NDK_LATEST_HOME ANDROID_NDK_ROOT; do
echo "$var=$ANDROID_SDK_ROOT/ndk/$NDK_VERSION" >> $GITHUB_ENV
done
- name: Setup Rust ${{ matrix.rust }} [${{ matrix.target }}]
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
components: rustfmt
- name: Setup Cargo ndk
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-ndk
key: ${{ runner.os }}-cargo-ndk
- uses: Swatinem/rust-cache@v2
- name: Prepare config
id: config
run: |
echo "android-target=$(case "${{ matrix.target }}" in
armv7-linux-androideabi) printf armeabi-v7a;;
aarch64-linux-android) printf arm64-v8a;;
i686-linux-android) printf x86;;
x86_64-linux-android) printf x86_64;;
esac)" >> $GITHUB_OUTPUT
if [[ "${{ matrix.target }}" =~ "64" ]]; then
echo "android-api=21" >> $GITHUB_OUTPUT
else
echo "android-api=19" >> $GITHUB_OUTPUT
fi
if [[ "${{ matrix.profile }}" == "release" ]]; then
echo "cargo-args=--release" >> $GITHUB_OUTPUT
else
echo "cargo-args=" >> $GITHUB_OUTPUT
fi
- name: Build target ${{ matrix.target }}
run: cargo ndk --platform ${{ steps.config.outputs.android-api }} --target ${{ steps.config.outputs.android-target }} --bindgen -- build ${{ steps.config.outputs.cargo-args }} --features generate-bindings
- name: Get latest build path
id: result
run: |
echo "build-path=$(ls -td target/${{ matrix.target }}/${{ matrix.profile }}/build/oboe-sys-*/ | head -1)" >> $GITHUB_OUTPUT
- name: Copy bindings
if: matrix.rust == 'stable' && matrix.profile == 'release'
run: |
mkdir -p bindings
cp ${{ steps.result.outputs.build-path }}out/bindings.rs bindings/bindings_$(echo ${{ matrix.target }} | sed -r 's/^([^-]+).*$/\1/').rs
- name: Upload bindings
if: matrix.rust == 'stable' && matrix.profile == 'release'
uses: actions/upload-artifact@v2
with:
name: bindings
path: bindings
- name: Archive library
if: matrix.rust == 'stable'
run: tar -czf liboboe-ext_${{ matrix.target }}_${{ matrix.profile }}.tar.gz -C ${{ steps.result.outputs.build-path }}/out/library liboboe-ext.a
- name: Upload library
if: matrix.rust == 'stable'
uses: actions/upload-artifact@v2
with:
name: library
path: liboboe-ext_${{ matrix.target }}_${{ matrix.profile }}.tar.gz
update-bindings:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Download bindings
uses: actions/download-artifact@v2
with:
name: bindings
path: sys/src
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
base: ${{ github.head_ref }}
commit-message: Updated bindings
branch: update-bindings
delete-branch: true
title: Update bindings
body: |
Bindings should be updated to be consistent with latest changes
build-demo:
needs:
- build
- cargo-apk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Set Up Android tools
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;${{ env.SDK_BUILD_TOOLS_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "cmdline-tools;${{ env.SDK_CMDLINE_TOOLS_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "ndk;${{ env.NDK_VERSION }}"
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "platforms;android-30"
- name: Setup Rust
uses: hecrj/setup-rust-action@v1
with:
targets: armv7-linux-androideabi, aarch64-linux-android, i686-linux-android, x86_64-linux-android
- name: Setup Cargo apk
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-apk
key: ${{ runner.os }}-cargo-apk
- uses: Swatinem/rust-cache@v2
- name: Create signing key
run: |
if [ -z "${{ secrets.APK_KEYSTORE_PASSWORD }}" ]; then
# create temporary keystore to sign apk
rm -f demo/release.keystore
keytool -genkey -dname "cn=Nobrand, ou=RnD, o=example.com, c=US" -v -keystore demo/release.keystore -alias demo -keyalg RSA -keysize 2048 -validity 20000 -storepass android
else
# use existing keystore to sign apk
sed -i 's/keystore_password = "android"/keystore_password = "${{ secrets.APK_KEYSTORE_PASSWORD }}"/' demo/Cargo.toml
fi
- name: Build demo apk
run: cargo apk build --manifest-path demo/Cargo.toml --release
- name: Upload demo apk
uses: actions/upload-artifact@v2
with:
name: apk
path: target/release/apk/oboe-demo.apk
release:
if: github.repository == 'katyo/oboe-rs' && startsWith(github.ref, 'refs/tags/')
needs:
- build
- build-demo
runs-on: ubuntu-latest
steps:
- name: Download libraries
uses: actions/download-artifact@v2
with:
name: library
- name: Download demo
uses: actions/download-artifact@v2
with:
name: apk
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
*.tar.gz
*.apk
#prerelease: true
#draft: true
fail_on_unmatched_files: true
publish:
if: github.repository == 'katyo/oboe-rs' && startsWith(github.ref, 'refs/tags/')
needs:
- release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Publish crates
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CRATES_TOKEN }}
args: --no-verify
#dry-run: true
cargo-ndk:
runs-on: ubuntu-latest
steps:
- name: Prepare cache
uses: actions/cache@v3
id: cache
with:
path: ~/.cargo/bin/cargo-ndk
key: ${{ runner.os }}-cargo-ndk
- name: Setup cargo ndk
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install cargo-ndk --force
cargo-apk:
runs-on: ubuntu-latest
steps:
- name: Prepare cache
uses: actions/cache@v3
id: cache
with:
path: ~/.cargo/bin/cargo-apk
key: ${{ runner.os }}-cargo-apk
- name: Setup cargo apk
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install cargo-apk