filesystem modules gathers first target only
With this change, the deps property in filesystem modules gather the
first target of the filesystem module only.
To gather dependencies across both targets, use multilib.both.deps
instead.
Bug: N/A
Test: go test ./...
Change-Id: Ie2ff0c48f08c61c8b219fc2c1540476ff8e4b1fc
diff --git a/android/packaging_test.go b/android/packaging_test.go
index 3833437..f99bb91 100644
--- a/android/packaging_test.go
+++ b/android/packaging_test.go
@@ -67,18 +67,15 @@
entries []string
}
-func packageMultiTargetTestModuleFactory() Module {
+func packageTestModuleFactory(multiTarget bool, depsCollectFirstTargetOnly bool) Module {
module := &packageTestModule{}
InitPackageModule(module)
- InitAndroidMultiTargetsArchModule(module, DeviceSupported, MultilibCommon)
- module.AddProperties(&module.properties)
- return module
-}
-
-func packageTestModuleFactory() Module {
- module := &packageTestModule{}
- InitPackageModule(module)
- InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
+ module.DepsCollectFirstTargetOnly = depsCollectFirstTargetOnly
+ if multiTarget {
+ InitAndroidMultiTargetsArchModule(module, DeviceSupported, MultilibCommon)
+ } else {
+ InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
+ }
module.AddProperties(&module.properties)
return module
}
@@ -98,17 +95,23 @@
m.entries = m.CopyDepsToZip(ctx, m.GatherPackagingSpecs(ctx), zipFile)
}
-func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []string) {
+type packageTestModuleConfig struct {
+ multiTarget bool
+ depsCollectFirstTargetOnly bool
+}
+
+func runPackagingTest(t *testing.T, config packageTestModuleConfig, bp string, expected []string) {
t.Helper()
var archVariant string
- var moduleFactory ModuleFactory
- if multitarget {
+ if config.multiTarget {
archVariant = "android_common"
- moduleFactory = packageMultiTargetTestModuleFactory
} else {
archVariant = "android_arm64_armv8-a"
- moduleFactory = packageTestModuleFactory
+ }
+
+ moduleFactory := func() Module {
+ return packageTestModuleFactory(config.multiTarget, config.depsCollectFirstTargetOnly)
}
result := GroupFixturePreparers(
@@ -128,8 +131,11 @@
}
func TestPackagingBaseMultiTarget(t *testing.T) {
- multiTarget := true
- runPackagingTest(t, multiTarget,
+ config := packageTestModuleConfig{
+ multiTarget: true,
+ depsCollectFirstTargetOnly: false,
+ }
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -141,7 +147,7 @@
}
`, []string{"lib64/foo"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -158,7 +164,7 @@
}
`, []string{"lib64/foo", "lib64/bar"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -176,7 +182,7 @@
}
`, []string{"lib32/foo", "lib32/bar", "lib64/foo", "lib64/bar"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -199,7 +205,7 @@
}
`, []string{"lib32/foo", "lib32/bar", "lib64/foo"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -221,7 +227,7 @@
}
`, []string{"lib32/foo", "lib64/foo", "lib64/bar"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -252,8 +258,11 @@
}
func TestPackagingBaseSingleTarget(t *testing.T) {
- multiTarget := false
- runPackagingTest(t, multiTarget,
+ config := packageTestModuleConfig{
+ multiTarget: false,
+ depsCollectFirstTargetOnly: false,
+ }
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -265,7 +274,7 @@
}
`, []string{"lib64/foo"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -282,7 +291,7 @@
}
`, []string{"lib64/foo", "lib64/bar"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -304,7 +313,7 @@
}
`, []string{"lib64/foo"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -325,7 +334,7 @@
}
`, []string{"lib64/foo", "lib64/bar"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -353,7 +362,7 @@
}
`, []string{"lib64/foo", "lib64/bar"})
- runPackagingTest(t, multiTarget,
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -374,8 +383,11 @@
func TestPackagingWithSkipInstallDeps(t *testing.T) {
// package -[dep]-> foo -[dep]-> bar -[dep]-> baz
// Packaging should continue transitively through modules that are not installed.
- multiTarget := false
- runPackagingTest(t, multiTarget,
+ config := packageTestModuleConfig{
+ multiTarget: false,
+ depsCollectFirstTargetOnly: false,
+ }
+ runPackagingTest(t, config,
`
component {
name: "foo",
@@ -398,3 +410,130 @@
}
`, []string{"lib64/foo", "lib64/bar", "lib64/baz"})
}
+
+func TestPackagingWithDepsCollectFirstTargetOnly(t *testing.T) {
+ config := packageTestModuleConfig{
+ multiTarget: true,
+ depsCollectFirstTargetOnly: true,
+ }
+ runPackagingTest(t, config,
+ `
+ component {
+ name: "foo",
+ }
+
+ package_module {
+ name: "package",
+ deps: ["foo"],
+ }
+ `, []string{"lib64/foo"})
+
+ runPackagingTest(t, config,
+ `
+ component {
+ name: "foo",
+ deps: ["bar"],
+ }
+
+ component {
+ name: "bar",
+ }
+
+ package_module {
+ name: "package",
+ deps: ["foo"],
+ }
+ `, []string{"lib64/foo", "lib64/bar"})
+
+ runPackagingTest(t, config,
+ `
+ component {
+ name: "foo",
+ deps: ["bar"],
+ }
+
+ component {
+ name: "bar",
+ }
+
+ package_module {
+ name: "package",
+ deps: ["foo"],
+ compile_multilib: "both",
+ }
+ `, []string{"lib64/foo", "lib64/bar"})
+
+ runPackagingTest(t, config,
+ `
+ component {
+ name: "foo",
+ }
+
+ component {
+ name: "bar",
+ compile_multilib: "32",
+ }
+
+ package_module {
+ name: "package",
+ deps: ["foo"],
+ multilib: {
+ lib32: {
+ deps: ["bar"],
+ },
+ },
+ compile_multilib: "both",
+ }
+ `, []string{"lib32/bar", "lib64/foo"})
+
+ runPackagingTest(t, config,
+ `
+ component {
+ name: "foo",
+ }
+
+ component {
+ name: "bar",
+ }
+
+ package_module {
+ name: "package",
+ deps: ["foo"],
+ multilib: {
+ both: {
+ deps: ["bar"],
+ },
+ },
+ compile_multilib: "both",
+ }
+ `, []string{"lib64/foo", "lib32/bar", "lib64/bar"})
+
+ runPackagingTest(t, config,
+ `
+ 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{"lib64/foo", "lib64/bar"})
+}