|
13 | 13 | # limitations under the License. |
14 | 14 | """Implementation.""" |
15 | 15 |
|
16 | | -load("//providers:providers.bzl", "AndroidDexInfo", "AndroidFeatureFlagSet", "AndroidIdlInfo", "AndroidInstrumentationInfo", "AndroidLibraryResourceClassJarProvider", "AndroidPreDexJarInfo", "ApkInfo", "BaselineProfileProvider", "DataBindingV2Info", "ProguardMappingInfo", "StarlarkAndroidDexInfo", "StarlarkAndroidResourcesInfo", "StarlarkApkInfo") |
| 16 | +load("//providers:providers.bzl", "AndroidDexInfo", "AndroidFeatureFlagSet", "AndroidIdlInfo", "AndroidInstrumentationInfo", "AndroidLibraryResourceClassJarProvider", "AndroidOptimizationInfo", "AndroidPreDexJarInfo", "ApkInfo", "BaselineProfileProvider", "DataBindingV2Info", "ProguardMappingInfo", "StarlarkAndroidDexInfo", "StarlarkAndroidResourcesInfo", "StarlarkApkInfo") |
17 | 17 | load("//rules:acls.bzl", "acls") |
18 | 18 | load("//rules:apk_packaging.bzl", _apk_packaging = "apk_packaging") |
19 | 19 | load("//rules:baseline_profiles.bzl", _baseline_profiles = "baseline_profiles") |
@@ -315,6 +315,11 @@ def _process_dex(ctx, validation_ctx, packaged_resources_ctx, deploy_ctx, bp_ctx |
315 | 315 | ) |
316 | 316 |
|
317 | 317 | should_optimize_dex = optimizing_dexer and proguarded_jar and not acls.in_disable_optimizing_dexer(str(ctx.label)) |
| 318 | + |
| 319 | + build_metadata_output = None |
| 320 | + if should_optimize_dex and acls.in_d8_optimization_metadata(str(ctx.label)): |
| 321 | + build_metadata_output = ctx.actions.declare_file(ctx.label.name + "_d8_optimization_info.json") |
| 322 | + |
318 | 323 | if proguard_output_map: |
319 | 324 | # Proguard map from preprocessing will be merged with Proguard map for desugared |
320 | 325 | # library. |
@@ -362,6 +367,7 @@ def _process_dex(ctx, validation_ctx, packaged_resources_ctx, deploy_ctx, bp_ctx |
362 | 367 | proguard_output_map = proguard_output_map, |
363 | 368 | postprocessing_output_map = postprocessing_output_map, |
364 | 369 | startup_profile = optimize_ctx.proguard_output.startup_profile_rewritten, |
| 370 | + build_metadata_output = build_metadata_output, |
365 | 371 | inclusion_filter_jar = binary_jar if is_instrumentation(ctx) and not is_binary_optimized else None, |
366 | 372 | transitive_runtime_jars_for_archive = deploy_ctx.transitive_runtime_jars_for_archive, |
367 | 373 | desugar_dict = deploy_ctx.desugar_dict, |
@@ -430,6 +436,9 @@ def _process_dex(ctx, validation_ctx, packaged_resources_ctx, deploy_ctx, bp_ctx |
430 | 436 | ) |
431 | 437 | providers.append(AndroidPreDexJarInfo(pre_dex_jar = binary_jar)) |
432 | 438 |
|
| 439 | + if build_metadata_output != None: |
| 440 | + providers.append(AndroidOptimizationInfo(d8_optimization_info = build_metadata_output)) |
| 441 | + |
433 | 442 | if postprocessing_output_map: |
434 | 443 | providers.append(ProguardMappingInfo(proguard_mapping = postprocessing_output_map)) |
435 | 444 |
|
|
0 commit comments