Merge "Do not convert android_library_import with no aars." into main
This commit is contained in:
commit
832e131725
2 changed files with 30 additions and 11 deletions
|
@ -21,6 +21,17 @@ import (
|
||||||
"android/soong/java"
|
"android/soong/java"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func runAndroidLibraryImportTestWithRegistrationCtxFunc(t *testing.T, registrationCtxFunc func(ctx android.RegistrationContext), tc Bp2buildTestCase) {
|
||||||
|
t.Helper()
|
||||||
|
(&tc).ModuleTypeUnderTest = "android_library_import"
|
||||||
|
(&tc).ModuleTypeUnderTestFactory = java.AARImportFactory
|
||||||
|
RunBp2BuildTestCase(t, registrationCtxFunc, tc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runAndroidLibraryImportTest(t *testing.T, tc Bp2buildTestCase) {
|
||||||
|
runAndroidLibraryImportTestWithRegistrationCtxFunc(t, func(ctx android.RegistrationContext) {}, tc)
|
||||||
|
}
|
||||||
|
|
||||||
func TestConvertAndroidLibrary(t *testing.T) {
|
func TestConvertAndroidLibrary(t *testing.T) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
|
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
|
||||||
|
@ -96,20 +107,12 @@ android_library {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConvertAndroidLibraryImport(t *testing.T) {
|
func TestConvertAndroidLibraryImport(t *testing.T) {
|
||||||
t.Helper()
|
runAndroidLibraryImportTestWithRegistrationCtxFunc(t,
|
||||||
RunBp2BuildTestCase(
|
|
||||||
t,
|
|
||||||
func(ctx android.RegistrationContext) {
|
func(ctx android.RegistrationContext) {
|
||||||
ctx.RegisterModuleType("android_library", java.AndroidLibraryFactory)
|
ctx.RegisterModuleType("android_library", java.AndroidLibraryFactory)
|
||||||
},
|
},
|
||||||
Bp2buildTestCase{
|
Bp2buildTestCase{
|
||||||
Description: "Android Library Import",
|
Description: "Android Library Import",
|
||||||
ModuleTypeUnderTest: "android_library_import",
|
|
||||||
ModuleTypeUnderTestFactory: java.AARImportFactory,
|
|
||||||
Filesystem: map[string]string{
|
|
||||||
"import.aar": "",
|
|
||||||
"dep.aar": "",
|
|
||||||
},
|
|
||||||
StubbedBuildDefinitions: []string{"static_lib_dep", "static_import_dep", "static_import_dep-neverlink"},
|
StubbedBuildDefinitions: []string{"static_lib_dep", "static_import_dep", "static_import_dep-neverlink"},
|
||||||
// Bazel's aar_import can only export *_import targets, so we expect
|
// Bazel's aar_import can only export *_import targets, so we expect
|
||||||
// only "static_import_dep" in exports, but both "static_lib_dep" and
|
// only "static_import_dep" in exports, but both "static_lib_dep" and
|
||||||
|
@ -122,7 +125,6 @@ android_library_import {
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: b/301007952 - This dep is needed because android_library_import must have aars set.
|
|
||||||
android_library_import {
|
android_library_import {
|
||||||
name: "static_import_dep",
|
name: "static_import_dep",
|
||||||
aars: ["import.aar"],
|
aars: ["import.aar"],
|
||||||
|
@ -220,3 +222,16 @@ android_library {
|
||||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAarImportFailsToConvertNoAars(t *testing.T) {
|
||||||
|
runAndroidLibraryImportTest(t,
|
||||||
|
Bp2buildTestCase{
|
||||||
|
Description: "Android Library Import with no aars does not convert.",
|
||||||
|
Blueprint: `
|
||||||
|
android_library_import {
|
||||||
|
name: "no_aar_import",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1276,6 +1276,10 @@ func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.Bp2buildMutatorContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AARImport) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
func (a *AARImport) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||||
|
if len(a.properties.Aars) == 0 {
|
||||||
|
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "aars can't be empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
aars := android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Aars, []string{})
|
aars := android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Aars, []string{})
|
||||||
exportableStaticLibs := []string{}
|
exportableStaticLibs := []string{}
|
||||||
// TODO(b/240716882): investigate and handle static_libs deps that are not imports. They are not supported for export by Bazel.
|
// TODO(b/240716882): investigate and handle static_libs deps that are not imports. They are not supported for export by Bazel.
|
||||||
|
|
Loading…
Reference in a new issue