Skip to content

Commit

Permalink
Build android
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Jun 5, 2024
1 parent 24cac4e commit 29e1026
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
43 changes: 42 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ on:
required: false
type: boolean
default: false
skip-android:
required: false
type: boolean
default: false

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -57,7 +61,7 @@ jobs:
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: "aarch64-linux-gnu-gcc"
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: "arm-linux-gnueabihf-gcc"
run: cargo build --verbose --release --target=${{ matrix.target }}
run: cargo build --verbose --release --target=${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: hath-rust-${{ matrix.target }}
Expand Down Expand Up @@ -161,3 +165,40 @@ jobs:
with:
name: hath-rust-universal-apple-darwin
path: target/release/hath-rust
build-android:
runs-on: ubuntu-latest
if: inputs.skip-android != true
strategy:
fail-fast: false
matrix:
target: ["aarch64-linux-android", "armv7-linux-androideabi", "i686-linux-android", "x86_64-linux-android"]
steps:
- uses: actions/checkout@v4
- name: Install Android NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r26d
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install toolchain
run: |
rustup update
rustup target add ${{ matrix.target }}
- name: Build
env:
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: "aarch64-linux-android21-clang"
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER: "armv7a-linux-androideabi21-clang"
CARGO_TARGET_I686_LINUX_ANDROID_LINKER: "i686-linux-android21-clang"
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER: "x86_64-linux-android21-clang"
run: cargo build --verbose --release --target=${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: hath-rust-${{ matrix.target }}
path: target/${{ matrix.target }}/release/hath-rust
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
mv artifacts/hath-rust-x86_64-pc-windows-msvc/hath-rust.exe hath-rust-x86_64-pc-windows-msvc.exe
mv artifacts/hath-rust-i686-pc-windows-msvc/hath-rust.exe hath-rust-i686-pc-windows-msvc.exe
mv artifacts/hath-rust-universal-apple-darwin/hath-rust hath-rust-universal-apple-darwin
mv artifacts/hath-rust-aarch64-linux-android/hath-rust hath-rust-aarch64-linux-android
mv artifacts/hath-rust-armv7-linux-androideabi/hath-rust hath-rust-armv7-linux-androideabi
mv artifacts/hath-rust-i686-linux-android/hath-rust hath-rust-i686-linux-android
mv artifacts/hath-rust-x86_64-linux-android/hath-rust hath-rust-x86_64-linux-android
- name: Create release
uses: softprops/action-gh-release@v2
with:
Expand All @@ -42,4 +46,8 @@ jobs:
hath-rust-armv7-unknown-linux-musleabihf
hath-rust-x86_64-pc-windows-msvc.exe
hath-rust-i686-pc-windows-msvc.exe
hath-rust-universal-apple-darwin
hath-rust-universal-apple-darwin
hath-rust-aarch64-linux-android
hath-rust-armv7-linux-androideabi
hath-rust-i686-linux-android
hath-rust-x86_64-linux-android
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ unicode-segmentation = "1.11.0"
[target.'cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
cpufeatures = "0.2"

[target.'cfg(not(any(target_env = "msvc", target_os = "macos")))'.dependencies]
[target.'cfg(not(any(target_env = "msvc", target_os = "macos", target_os = "android")))'.dependencies]
tikv-jemallocator = { version = "0.5", features = ["background_threads", "unprefixed_malloc_on_supported_platforms"] }

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod rpc;
mod server;
mod util;

#[cfg(not(target_env = "msvc"))]
#[cfg(not(any(target_env = "msvc", target_os = "android")))]
#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

Expand Down

0 comments on commit 29e1026

Please sign in to comment.