Skip to content

Commit

Permalink
cargo-apk: Append --target to blanket cargo apk -- calls when not…
Browse files Browse the repository at this point in the history
… provided

When the user doesn't provide a `--target` we default the triple to the
currently connected device over `adb`, or otherwise fall back to
`aarch64`.

While this triple is always used to determine what NDK environment to
provide, it's never added to the arguments passed after `--`; for
example a `cargo apk -- test --no-run` will try to build tests for the
host unless explicitly called with `--target`.
  • Loading branch information
MarijnS95 committed Jun 10, 2022
1 parent 4dd596d commit e65178a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions cargo-apk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- Move NDK r23 `-lgcc` workaround to `ndk-build::cargo::cargo_ndk`, to also apply to our `cargo apk --` invocations. ([#286](https://github.com/rust-windowing/android-ndk-rs/pull/286))
- Append `--target` to blanket `cargo apk --` calls when not provided by the user. ([#287](https://github.com/rust-windowing/android-ndk-rs/pull/287))

# 0.9.1 (2022-05-12)

Expand Down
8 changes: 7 additions & 1 deletion cargo-apk/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ impl<'a> ApkBuilder<'a> {

pub fn check(&self) -> Result<(), Error> {
for target in &self.build_targets {
let triple = target.rust_triple();
let mut cargo = cargo_ndk(
&self.ndk,
*target,
Expand All @@ -107,6 +106,7 @@ impl<'a> ApkBuilder<'a> {
)?;
cargo.arg("check");
if self.cmd.target().is_none() {
let triple = target.rust_triple();
cargo.arg("--target").arg(triple);
}
cargo.args(self.cmd.args());
Expand Down Expand Up @@ -246,6 +246,12 @@ impl<'a> ApkBuilder<'a> {
self.cmd.target_dir(),
)?;
cargo.args(self.cmd.args());

if self.cmd.target().is_none() {
let triple = target.rust_triple();
cargo.arg("--target").arg(triple);
}

if !cargo.status()?.success() {
return Err(NdkError::CmdFailed(cargo).into());
}
Expand Down

0 comments on commit e65178a

Please sign in to comment.