Skip to content

Commit

Permalink
Merge branch 'joamag/libretro-android' into 'master'
Browse files Browse the repository at this point in the history
Added Android support for Libretro

Closes #35

See merge request joamag/boytacean!34
  • Loading branch information
joamag committed Sep 16, 2023
2 parents fe82662 + e06c1d4 commit ce1f8f0
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[target.aarch64-linux-android]
ar = "./ndk/arm64/bin/aarch64-linux-android-ar"
linker = "./ndk/arm64/bin/aarch64-linux-android-clang"

[target.armv7-linux-androideabi]
ar = "./ndk/arm/bin/arm-linux-androideabi-ar"
linker = "./ndk/arm/bin/arm-linux-androideabi-clang"

[target.i686-linux-android]
ar = "./ndk/x86/bin/i686-linux-android-ar"
linker = "./ndk/x86/bin/i686-linux-android-clang"
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
with:
name: boytacean-linux
path: |
frontends/libretro/res/boytacean_libretro.info
target/release/boytacean-sdl-linux-x64
target/release/libboytacean.so
target/release/boytacean_libretro.so
Expand Down Expand Up @@ -153,6 +154,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
boytacean-linux//boytacean_libretro.info
boytacean-linux/boytacean-sdl-linux-x64
boytacean-linux/libboytacean.so
boytacean-linux/boytacean_libretro.so
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,63 @@ jobs:
- name: Build release version
run: cd frontends/libretro && cargo build --release
if: matrix.rust-version == '1.71.0'
build-libretro-android:
name: Build Libretro Android
timeout-minutes: 30
strategy:
matrix:
rust-version: [
"1.71.0",
"latest"
]
runs-on: ubuntu-latest
container: rust:${{ matrix.rust-version }}
steps:
- name: Checkout code from repository
uses: actions/checkout@v3
- name: Install Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25c
- name: Install Dependencies
run: |
apt-get update
apt-get install -y -q zip
- name: Install Rust components
run: |
rustup component add rustfmt
rustup component add clippy
- name: Print Rust information
run: rustc --version
- name: Setup local NDK
run: |
mkdir -p ndk
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch arm64 --install-dir ndk/arm64
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch arm --install-dir ndk/arm
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch x86 --install-dir ndk/x86
env:
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Add Rust Android targets
run: |
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
- name: Verify Rust code format
run: cd frontends/libretro && cargo fmt --all -- --check
- name: Verify Rust code linting
run: cd frontends/libretro && cargo clippy -- -D warnings -A unknown-lints
- name: Run unit tests
run: cd frontends/libretro && cargo test
- name: Build development version
run: |
cd frontends/libretro
cargo build --target=aarch64-linux-android
cargo build --target=armv7-linux-androideabi
cargo build --target=i686-linux-android
- name: Build release version
run: |
cd frontends/libretro
cargo build --target=aarch64-linux-android --release
cargo build --target=armv7-linux-androideabi --release
cargo build --target=i686-linux-android --release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ Cargo.lock

/.idea

/ndk
/target
/res/roms.prop
/frontends/*/target
/frontends/*/ndk

/src/gen/build.rs
/src/gen/_build.rs
27 changes: 27 additions & 0 deletions frontends/libretro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,30 @@
```bash
cargo build
```

### Android

Configure `NDK_HOME` environment variable to point to your Android NDK directory and then create local toolchain replicas in the root project directory using:

```bash
mkdir -p ndk
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch arm64 --install-dir ndk/arm64
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch arm --install-dir ndk/arm
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 26 --arch x86 --install-dir ndk/x86
```

To install the Rust targets for Android using rustup run:

```bash
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
```

Then you're ready to build Boytacean's libretro core using the following commands (for release builds):

```bash
cargo build --target=aarch64-linux-android --release
cargo build --target=armv7-linux-androideabi --release
cargo build --target=i686-linux-android --release
```

0 comments on commit ce1f8f0

Please sign in to comment.