From b02b5f74c25103d6627edabfac14ad8eb479eda1 Mon Sep 17 00:00:00 2001 From: Tim Peut Date: Fri, 1 Sep 2023 12:45:00 -0700 Subject: [PATCH] Add proto map field to AndroidOptimizationInfo. Also set a default value for all fields on the starlark constructor. PiperOrigin-RevId: 562024520 Change-Id: I905361298b7c33ee9825a9f3f4271f1d905397d8 --- .../android/AndroidOptimizationInfo.java | 11 ++++ .../android/AndroidOptimizationInfoApi.java | 58 ++++++++++++++----- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidOptimizationInfo.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidOptimizationInfo.java index 7d9e32a1f06d23..2644f75190e88e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidOptimizationInfo.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidOptimizationInfo.java @@ -36,6 +36,7 @@ public class AndroidOptimizationInfo extends NativeInfo @Nullable private final Artifact seeds; @Nullable private final Artifact libraryJar; @Nullable private final Artifact config; + @Nullable private final Artifact protoMapping; @Nullable private final Artifact rewrittenStartupProfile; @Nullable private final Artifact rewrittenMergedBaselineProfile; @Nullable private final Artifact optimizedResourceApk; @@ -51,6 +52,7 @@ public AndroidOptimizationInfo( Artifact seeds, Artifact libraryJar, Artifact config, + Artifact protoMapping, Artifact rewrittenStartupProfile, Artifact rewrittenMergedBaselineProfile, Artifact optimizedResourceApk, @@ -64,6 +66,7 @@ public AndroidOptimizationInfo( this.seeds = seeds; this.libraryJar = libraryJar; this.config = config; + this.protoMapping = protoMapping; this.rewrittenStartupProfile = rewrittenStartupProfile; this.rewrittenMergedBaselineProfile = rewrittenMergedBaselineProfile; this.optimizedResourceApk = optimizedResourceApk; @@ -109,6 +112,12 @@ public Artifact getConfig() { return config; } + @Override + @Nullable + public Artifact getProtoMapping() { + return protoMapping; + } + @Override @Nullable public Artifact getRewrittenStartupProfile() { @@ -176,6 +185,7 @@ public AndroidOptimizationInfo createInfo( Object seeds, Object libraryJar, Object config, + Object protoMapping, Object rewrittenStartupProfile, Object rewrittenMergedBaselineProfile, Object optimizedResourceApk, @@ -191,6 +201,7 @@ public AndroidOptimizationInfo createInfo( fromNoneable(seeds, Artifact.class), fromNoneable(libraryJar, Artifact.class), fromNoneable(config, Artifact.class), + fromNoneable(protoMapping, Artifact.class), fromNoneable(rewrittenStartupProfile, Artifact.class), fromNoneable(rewrittenMergedBaselineProfile, Artifact.class), fromNoneable(optimizedResourceApk, Artifact.class), diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidOptimizationInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidOptimizationInfoApi.java index c445271995dfee..22e68da0892aaf 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidOptimizationInfoApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidOptimizationInfoApi.java @@ -81,6 +81,15 @@ public interface AndroidOptimizationInfoApi extends Struc @Nullable FileT getConfig(); + @StarlarkMethod( + name = "proto_mapping", + structField = true, + doc = "Returns the proguard proto mapping.", + allowReturnNones = true, + documented = false) + @Nullable + FileT getProtoMapping(); + @StarlarkMethod( name = "rewritten_startup_profile", structField = true, @@ -174,7 +183,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The optimized jar."), + doc = "The optimized jar.", + defaultValue = "None"), @Param( name = "mapping", allowedTypes = { @@ -182,7 +192,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The proguard mapping."), + doc = "The proguard mapping.", + defaultValue = "None"), @Param( name = "seeds", allowedTypes = { @@ -190,7 +201,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The proguard seeds."), + doc = "The proguard seeds.", + defaultValue = "None"), @Param( name = "library_jar", allowedTypes = { @@ -198,7 +210,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The proguard library jar."), + doc = "The proguard library jar.", + defaultValue = "None"), @Param( name = "config", allowedTypes = { @@ -206,7 +219,17 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The proguard config."), + doc = "The proguard config.", + defaultValue = "None"), + @Param( + name = "proto_mapping", + allowedTypes = { + @ParamType(type = FileApi.class), + @ParamType(type = NoneType.class), + }, + named = true, + doc = "The proguard proto mapping.", + defaultValue = "None"), @Param( name = "rewritten_startup_profile", allowedTypes = { @@ -214,7 +237,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The rewritten startup profile."), + doc = "The rewritten startup profile.", + defaultValue = "None"), @Param( name = "rewriten_merged_baseline_profile", allowedTypes = { @@ -222,7 +246,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The rewritten merged baseline profile."), + doc = "The rewritten merged baseline profile.", + defaultValue = "None"), @Param( name = "optimized_resource_apk", allowedTypes = { @@ -230,7 +255,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The optimized resource apk."), + doc = "The optimized resource apk.", + defaultValue = "None"), @Param( name = "shrunk_resource_apk", allowedTypes = { @@ -238,7 +264,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The shrunk resource apk."), + doc = "The shrunk resource apk.", + defaultValue = "None"), @Param( name = "shrunk_resource_zip", allowedTypes = { @@ -246,7 +273,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The shrunk resource zip."), + doc = "The shrunk resource zip.", + defaultValue = "None"), @Param( name = "resource_shrinker_log", allowedTypes = { @@ -254,7 +282,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The resource shrinker log."), + doc = "The resource shrinker log.", + defaultValue = "None"), @Param( name = "resource_optimization_config", allowedTypes = { @@ -262,7 +291,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The resource optimization config."), + doc = "The resource optimization config.", + defaultValue = "None"), @Param( name = "resource_path_shortening_map", allowedTypes = { @@ -270,7 +300,8 @@ interface Provider extends ProviderApi { @ParamType(type = NoneType.class), }, named = true, - doc = "The resource path shortening map."), + doc = "The resource path shortening map.", + defaultValue = "None"), }, selfCall = true) @StarlarkConstructor @@ -280,6 +311,7 @@ AndroidOptimizationInfoApi createInfo( Object seeds, Object libraryJar, Object config, + Object protoMapping, Object rewrittenStartupProfile, Object rewrittenMergedBaselineProfile, Object optimizedResourceApk,