Skip to content

Commit

Permalink
Filter synthetics map out of jar before optimization.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 682093365
Change-Id: I945221e33c72643c800c34707f8380cf42bd6775
  • Loading branch information
timpeut authored and copybara-github committed Oct 4, 2024
1 parent 889e811 commit adb64f8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion rules/android_binary/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,23 @@ def _process_optimize(ctx, validation_ctx, deploy_ctx, packaged_resources_ctx, b
enable_rewrite_resources_through_optimizer = enable_resource_shrinking and ctx.attr._rewrite_resources_through_optimizer

optimized_resource_shrinker_log = ctx.actions.declare_file(_resources.get_shrinker_log_name(ctx)) if resource_shrinking_in_optimizer else None

# Pre-process (i.e. filter) the deploy jar before passing to optimizer.
# The desugared synthetics map is not updated by the optimizer with the
# new class names. Optimization invalidates this mapping, so simply remove
# it. The mapping is useful for incremental dexing but is not needed for
# monolithic dexing.
filtered_deploy_jar = ctx.actions.declare_file(ctx.label.name + "_filtered_deploy.jar")
common.filter_zip_exclude(
ctx,
output = filtered_deploy_jar,
input = deploy_ctx.deploy_jar,
filters = ["META-INF/metadata/synthetic-contexts.map"],
)

proguard_output = proguard.apply_proguard(
ctx,
input_jar = deploy_ctx.deploy_jar,
input_jar = filtered_deploy_jar,
proguard_specs = proguard_specs,
proguard_optimization_passes = getattr(ctx.attr, "proguard_optimization_passes", None),
proguard_output_jar = proguard_output_jar,
Expand Down

0 comments on commit adb64f8

Please sign in to comment.