Merge "Bp2build for android_app minsdkversion property"
This commit is contained in:
@@ -710,6 +710,10 @@ var (
|
|||||||
// for building com.android.neuralnetworks
|
// for building com.android.neuralnetworks
|
||||||
"libimapper_stablec",
|
"libimapper_stablec",
|
||||||
"libimapper_providerutils",
|
"libimapper_providerutils",
|
||||||
|
|
||||||
|
// min_sdk_version in android_app
|
||||||
|
"CtsShimUpgrade",
|
||||||
|
"fake-framework",
|
||||||
}
|
}
|
||||||
|
|
||||||
Bp2buildModuleTypeAlwaysConvertList = []string{
|
Bp2buildModuleTypeAlwaysConvertList = []string{
|
||||||
|
@@ -344,3 +344,50 @@ android_app {
|
|||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAndroidAppMinSdkProvided(t *testing.T) {
|
||||||
|
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "Android app with value for min_sdk_version",
|
||||||
|
ModuleTypeUnderTest: "android_app",
|
||||||
|
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||||
|
Filesystem: map[string]string{},
|
||||||
|
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||||
|
android_app {
|
||||||
|
name: "foo",
|
||||||
|
sdk_version: "current",
|
||||||
|
min_sdk_version: "24",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("android_binary", "foo", AttrNameToString{
|
||||||
|
"manifest": `"AndroidManifest.xml"`,
|
||||||
|
"resource_files": `[]`,
|
||||||
|
"manifest_values": `{
|
||||||
|
"minSdkVersion": "24",
|
||||||
|
}`,
|
||||||
|
}),
|
||||||
|
}})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAndroidAppMinSdkDefaultToSdkVersion(t *testing.T) {
|
||||||
|
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "Android app with value for sdk_version",
|
||||||
|
ModuleTypeUnderTest: "android_app",
|
||||||
|
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||||
|
Filesystem: map[string]string{},
|
||||||
|
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||||
|
android_app {
|
||||||
|
name: "foo",
|
||||||
|
sdk_version: "30",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("android_binary", "foo", AttrNameToString{
|
||||||
|
"manifest": `"AndroidManifest.xml"`,
|
||||||
|
"resource_files": `[]`,
|
||||||
|
"manifest_values": `{
|
||||||
|
"minSdkVersion": "30",
|
||||||
|
}`,
|
||||||
|
}),
|
||||||
|
}})
|
||||||
|
}
|
||||||
|
16
java/app.go
16
java/app.go
@@ -1495,6 +1495,10 @@ func androidAppCertificateBp2Build(ctx android.TopDownMutatorContext, module *An
|
|||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type manifestValueAttribute struct {
|
||||||
|
MinSdkVersion *string
|
||||||
|
}
|
||||||
|
|
||||||
type bazelAndroidAppAttributes struct {
|
type bazelAndroidAppAttributes struct {
|
||||||
*javaCommonAttributes
|
*javaCommonAttributes
|
||||||
*bazelAapt
|
*bazelAapt
|
||||||
@@ -1502,6 +1506,7 @@ type bazelAndroidAppAttributes struct {
|
|||||||
Custom_package *string
|
Custom_package *string
|
||||||
Certificate bazel.LabelAttribute
|
Certificate bazel.LabelAttribute
|
||||||
Certificate_name bazel.StringAttribute
|
Certificate_name bazel.StringAttribute
|
||||||
|
Manifest_values *manifestValueAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertWithBp2build is used to convert android_app to Bazel.
|
// ConvertWithBp2build is used to convert android_app to Bazel.
|
||||||
@@ -1516,11 +1521,22 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
|
|
||||||
certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate)
|
certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate)
|
||||||
|
|
||||||
|
manifestValues := &manifestValueAttribute{}
|
||||||
|
// MinSdkVersion(ctx) calls SdkVersion(ctx) if no value for min_sdk_version is set
|
||||||
|
minSdkSpec := a.MinSdkVersion(ctx)
|
||||||
|
if !minSdkSpec.ApiLevel.IsPreview() && minSdkSpec.Valid() {
|
||||||
|
minSdkStr, err := minSdkSpec.EffectiveVersionString(ctx)
|
||||||
|
if err == nil {
|
||||||
|
manifestValues.MinSdkVersion = &minSdkStr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
appAttrs := &bazelAndroidAppAttributes{
|
appAttrs := &bazelAndroidAppAttributes{
|
||||||
// TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
|
// TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
|
||||||
Custom_package: a.overridableAppProperties.Package_name,
|
Custom_package: a.overridableAppProperties.Package_name,
|
||||||
Certificate: certificate,
|
Certificate: certificate,
|
||||||
Certificate_name: certificateName,
|
Certificate_name: certificateName,
|
||||||
|
Manifest_values: manifestValues,
|
||||||
}
|
}
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
Reference in New Issue
Block a user