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 8da0967 commit 04a47ad
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
Expand Up @@ -2,6 +2,7 @@

- 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))
- Disable `aapt` compression for the [(default) `dev` profile](https://doc.rust-lang.org/cargo/reference/profiles.html). ([#283](https://github.com/rust-windowing/android-ndk-rs/pull/283))
- 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 @@ -247,6 +247,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 04a47ad

Please sign in to comment.