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

Commit 25ebc502 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use shared variant of dep for packaging" into main

parents 36c0d1b3 405f2d44
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -377,7 +377,17 @@ func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.Dep
			if p.IgnoreMissingDependencies && !ctx.OtherModuleExists(dep) {
				continue
			}
			ctx.AddFarVariationDependencies(t.Variations(), depTag, dep)
			targetVariation := t.Variations()
			sharedVariation := blueprint.Variation{
				Mutator:   "link",
				Variation: "shared",
			}
			// If a shared variation exists, use that. Static variants do not provide any standalone files
			// for packaging.
			if ctx.OtherModuleFarDependencyVariantExists([]blueprint.Variation{sharedVariation}, dep) {
				targetVariation = append(targetVariation, sharedVariation)
			}
			ctx.AddFarVariationDependencies(targetVariation, depTag, dep)
		}
	}
}
+19 −0
Original line number Diff line number Diff line
@@ -610,3 +610,22 @@ func TestDoNotPackageCrossPartitionDependencies(t *testing.T) {
	fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
	android.AssertDeepEquals(t, "filesystem with dependencies on different partition", "bin/binfoo\n", fileList)
}

// If a cc_library is listed in `deps`, and it has a shared and static variant, then the shared variant
// should be installed.
func TestUseSharedVariationOfNativeLib(t *testing.T) {
	result := fixture.RunTestWithBp(t, `
		android_filesystem {
			name: "myfilesystem",
			deps: ["libfoo"],
		}
		// cc_library will create a static and shared variant.
		cc_library {
			name: "libfoo",
		}
	`)

	partition := result.ModuleForTests("myfilesystem", "android_common")
	fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
	android.AssertDeepEquals(t, "cc_library listed in deps", "lib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo.so\nlib64/libm.so\n", fileList)
}