Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndk-build,cargo-apk: Disable aapt compression for the dev profile #283

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 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))
- 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))

# 0.9.1 (2022-05-12)

Expand Down
1 change: 1 addition & 0 deletions cargo-apk/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl<'a> ApkBuilder<'a> {
assets,
resources,
manifest,
disable_aapt_compression: self.cmd.profile() == &Profile::Dev,
};
let apk = config.create_apk()?;

Expand Down
3 changes: 2 additions & 1 deletion ndk-build/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- **Breaking:** Provide NDK r23 `-lgcc` workaround in `cargo_ndk` function, now requiring `target_dir` as argument. ([#286](https://github.com/rust-windowing/android-ndk-rs/pull/286))
- **Breaking:** Provide NDK r23 `-lgcc` workaround in `cargo_ndk()` function, now requiring `target_dir` as argument. ([#286](https://github.com/rust-windowing/android-ndk-rs/pull/286))
- **Breaking:** Add `disable_aapt_compression` field to `ApkConfig` to disable `aapt` compression. ([#283](https://github.com/rust-windowing/android-ndk-rs/pull/283))

# 0.5.0 (2022-05-07)

Expand Down
16 changes: 13 additions & 3 deletions ndk-build/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct ApkConfig {
pub assets: Option<PathBuf>,
pub resources: Option<PathBuf>,
pub manifest: AndroidManifest,
pub disable_aapt_compression: bool,
}

impl ApkConfig {
Expand Down Expand Up @@ -51,6 +52,10 @@ impl ApkConfig {
.arg("-I")
.arg(self.ndk.android_jar(target_sdk_version)?);

if self.disable_aapt_compression {
aapt.arg("-0").arg("");
}

if let Some(res) = &self.resources {
aapt.arg("-S").arg(res);
}
Expand Down Expand Up @@ -90,9 +95,14 @@ impl<'a> UnalignedApk<'a> {
let lib_path_unix = lib_path.to_str().unwrap().replace('\\', "/");

let mut aapt = self.0.build_tool(bin!("aapt"))?;
aapt.arg("add")
.arg(self.0.unaligned_apk())
.arg(lib_path_unix);
aapt.arg("add");

if self.0.disable_aapt_compression {
aapt.arg("-0").arg("");
}

aapt.arg(self.0.unaligned_apk()).arg(lib_path_unix);

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