Skip to content
Closed
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
2 changes: 1 addition & 1 deletion rules/android_binary/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def _process_optimize(ctx, validation_ctx, deploy_ctx, packaged_resources_ctx, b
# Proguard map from shrinking is the final output.
proguard_output_map = ctx.actions.declare_file(ctx.label.name + "_proguard.map")

if ctx.attr._generate_proguard_outputs:
if not acls.use_r8(str(ctx.label)) and ctx.attr._generate_proguard_outputs:
proguard_output_jar = ctx.outputs.proguard_jar
proguard_output_config = ctx.outputs.proguard_config
else:
Expand Down
1 change: 1 addition & 0 deletions test/rules/android_binary/r8_integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ py_test(
"//test/rules/android_binary/r8_integration/java/com/basicapp:basic_app_R8_no_shrink",
"//test/rules/android_binary/r8_integration/java/com/basicapp:basic_app_R8_shrink",
"//test/rules/android_binary/r8_integration/java/com/basicapp:basic_app_no_R8",
"//test/rules/android_binary/r8_integration/java/com/basicapp:basic_app_select_R8_genmap",
"@androidsdk//:dexdump",
],
)
Expand Down
28 changes: 26 additions & 2 deletions test/rules/android_binary/r8_integration/java/com/basicapp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,41 @@ load("//rules:rules.bzl", "android_binary", "android_library")
proguard_specs = specs,
resource_files = glob(["res/**"]),
shrink_resources = shrink,
proguard_generate_mapping = genmap,
visibility = ["//test/rules/android_binary/r8_integration:__pkg__"],
deps = [
":basic_lib",
":lib_with_specs",
],
)
for name, specs, shrink in [
for name, specs, shrink, genmap in [
(
"basic_app_R8_shrink",
["proguard.cfg"],
True,
False,
),
(
"basic_app_R8_no_shrink",
["proguard.cfg"],
False,
False,
),
(
"basic_app_no_R8",
[],
False,
False,
),
(
"basic_app_select_R8_genmap",
select({
":is_c_opt": ["proguard.cfg"],
"//conditions:default": [],
}),
True,
True,
),
("basic_app_no_R8", [], False),
]
]

Expand All @@ -58,3 +75,10 @@ android_library(
manifest = "AndroidManifest_lib.xml",
proguard_specs = ["lib2_proguard.cfg"],
)

config_setting(
name = "is_c_opt",
values = {
"compilation_mode": "opt",
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def test_r8_integration(self):
expect_unused_activity_class=False,
)

# No R8 when run in default test mode (non-opt),
# so unused resources and unused classes should be in the app
self._r8_integration_check(
"basic_app_select_R8_genmap.apk",
expect_unused_activity_resource=True,
expect_unused_activity_class=True,
)


if __name__ == "__main__":
dexdump = sys.argv.pop()
Expand Down