arch.<arch>.deps now works in android_filesystem
android_filesystem is a multi targets module type inhering from PackagingBase. Since it's a multi-targets module, it is mutated only for the common arch and therefore arch-specific properties are NOT squashed into the matching top level property (i.e. setArchProperties is no op). As a result, the values set in arch.<arch>.deps property were ignored. This fixes the issue by explicitly adding the properties in arch-specific structs and reading the properties in the matching arch. Also added a set of tests for non-multi-target modules. Bug: N/A Test: m Change-Id: Ibd4b509e73fa1760cc38b3661a08f83a6f639705
This commit is contained in:
@@ -87,9 +87,17 @@ type packagingMultilibProperties struct {
|
||||
Lib64 depsProperty `android:"arch_variant"`
|
||||
}
|
||||
|
||||
type packagingArchProperties struct {
|
||||
Arm64 depsProperty
|
||||
Arm depsProperty
|
||||
X86_64 depsProperty
|
||||
X86 depsProperty
|
||||
}
|
||||
|
||||
type PackagingProperties struct {
|
||||
Deps []string `android:"arch_variant"`
|
||||
Multilib packagingMultilibProperties `android:"arch_variant"`
|
||||
Arch packagingArchProperties
|
||||
}
|
||||
|
||||
func InitPackageModule(p PackageModule) {
|
||||
@@ -116,6 +124,7 @@ func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) []s
|
||||
} else if arch == Common {
|
||||
ret = append(ret, p.properties.Multilib.Common.Deps...)
|
||||
}
|
||||
|
||||
for i, t := range ctx.MultiTargets() {
|
||||
if t.Arch.ArchType == arch {
|
||||
ret = append(ret, p.properties.Deps...)
|
||||
@@ -124,6 +133,20 @@ func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) []s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.Arch().ArchType == Common {
|
||||
switch arch {
|
||||
case Arm64:
|
||||
ret = append(ret, p.properties.Arch.Arm64.Deps...)
|
||||
case Arm:
|
||||
ret = append(ret, p.properties.Arch.Arm.Deps...)
|
||||
case X86_64:
|
||||
ret = append(ret, p.properties.Arch.X86_64.Deps...)
|
||||
case X86:
|
||||
ret = append(ret, p.properties.Arch.X86.Deps...)
|
||||
}
|
||||
}
|
||||
|
||||
return FirstUniqueStrings(ret)
|
||||
}
|
||||
|
||||
|
@@ -61,13 +61,20 @@ type packageTestModule struct {
|
||||
entries []string
|
||||
}
|
||||
|
||||
func packageTestModuleFactory() Module {
|
||||
func packageMultiTargetTestModuleFactory() Module {
|
||||
module := &packageTestModule{}
|
||||
InitPackageModule(module)
|
||||
InitAndroidMultiTargetsArchModule(module, DeviceSupported, MultilibCommon)
|
||||
return module
|
||||
}
|
||||
|
||||
func packageTestModuleFactory() Module {
|
||||
module := &packageTestModule{}
|
||||
InitPackageModule(module)
|
||||
InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
|
||||
return module
|
||||
}
|
||||
|
||||
func (m *packageTestModule) DepsMutator(ctx BottomUpMutatorContext) {
|
||||
m.AddDeps(ctx, installDepTag{})
|
||||
}
|
||||
@@ -77,14 +84,22 @@ func (m *packageTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
m.entries = m.CopyDepsToZip(ctx, zipFile)
|
||||
}
|
||||
|
||||
func runPackagingTest(t *testing.T, bp string, expected []string) {
|
||||
func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []string) {
|
||||
t.Helper()
|
||||
|
||||
config := TestArchConfig(buildDir, nil, bp, nil)
|
||||
|
||||
ctx := NewTestArchContext(config)
|
||||
ctx.RegisterModuleType("component", componentTestModuleFactory)
|
||||
ctx.RegisterModuleType("package_module", packageTestModuleFactory)
|
||||
|
||||
var archVariant string
|
||||
if multitarget {
|
||||
archVariant = "android_common"
|
||||
ctx.RegisterModuleType("package_module", packageMultiTargetTestModuleFactory)
|
||||
} else {
|
||||
archVariant = "android_arm64_armv8-a"
|
||||
ctx.RegisterModuleType("package_module", packageTestModuleFactory)
|
||||
}
|
||||
ctx.Register()
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
@@ -92,7 +107,7 @@ func runPackagingTest(t *testing.T, bp string, expected []string) {
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
FailIfErrored(t, errs)
|
||||
|
||||
p := ctx.ModuleForTests("package", "android_common").Module().(*packageTestModule)
|
||||
p := ctx.ModuleForTests("package", archVariant).Module().(*packageTestModule)
|
||||
actual := p.entries
|
||||
actual = SortedUniqueStrings(actual)
|
||||
expected = SortedUniqueStrings(expected)
|
||||
@@ -101,8 +116,9 @@ func runPackagingTest(t *testing.T, bp string, expected []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackagingBase(t *testing.T) {
|
||||
runPackagingTest(t,
|
||||
func TestPackagingBaseMultiTarget(t *testing.T) {
|
||||
multiTarget := true
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
@@ -114,7 +130,7 @@ func TestPackagingBase(t *testing.T) {
|
||||
}
|
||||
`, []string{"lib64/foo"})
|
||||
|
||||
runPackagingTest(t,
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
@@ -131,7 +147,7 @@ func TestPackagingBase(t *testing.T) {
|
||||
}
|
||||
`, []string{"lib64/foo", "lib64/bar"})
|
||||
|
||||
runPackagingTest(t,
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
@@ -149,7 +165,7 @@ func TestPackagingBase(t *testing.T) {
|
||||
}
|
||||
`, []string{"lib32/foo", "lib32/bar", "lib64/foo", "lib64/bar"})
|
||||
|
||||
runPackagingTest(t,
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
@@ -172,7 +188,7 @@ func TestPackagingBase(t *testing.T) {
|
||||
}
|
||||
`, []string{"lib32/foo", "lib32/bar", "lib64/foo"})
|
||||
|
||||
runPackagingTest(t,
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
@@ -193,4 +209,136 @@ func TestPackagingBase(t *testing.T) {
|
||||
compile_multilib: "both",
|
||||
}
|
||||
`, []string{"lib32/foo", "lib64/foo", "lib64/bar"})
|
||||
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
}
|
||||
|
||||
component {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
component {
|
||||
name: "baz",
|
||||
}
|
||||
|
||||
package_module {
|
||||
name: "package",
|
||||
deps: ["foo"],
|
||||
arch: {
|
||||
arm64: {
|
||||
deps: ["bar"],
|
||||
},
|
||||
x86_64: {
|
||||
deps: ["baz"],
|
||||
},
|
||||
},
|
||||
compile_multilib: "both",
|
||||
}
|
||||
`, []string{"lib32/foo", "lib64/foo", "lib64/bar"})
|
||||
}
|
||||
|
||||
func TestPackagingBaseSingleTarget(t *testing.T) {
|
||||
multiTarget := false
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
}
|
||||
|
||||
package_module {
|
||||
name: "package",
|
||||
deps: ["foo"],
|
||||
}
|
||||
`, []string{"lib64/foo"})
|
||||
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
deps: ["bar"],
|
||||
}
|
||||
|
||||
component {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
package_module {
|
||||
name: "package",
|
||||
deps: ["foo"],
|
||||
}
|
||||
`, []string{"lib64/foo", "lib64/bar"})
|
||||
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
}
|
||||
|
||||
component {
|
||||
name: "bar",
|
||||
compile_multilib: "32",
|
||||
}
|
||||
|
||||
package_module {
|
||||
name: "package",
|
||||
deps: ["foo"],
|
||||
multilib: {
|
||||
lib32: {
|
||||
deps: ["bar"],
|
||||
},
|
||||
},
|
||||
}
|
||||
`, []string{"lib64/foo"})
|
||||
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
}
|
||||
|
||||
component {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
package_module {
|
||||
name: "package",
|
||||
deps: ["foo"],
|
||||
multilib: {
|
||||
lib64: {
|
||||
deps: ["bar"],
|
||||
},
|
||||
},
|
||||
}
|
||||
`, []string{"lib64/foo", "lib64/bar"})
|
||||
|
||||
runPackagingTest(t, multiTarget,
|
||||
`
|
||||
component {
|
||||
name: "foo",
|
||||
}
|
||||
|
||||
component {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
component {
|
||||
name: "baz",
|
||||
}
|
||||
|
||||
package_module {
|
||||
name: "package",
|
||||
deps: ["foo"],
|
||||
arch: {
|
||||
arm64: {
|
||||
deps: ["bar"],
|
||||
},
|
||||
x86_64: {
|
||||
deps: ["baz"],
|
||||
},
|
||||
},
|
||||
}
|
||||
`, []string{"lib64/foo", "lib64/bar"})
|
||||
}
|
||||
|
Reference in New Issue
Block a user