Loading bp2build/android_app_conversion_test.go +27 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ func runAndroidAppTestCase(t *testing.T, tc Bp2buildTestCase) { func registerAndroidAppModuleTypes(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.RegisterModuleType("java_library", java.LibraryFactory) } func TestMinimalAndroidApp(t *testing.T) { Loading Loading @@ -200,3 +201,29 @@ android_app { }), }}) } func TestAndroidAppLibs(t *testing.T) { runAndroidAppTestCase(t, Bp2buildTestCase{ Description: "Android app with libs", ModuleTypeUnderTest: "android_app", ModuleTypeUnderTestFactory: java.AndroidAppFactory, Filesystem: map[string]string{}, Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + ` android_app { name: "foo", libs: ["barLib"] } java_library{ name: "barLib", } `, ExpectedBazelTargets: []string{ MakeBazelTarget("java_library", "barLib", AttrNameToString{}), MakeNeverlinkDuplicateTarget("java_library", "barLib"), MakeBazelTarget("android_binary", "foo", AttrNameToString{ "manifest": `"AndroidManifest.xml"`, "resource_files": `[]`, "deps": `[":barLib-neverlink"]`, }), }}) } java/java.go +3 −1 Original line number Diff line number Diff line Loading @@ -2677,7 +2677,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) if m.properties.Libs != nil { // TODO 244210934 ALIX Check if this else statement breaks presubmits get rid of it if it doesn't if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") || ctx.ModuleType() == "android_library" { modType := ctx.ModuleType() if strings.HasPrefix(modType, "java_binary") || strings.HasPrefix(modType, "java_library") || modType == "android_app" || modType == "android_library" { for _, d := range m.properties.Libs { neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d) neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink" Loading Loading
bp2build/android_app_conversion_test.go +27 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ func runAndroidAppTestCase(t *testing.T, tc Bp2buildTestCase) { func registerAndroidAppModuleTypes(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.RegisterModuleType("java_library", java.LibraryFactory) } func TestMinimalAndroidApp(t *testing.T) { Loading Loading @@ -200,3 +201,29 @@ android_app { }), }}) } func TestAndroidAppLibs(t *testing.T) { runAndroidAppTestCase(t, Bp2buildTestCase{ Description: "Android app with libs", ModuleTypeUnderTest: "android_app", ModuleTypeUnderTestFactory: java.AndroidAppFactory, Filesystem: map[string]string{}, Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + ` android_app { name: "foo", libs: ["barLib"] } java_library{ name: "barLib", } `, ExpectedBazelTargets: []string{ MakeBazelTarget("java_library", "barLib", AttrNameToString{}), MakeNeverlinkDuplicateTarget("java_library", "barLib"), MakeBazelTarget("android_binary", "foo", AttrNameToString{ "manifest": `"AndroidManifest.xml"`, "resource_files": `[]`, "deps": `[":barLib-neverlink"]`, }), }}) }
java/java.go +3 −1 Original line number Diff line number Diff line Loading @@ -2677,7 +2677,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) if m.properties.Libs != nil { // TODO 244210934 ALIX Check if this else statement breaks presubmits get rid of it if it doesn't if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") || ctx.ModuleType() == "android_library" { modType := ctx.ModuleType() if strings.HasPrefix(modType, "java_binary") || strings.HasPrefix(modType, "java_library") || modType == "android_app" || modType == "android_library" { for _, d := range m.properties.Libs { neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d) neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink" Loading