Merge "Use raw {min,target}_sdk_version properties in android_app converter" into main

This commit is contained in:
Romain Jobredeaux 2023-09-21 20:58:16 +00:00 committed by Gerrit Code Review
commit 2c11851598
3 changed files with 8 additions and 31 deletions

View file

@ -434,7 +434,6 @@ android_app {
name: "foo",
sdk_version: "current",
min_sdk_version: "24",
max_sdk_version: "30",
target_sdk_version: "29",
optimize: {
enabled: false,
@ -446,7 +445,6 @@ android_app {
"manifest": `"AndroidManifest.xml"`,
"resource_files": `[]`,
"manifest_values": `{
"maxSdkVersion": "30",
"minSdkVersion": "24",
"targetSdkVersion": "29",
}`,
@ -475,12 +473,8 @@ android_app {
MakeBazelTarget("android_binary", "foo", AttrNameToString{
"manifest": `"AndroidManifest.xml"`,
"resource_files": `[]`,
"manifest_values": `{
"minSdkVersion": "30",
"targetSdkVersion": "30",
}`,
"sdk_version": `"30"`,
"optimize": `False`,
"sdk_version": `"30"`,
"optimize": `False`,
}),
}})
}

View file

@ -290,6 +290,7 @@ func platformMappingSingleProduct(
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:memtag_heap_sync_include_paths=%s\n", strings.Join(productVariables.MemtagHeapSyncIncludePaths, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:manifest_package_name_overrides=%s\n", strings.Join(productVariables.ManifestPackageNameOverrides, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:native_coverage=%t\n", proptools.Bool(productVariables.Native_coverage)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:platform_sdk_final=%t\n", proptools.Bool(productVariables.Platform_sdk_final)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:platform_version_name=%s\n", proptools.String(productVariables.Platform_version_name)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:product_brand=%s\n", productVariables.ProductBrand))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:product_manufacturer=%s\n", productVariables.ProductManufacturer))

View file

@ -1622,7 +1622,6 @@ func androidAppCertificateBp2Build(ctx android.Bp2buildMutatorContext, module *A
type manifestValueAttribute struct {
MinSdkVersion *string
MaxSdkVersion *string
TargetSdkVersion *string
}
@ -1636,6 +1635,7 @@ type bazelAndroidAppAttributes struct {
Manifest_values *manifestValueAttribute
Optimize *bool
Proguard_specs bazel.LabelListAttribute
Updatable *bool
}
func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (bool, android.CommonAttributes, *bazelAndroidAppAttributes) {
@ -1660,28 +1660,9 @@ func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (boo
certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate)
manifestValues := &manifestValueAttribute{}
// TODO(b/274474008 ): Directly convert deviceProperties.Min_sdk_version in bp2build
// MinSdkVersion(ctx) calls SdkVersion(ctx) if no value for min_sdk_version is set
minSdkVersion := a.MinSdkVersion(ctx)
if !minSdkVersion.IsPreview() && !minSdkVersion.IsInvalid() {
if minSdkStr, err := minSdkVersion.EffectiveVersionString(ctx); err == nil {
manifestValues.MinSdkVersion = &minSdkStr
}
}
maxSdkVersion := a.MaxSdkVersion(ctx)
if !maxSdkVersion.IsPreview() && !maxSdkVersion.IsInvalid() {
if maxSdkStr, err := maxSdkVersion.EffectiveVersionString(ctx); err == nil {
manifestValues.MaxSdkVersion = &maxSdkStr
}
}
targetSdkVersion := a.TargetSdkVersion(ctx)
if !targetSdkVersion.IsPreview() && !targetSdkVersion.IsInvalid() {
if targetSdkStr, err := targetSdkVersion.EffectiveVersionString(ctx); err == nil {
manifestValues.TargetSdkVersion = &targetSdkStr
}
manifestValues := &manifestValueAttribute{
MinSdkVersion: a.deviceProperties.Min_sdk_version,
TargetSdkVersion: a.deviceProperties.Target_sdk_version,
}
appAttrs := &bazelAndroidAppAttributes{
@ -1690,6 +1671,7 @@ func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (boo
Certificate: certificate,
Certificate_name: certificateName,
Manifest_values: manifestValues,
Updatable: a.appProperties.Updatable,
}
if !BoolDefault(a.dexProperties.Optimize.Enabled, true) {