Skip to content

Commit 8f26cfb

Browse files
committed
apk: Use rustc --crate-type=cdylib to always force a lib to be compiled
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.
1 parent 8ce097b commit 8f26cfb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.github/workflows/rust.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ jobs:
7070
run: cargo install --path cargo-apk
7171

7272
- name: Cargo apk build for target ${{ matrix.rust-target }}
73-
run: cargo apk build -p examples --target ${{ matrix.rust-target }} --examples
73+
run: |
74+
cargo apk build -p examples --target ${{ matrix.rust-target }} --example hello_world
75+
cargo apk build -p examples --target ${{ matrix.rust-target }} --example jni_audio
76+
cargo apk build -p examples --target ${{ matrix.rust-target }} --example looper
7477
7578
- uses: actions/upload-artifact@v2
7679
# Only need this for CI, unless users are interested in downloading

cargo-apk/src/apk.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ impl<'a> ApkBuilder<'a> {
228228
self.min_sdk_version(),
229229
self.cmd.target_dir(),
230230
)?;
231-
cargo.arg("build");
231+
cargo.arg("rustc");
232+
cargo.arg("--crate-type=cdylib");
232233
if self.cmd.target().is_none() {
233234
cargo.arg("--target").arg(triple);
234235
}

0 commit comments

Comments
 (0)