Merge "Filter-out deps of unsupported arch" into main am: c6541077de
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3084949 Change-Id: I3cec354d4d0db7075820c5594ef40ede2e5c3402 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -497,6 +497,7 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
|
|||||||
partition: fullInstallPath.partition,
|
partition: fullInstallPath.partition,
|
||||||
skipInstall: m.skipInstall(),
|
skipInstall: m.skipInstall(),
|
||||||
aconfigPaths: m.getAconfigPaths(),
|
aconfigPaths: m.getAconfigPaths(),
|
||||||
|
archType: m.target.Arch.ArchType,
|
||||||
}
|
}
|
||||||
m.packagingSpecs = append(m.packagingSpecs, spec)
|
m.packagingSpecs = append(m.packagingSpecs, spec)
|
||||||
return spec
|
return spec
|
||||||
@@ -622,6 +623,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
|
|||||||
partition: fullInstallPath.partition,
|
partition: fullInstallPath.partition,
|
||||||
skipInstall: m.skipInstall(),
|
skipInstall: m.skipInstall(),
|
||||||
aconfigPaths: m.getAconfigPaths(),
|
aconfigPaths: m.getAconfigPaths(),
|
||||||
|
archType: m.target.Arch.ArchType,
|
||||||
})
|
})
|
||||||
|
|
||||||
return fullInstallPath
|
return fullInstallPath
|
||||||
@@ -665,6 +667,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str
|
|||||||
partition: fullInstallPath.partition,
|
partition: fullInstallPath.partition,
|
||||||
skipInstall: m.skipInstall(),
|
skipInstall: m.skipInstall(),
|
||||||
aconfigPaths: m.getAconfigPaths(),
|
aconfigPaths: m.getAconfigPaths(),
|
||||||
|
archType: m.target.Arch.ArchType,
|
||||||
})
|
})
|
||||||
|
|
||||||
return fullInstallPath
|
return fullInstallPath
|
||||||
|
@@ -51,6 +51,9 @@ type PackagingSpec struct {
|
|||||||
|
|
||||||
// Paths of aconfig files for the built artifact
|
// Paths of aconfig files for the built artifact
|
||||||
aconfigPaths *Paths
|
aconfigPaths *Paths
|
||||||
|
|
||||||
|
// ArchType of the module which produced this packaging spec
|
||||||
|
archType ArchType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PackagingSpec) Equals(other *PackagingSpec) bool {
|
func (p *PackagingSpec) Equals(other *PackagingSpec) bool {
|
||||||
@@ -260,11 +263,31 @@ func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.Dep
|
|||||||
|
|
||||||
func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter func(PackagingSpec) bool) map[string]PackagingSpec {
|
func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter func(PackagingSpec) bool) map[string]PackagingSpec {
|
||||||
m := make(map[string]PackagingSpec)
|
m := make(map[string]PackagingSpec)
|
||||||
|
|
||||||
|
var arches []ArchType
|
||||||
|
for _, target := range p.getSupportedTargets(ctx) {
|
||||||
|
arches = append(arches, target.Arch.ArchType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out packaging specs for unsupported architecture
|
||||||
|
filterArch := func(ps PackagingSpec) bool {
|
||||||
|
for _, arch := range arches {
|
||||||
|
if arch == ps.archType {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
ctx.VisitDirectDeps(func(child Module) {
|
ctx.VisitDirectDeps(func(child Module) {
|
||||||
if pi, ok := ctx.OtherModuleDependencyTag(child).(PackagingItem); !ok || !pi.IsPackagingItem() {
|
if pi, ok := ctx.OtherModuleDependencyTag(child).(PackagingItem); !ok || !pi.IsPackagingItem() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, ps := range child.TransitivePackagingSpecs() {
|
for _, ps := range child.TransitivePackagingSpecs() {
|
||||||
|
if !filterArch(ps) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
if !filter(ps) {
|
if !filter(ps) {
|
||||||
continue
|
continue
|
||||||
|
@@ -497,3 +497,70 @@ func TestTrackPhonyAsRequiredDep(t *testing.T) {
|
|||||||
android.AssertStringListContains(t, "missing entry", fs.entries, e)
|
android.AssertStringListContains(t, "missing entry", fs.entries, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFilterOutUnsupportedArches(t *testing.T) {
|
||||||
|
result := fixture.RunTestWithBp(t, `
|
||||||
|
android_filesystem {
|
||||||
|
name: "fs_64_only",
|
||||||
|
deps: ["foo"],
|
||||||
|
}
|
||||||
|
|
||||||
|
android_filesystem {
|
||||||
|
name: "fs_64_32",
|
||||||
|
compile_multilib: "both",
|
||||||
|
multilib: {
|
||||||
|
first: {
|
||||||
|
deps: ["foo"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_binary {
|
||||||
|
name: "foo",
|
||||||
|
required: ["phony"],
|
||||||
|
}
|
||||||
|
|
||||||
|
phony {
|
||||||
|
name: "phony",
|
||||||
|
required: [
|
||||||
|
"libbar",
|
||||||
|
"app",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libbar",
|
||||||
|
}
|
||||||
|
|
||||||
|
android_app {
|
||||||
|
name: "app",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
platform_apis: true,
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
testcases := []struct {
|
||||||
|
fsName string
|
||||||
|
expected []string
|
||||||
|
unexpected []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
fsName: "fs_64_only",
|
||||||
|
expected: []string{"app/app/app.apk", "bin/foo", "lib64/libbar.so"},
|
||||||
|
unexpected: []string{"lib/libbar.so"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fsName: "fs_64_32",
|
||||||
|
expected: []string{"app/app/app.apk", "bin/foo", "lib64/libbar.so", "lib/libbar.so"},
|
||||||
|
unexpected: []string{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, c := range testcases {
|
||||||
|
fs := result.ModuleForTests(c.fsName, "android_common").Module().(*filesystem)
|
||||||
|
for _, e := range c.expected {
|
||||||
|
android.AssertStringListContains(t, "missing entry", fs.entries, e)
|
||||||
|
}
|
||||||
|
for _, e := range c.unexpected {
|
||||||
|
android.AssertStringListDoesNotContain(t, "unexpected entry", fs.entries, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user