Skip to content

Commit

Permalink
apk: Use rustc --crate-type=cdylib to always force a lib to be comp…
Browse files Browse the repository at this point in the history
…iled

This automatically turns `crate-type = ["*lib"]` and `[lib]` targets
into a `cdylib`, and otherwise errors appropriately when encountering a
binary instead of succeeding the build and having `cargo-apk` later
complain when `target/aarch64-linux-android/debug/lib<yourpacakge>.so`
is not found.
  • Loading branch information
MarijnS95 committed Sep 11, 2023
1 parent 8ce097b commit 8f26cfb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ jobs:
run: cargo install --path cargo-apk

- name: Cargo apk build for target ${{ matrix.rust-target }}
run: cargo apk build -p examples --target ${{ matrix.rust-target }} --examples
run: |
cargo apk build -p examples --target ${{ matrix.rust-target }} --example hello_world
cargo apk build -p examples --target ${{ matrix.rust-target }} --example jni_audio
cargo apk build -p examples --target ${{ matrix.rust-target }} --example looper
- uses: actions/upload-artifact@v2
# Only need this for CI, unless users are interested in downloading
Expand Down
3 changes: 2 additions & 1 deletion cargo-apk/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ impl<'a> ApkBuilder<'a> {
self.min_sdk_version(),
self.cmd.target_dir(),
)?;
cargo.arg("build");
cargo.arg("rustc");
cargo.arg("--crate-type=cdylib");
if self.cmd.target().is_none() {
cargo.arg("--target").arg(triple);
}
Expand Down

0 comments on commit 8f26cfb

Please sign in to comment.