Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f02c7d88 authored by Alix Espino's avatar Alix Espino Committed by Gerrit Code Review
Browse files

Merge "libs support for android_app->* edge"

parents ee37e8e8 6c087cf0
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -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) {
@@ -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"]`,
			}),
		}})
}
+3 −1
Original line number Diff line number Diff line
@@ -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"