Loading android/packaging.go +11 −1 Original line number Diff line number Diff line Loading @@ -395,6 +395,11 @@ func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.Dep func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter func(PackagingSpec) bool) map[string]PackagingSpec { // all packaging specs gathered from the dep. var all []PackagingSpec // Name of the dependency which requested the packaging spec. // If this dep is overridden, the packaging spec will not be installed via this dependency chain. // (the packaging spec might still be installed if there are some other deps which depend on it). var depNames []string // list of module names overridden var overridden []string Loading Loading @@ -429,6 +434,7 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter } } all = append(all, ps) depNames = append(depNames, child.Name()) if ps.overrides != nil { overridden = append(overridden, *ps.overrides...) } Loading @@ -437,10 +443,14 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter // all minus packaging specs that are overridden var filtered []PackagingSpec for _, ps := range all { for index, ps := range all { if ps.owner != "" && InList(ps.owner, overridden) { continue } // The dependency which requested this packaging spec has been overridden. if InList(depNames[index], overridden) { continue } filtered = append(filtered, ps) } Loading filesystem/filesystem_test.go +35 −0 Original line number Diff line number Diff line Loading @@ -629,3 +629,38 @@ func TestUseSharedVariationOfNativeLib(t *testing.T) { 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) } // binfoo1 overrides binbar. transitive deps of binbar should not be installed. func TestDoNotInstallTransitiveDepOfOverriddenModule(t *testing.T) { result := fixture.RunTestWithBp(t, ` android_filesystem { name: "myfilesystem", deps: ["binfoo1", "libfoo2", "binbar"], } cc_binary { name: "binfoo1", shared_libs: ["libfoo"], overrides: ["binbar"], } cc_library { name: "libfoo", } cc_library { name: "libfoo2", overrides: ["libfoo"], } // binbar gets overridden by binfoo1 // therefore, libbar should not be installed cc_binary { name: "binbar", shared_libs: ["libbar"] } cc_library { name: "libbar", } `) partition := result.ModuleForTests("myfilesystem", "android_common") fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) android.AssertDeepEquals(t, "Shared library dep of overridden binary should not be installed", fileList, "bin/binfoo1\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo2.so\nlib64/libm.so\n") } Loading
android/packaging.go +11 −1 Original line number Diff line number Diff line Loading @@ -395,6 +395,11 @@ func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.Dep func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter func(PackagingSpec) bool) map[string]PackagingSpec { // all packaging specs gathered from the dep. var all []PackagingSpec // Name of the dependency which requested the packaging spec. // If this dep is overridden, the packaging spec will not be installed via this dependency chain. // (the packaging spec might still be installed if there are some other deps which depend on it). var depNames []string // list of module names overridden var overridden []string Loading Loading @@ -429,6 +434,7 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter } } all = append(all, ps) depNames = append(depNames, child.Name()) if ps.overrides != nil { overridden = append(overridden, *ps.overrides...) } Loading @@ -437,10 +443,14 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter // all minus packaging specs that are overridden var filtered []PackagingSpec for _, ps := range all { for index, ps := range all { if ps.owner != "" && InList(ps.owner, overridden) { continue } // The dependency which requested this packaging spec has been overridden. if InList(depNames[index], overridden) { continue } filtered = append(filtered, ps) } Loading
filesystem/filesystem_test.go +35 −0 Original line number Diff line number Diff line Loading @@ -629,3 +629,38 @@ func TestUseSharedVariationOfNativeLib(t *testing.T) { 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) } // binfoo1 overrides binbar. transitive deps of binbar should not be installed. func TestDoNotInstallTransitiveDepOfOverriddenModule(t *testing.T) { result := fixture.RunTestWithBp(t, ` android_filesystem { name: "myfilesystem", deps: ["binfoo1", "libfoo2", "binbar"], } cc_binary { name: "binfoo1", shared_libs: ["libfoo"], overrides: ["binbar"], } cc_library { name: "libfoo", } cc_library { name: "libfoo2", overrides: ["libfoo"], } // binbar gets overridden by binfoo1 // therefore, libbar should not be installed cc_binary { name: "binbar", shared_libs: ["libbar"] } cc_library { name: "libbar", } `) partition := result.ModuleForTests("myfilesystem", "android_common") fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) android.AssertDeepEquals(t, "Shared library dep of overridden binary should not be installed", fileList, "bin/binfoo1\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo2.so\nlib64/libm.so\n") }