mirror of
https://github.com/imsnif/bandwhich.git
synced 2026-02-09 01:59:18 +08:00
Enable Android build (#384)
* Support build for target_os android The target_os `android` is quite similar to `linux` but must be mentioned in the guards explicitly. Tested for target `aarch64-linux-android`. * Add target aarch64-linux-android to ci Use `cross` for building target `aarch64-linux-android`. In the `ci` workflow the matrix branch of `os` `ubuntu-latest` is used because the matrix organization is host os centric instead of target. Releases are build with `cross` for target `aarch64-linux-android`. Install `cross` if needed for a run. At the time of writing the latest release of `cross` can't build binaries for target `aarch64-linux-android` and it's common sense that the latest git tag or `master` shall be used [1]. [1] https://github.com/cross-rs/cross/issues/1222 * Add android related readme section
This commit is contained in:
21
.github/workflows/ci.yaml
vendored
21
.github/workflows/ci.yaml
vendored
@@ -47,13 +47,25 @@ jobs:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Install Cross on Ubuntu
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
# The latest realese of `cross` is not able to build/link for `aarch64-linux-android`
|
||||
# See: https://github.com/cross-rs/cross/issues/1222
|
||||
# This is fixed on `main` but not yet released. To avoid a breakage somewhen in the future
|
||||
# pin the cross revision used to the latest HEAD at 04/2024.
|
||||
# Remove the git source and revision once cross 0.3 is released.
|
||||
run: cargo install --git https://github.com/cross-rs/cross.git --rev 085092c cross
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
run: cargo build --verbose
|
||||
|
||||
- name: Build target aarch64-linux-android
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: cross build --target aarch64-linux-android --verbose
|
||||
|
||||
# This is useful for debugging problems when the expected build artifacts
|
||||
# (like shell completions and man pages) aren't generated.
|
||||
- name: Show build.rs stderr
|
||||
@@ -103,6 +115,13 @@ jobs:
|
||||
name: ${{ matrix.os }}-${{ matrix.rust }}-failed_snapshots
|
||||
path: '**/*.snap.new'
|
||||
|
||||
- name: Upload android binary
|
||||
if: ${{ matrix.os == 'ubuntu-latest' && ( success() || steps.build.outcome == 'success' ) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aarch64-linux-android-${{ matrix.rust }}
|
||||
path: target/aarch64-linux-android/debug/bandwhich
|
||||
|
||||
- name: Upload unix binary
|
||||
if: ${{ matrix.os != 'windows-latest' && ( success() || steps.build.outcome == 'success' ) }}
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
12
.github/workflows/release.yaml
vendored
12
.github/workflows/release.yaml
vendored
@@ -52,11 +52,17 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
build:
|
||||
- aarch64-linux-android
|
||||
- linux-x64-gnu
|
||||
- linux-x64-musl
|
||||
- macos-x64
|
||||
- windows-x64-msvc
|
||||
include:
|
||||
- cargo: cargo # default; overwrite with `cross` if necessary
|
||||
- build: aarch64-linux-android
|
||||
os: ubuntu-latest
|
||||
target: aarch64-linux-android
|
||||
cargo: cross
|
||||
- build: linux-x64-gnu
|
||||
os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
@@ -84,13 +90,17 @@ jobs:
|
||||
if: matrix.target == 'x86_64-unknown-linux-musl'
|
||||
run: sudo apt-get install -y --no-install-recommends musl-tools
|
||||
|
||||
- name: Install cross
|
||||
if: matrix.cargo == 'cross'
|
||||
run: cargo install --git https://github.com/cross-rs/cross.git --rev 085092c cross
|
||||
|
||||
- name: Build release binary
|
||||
shell: bash
|
||||
env:
|
||||
RUSTFLAGS: "-C strip=symbols"
|
||||
run: |
|
||||
mkdir -p "$BANDWHICH_GEN_DIR"
|
||||
cargo build --verbose --release --target ${{ matrix.target }}
|
||||
${{ matrix.cargo }} build --verbose --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Collect build artifacts
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user