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

Precise Resource Shrinker + aapt2 optimize #217

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Next Next commit
r8 precise shrink
  • Loading branch information
benjaminRomano committed Mar 13, 2024
commit c71287b828236544b2278a44a5244bbf33d78e63
20 changes: 14 additions & 6 deletions rules/android_binary_internal/r8.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,24 @@ def process_resource_shrinking_r8(ctx, r8_ctx, packaged_resources_ctx, **_unused
proto_resource_apk_shrunk = ctx.actions.declare_file(
ctx.label.name + "_proto_resource_apk_shrunk.ap_",
)

resource_shrinking_usage_log = ctx.actions.declare_file(ctx.label.name + "_resource_shrinking_usage.log")
args = ctx.actions.args()
args.add("--input", proto_resource_apk)
args.add("--dex_input", final_classes_dex_zip)

args.add("--proguard_mapping", final_proguard_output_map)
args.add("--output", proto_resource_apk_shrunk)
args.add("--precise_shrinking", "true")
args.add("--print_usage_log", resource_shrinking_usage_log)

java.run(
ctx = ctx,
host_javabase = common.get_host_javabase(ctx),
executable = android_toolchain.resource_shrinker.files_to_run,
arguments = [ctx.actions.args()
.add("--input", proto_resource_apk)
.add("--dex_input", r8_ctx.final_classes_dex_zip)
.add("--output", proto_resource_apk_shrunk)],
inputs = [proto_resource_apk, r8_ctx.final_classes_dex_zip],
outputs = [proto_resource_apk_shrunk],
arguments = [args],
inputs = [proto_resource_apk, final_classes_dex_zip, final_proguard_output_map],
outputs = [proto_resource_apk_shrunk, resource_shrinking_usage_log],
mnemonic = "ResourceShrinkerForR8",
progress_message = "Shrinking resources %{label}",
)
Expand Down