Skip to content

Commit

Permalink
Add proto map field to AndroidOptimizationInfo.
Browse files Browse the repository at this point in the history
Also set a default value for all fields on the starlark constructor.

PiperOrigin-RevId: 562024520
Change-Id: I905361298b7c33ee9825a9f3f4271f1d905397d8
  • Loading branch information
timpeut authored and copybara-github committed Sep 1, 2023
1 parent e7d847f commit b02b5f7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -51,6 +52,7 @@ public AndroidOptimizationInfo(
Artifact seeds,
Artifact libraryJar,
Artifact config,
Artifact protoMapping,
Artifact rewrittenStartupProfile,
Artifact rewrittenMergedBaselineProfile,
Artifact optimizedResourceApk,
Expand All @@ -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;
Expand Down Expand Up @@ -109,6 +112,12 @@ public Artifact getConfig() {
return config;
}

@Override
@Nullable
public Artifact getProtoMapping() {
return protoMapping;
}

@Override
@Nullable
public Artifact getRewrittenStartupProfile() {
Expand Down Expand Up @@ -176,6 +185,7 @@ public AndroidOptimizationInfo createInfo(
Object seeds,
Object libraryJar,
Object config,
Object protoMapping,
Object rewrittenStartupProfile,
Object rewrittenMergedBaselineProfile,
Object optimizedResourceApk,
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public interface AndroidOptimizationInfoApi<FileT extends FileApi> 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,
Expand Down Expand Up @@ -174,103 +183,125 @@ interface Provider<FileT extends FileApi> extends ProviderApi {
@ParamType(type = NoneType.class),
},
named = true,
doc = "The optimized jar."),
doc = "The optimized jar.",
defaultValue = "None"),
@Param(
name = "mapping",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The proguard mapping."),
doc = "The proguard mapping.",
defaultValue = "None"),
@Param(
name = "seeds",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The proguard seeds."),
doc = "The proguard seeds.",
defaultValue = "None"),
@Param(
name = "library_jar",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The proguard library jar."),
doc = "The proguard library jar.",
defaultValue = "None"),
@Param(
name = "config",
allowedTypes = {
@ParamType(type = FileApi.class),
@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 = {
@ParamType(type = FileApi.class),
@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 = {
@ParamType(type = FileApi.class),
@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 = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The optimized resource apk."),
doc = "The optimized resource apk.",
defaultValue = "None"),
@Param(
name = "shrunk_resource_apk",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The shrunk resource apk."),
doc = "The shrunk resource apk.",
defaultValue = "None"),
@Param(
name = "shrunk_resource_zip",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The shrunk resource zip."),
doc = "The shrunk resource zip.",
defaultValue = "None"),
@Param(
name = "resource_shrinker_log",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The resource shrinker log."),
doc = "The resource shrinker log.",
defaultValue = "None"),
@Param(
name = "resource_optimization_config",
allowedTypes = {
@ParamType(type = FileApi.class),
@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 = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The resource path shortening map."),
doc = "The resource path shortening map.",
defaultValue = "None"),
},
selfCall = true)
@StarlarkConstructor
Expand All @@ -280,6 +311,7 @@ AndroidOptimizationInfoApi<FileT> createInfo(
Object seeds,
Object libraryJar,
Object config,
Object protoMapping,
Object rewrittenStartupProfile,
Object rewrittenMergedBaselineProfile,
Object optimizedResourceApk,
Expand Down

0 comments on commit b02b5f7

Please sign in to comment.