Merge "filesystem modules gathers first target only" into main
This commit is contained in:
@@ -142,6 +142,10 @@ type PackagingBase struct {
|
|||||||
// for rare cases like when there's a dependency to a module which exists in certain repo
|
// for rare cases like when there's a dependency to a module which exists in certain repo
|
||||||
// checkouts, this is needed.
|
// checkouts, this is needed.
|
||||||
IgnoreMissingDependencies bool
|
IgnoreMissingDependencies bool
|
||||||
|
|
||||||
|
// If this is set to true by a module type inheriting PackagingBase, the deps property
|
||||||
|
// collects the first target only even with compile_multilib: true.
|
||||||
|
DepsCollectFirstTargetOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type depsProperty struct {
|
type depsProperty struct {
|
||||||
@@ -154,6 +158,7 @@ type packagingMultilibProperties struct {
|
|||||||
Common depsProperty `android:"arch_variant"`
|
Common depsProperty `android:"arch_variant"`
|
||||||
Lib32 depsProperty `android:"arch_variant"`
|
Lib32 depsProperty `android:"arch_variant"`
|
||||||
Lib64 depsProperty `android:"arch_variant"`
|
Lib64 depsProperty `android:"arch_variant"`
|
||||||
|
Both depsProperty `android:"arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type packagingArchProperties struct {
|
type packagingArchProperties struct {
|
||||||
@@ -194,11 +199,28 @@ func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) []s
|
|||||||
ret = append(ret, p.properties.Multilib.Common.Deps...)
|
ret = append(ret, p.properties.Multilib.Common.Deps...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, t := range ctx.MultiTargets() {
|
if p.DepsCollectFirstTargetOnly {
|
||||||
if t.Arch.ArchType == arch {
|
if len(p.properties.Multilib.First.Deps) > 0 {
|
||||||
ret = append(ret, p.properties.Deps...)
|
ctx.PropertyErrorf("multilib.first.deps", "not supported. use \"deps\" instead")
|
||||||
if i == 0 {
|
}
|
||||||
ret = append(ret, p.properties.Multilib.First.Deps...)
|
for i, t := range ctx.MultiTargets() {
|
||||||
|
if t.Arch.ArchType == arch {
|
||||||
|
ret = append(ret, p.properties.Multilib.Both.Deps...)
|
||||||
|
if i == 0 {
|
||||||
|
ret = append(ret, p.properties.Deps...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if len(p.properties.Multilib.Both.Deps) > 0 {
|
||||||
|
ctx.PropertyErrorf("multilib.both.deps", "not supported. use \"deps\" instead")
|
||||||
|
}
|
||||||
|
for i, t := range ctx.MultiTargets() {
|
||||||
|
if t.Arch.ArchType == arch {
|
||||||
|
ret = append(ret, p.properties.Deps...)
|
||||||
|
if i == 0 {
|
||||||
|
ret = append(ret, p.properties.Multilib.First.Deps...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -67,18 +67,15 @@ type packageTestModule struct {
|
|||||||
entries []string
|
entries []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func packageMultiTargetTestModuleFactory() Module {
|
func packageTestModuleFactory(multiTarget bool, depsCollectFirstTargetOnly bool) Module {
|
||||||
module := &packageTestModule{}
|
module := &packageTestModule{}
|
||||||
InitPackageModule(module)
|
InitPackageModule(module)
|
||||||
InitAndroidMultiTargetsArchModule(module, DeviceSupported, MultilibCommon)
|
module.DepsCollectFirstTargetOnly = depsCollectFirstTargetOnly
|
||||||
module.AddProperties(&module.properties)
|
if multiTarget {
|
||||||
return module
|
InitAndroidMultiTargetsArchModule(module, DeviceSupported, MultilibCommon)
|
||||||
}
|
} else {
|
||||||
|
InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
|
||||||
func packageTestModuleFactory() Module {
|
}
|
||||||
module := &packageTestModule{}
|
|
||||||
InitPackageModule(module)
|
|
||||||
InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
|
|
||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
@@ -98,17 +95,23 @@ func (m *packageTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|||||||
m.entries = m.CopyDepsToZip(ctx, m.GatherPackagingSpecs(ctx), zipFile)
|
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()
|
t.Helper()
|
||||||
|
|
||||||
var archVariant string
|
var archVariant string
|
||||||
var moduleFactory ModuleFactory
|
if config.multiTarget {
|
||||||
if multitarget {
|
|
||||||
archVariant = "android_common"
|
archVariant = "android_common"
|
||||||
moduleFactory = packageMultiTargetTestModuleFactory
|
|
||||||
} else {
|
} else {
|
||||||
archVariant = "android_arm64_armv8-a"
|
archVariant = "android_arm64_armv8-a"
|
||||||
moduleFactory = packageTestModuleFactory
|
}
|
||||||
|
|
||||||
|
moduleFactory := func() Module {
|
||||||
|
return packageTestModuleFactory(config.multiTarget, config.depsCollectFirstTargetOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := GroupFixturePreparers(
|
result := GroupFixturePreparers(
|
||||||
@@ -128,8 +131,11 @@ func runPackagingTest(t *testing.T, multitarget bool, bp string, expected []stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPackagingBaseMultiTarget(t *testing.T) {
|
func TestPackagingBaseMultiTarget(t *testing.T) {
|
||||||
multiTarget := true
|
config := packageTestModuleConfig{
|
||||||
runPackagingTest(t, multiTarget,
|
multiTarget: true,
|
||||||
|
depsCollectFirstTargetOnly: false,
|
||||||
|
}
|
||||||
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -141,7 +147,7 @@ func TestPackagingBaseMultiTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo"})
|
`, []string{"lib64/foo"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -158,7 +164,7 @@ func TestPackagingBaseMultiTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo", "lib64/bar"})
|
`, []string{"lib64/foo", "lib64/bar"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -176,7 +182,7 @@ func TestPackagingBaseMultiTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib32/foo", "lib32/bar", "lib64/foo", "lib64/bar"})
|
`, []string{"lib32/foo", "lib32/bar", "lib64/foo", "lib64/bar"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -199,7 +205,7 @@ func TestPackagingBaseMultiTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib32/foo", "lib32/bar", "lib64/foo"})
|
`, []string{"lib32/foo", "lib32/bar", "lib64/foo"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -221,7 +227,7 @@ func TestPackagingBaseMultiTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib32/foo", "lib64/foo", "lib64/bar"})
|
`, []string{"lib32/foo", "lib64/foo", "lib64/bar"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -252,8 +258,11 @@ func TestPackagingBaseMultiTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPackagingBaseSingleTarget(t *testing.T) {
|
func TestPackagingBaseSingleTarget(t *testing.T) {
|
||||||
multiTarget := false
|
config := packageTestModuleConfig{
|
||||||
runPackagingTest(t, multiTarget,
|
multiTarget: false,
|
||||||
|
depsCollectFirstTargetOnly: false,
|
||||||
|
}
|
||||||
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -265,7 +274,7 @@ func TestPackagingBaseSingleTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo"})
|
`, []string{"lib64/foo"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -282,7 +291,7 @@ func TestPackagingBaseSingleTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo", "lib64/bar"})
|
`, []string{"lib64/foo", "lib64/bar"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -304,7 +313,7 @@ func TestPackagingBaseSingleTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo"})
|
`, []string{"lib64/foo"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -325,7 +334,7 @@ func TestPackagingBaseSingleTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo", "lib64/bar"})
|
`, []string{"lib64/foo", "lib64/bar"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -353,7 +362,7 @@ func TestPackagingBaseSingleTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo", "lib64/bar"})
|
`, []string{"lib64/foo", "lib64/bar"})
|
||||||
|
|
||||||
runPackagingTest(t, multiTarget,
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -374,8 +383,11 @@ func TestPackagingBaseSingleTarget(t *testing.T) {
|
|||||||
func TestPackagingWithSkipInstallDeps(t *testing.T) {
|
func TestPackagingWithSkipInstallDeps(t *testing.T) {
|
||||||
// package -[dep]-> foo -[dep]-> bar -[dep]-> baz
|
// package -[dep]-> foo -[dep]-> bar -[dep]-> baz
|
||||||
// Packaging should continue transitively through modules that are not installed.
|
// Packaging should continue transitively through modules that are not installed.
|
||||||
multiTarget := false
|
config := packageTestModuleConfig{
|
||||||
runPackagingTest(t, multiTarget,
|
multiTarget: false,
|
||||||
|
depsCollectFirstTargetOnly: false,
|
||||||
|
}
|
||||||
|
runPackagingTest(t, config,
|
||||||
`
|
`
|
||||||
component {
|
component {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
@@ -398,3 +410,130 @@ func TestPackagingWithSkipInstallDeps(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`, []string{"lib64/foo", "lib64/bar", "lib64/baz"})
|
`, []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"})
|
||||||
|
}
|
||||||
|
@@ -152,6 +152,7 @@ func filesystemFactory() android.Module {
|
|||||||
func initFilesystemModule(module *filesystem) {
|
func initFilesystemModule(module *filesystem) {
|
||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
android.InitPackageModule(module)
|
android.InitPackageModule(module)
|
||||||
|
module.PackagingBase.DepsCollectFirstTargetOnly = true
|
||||||
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||||
android.InitDefaultableModule(module)
|
android.InitDefaultableModule(module)
|
||||||
}
|
}
|
||||||
|
@@ -508,11 +508,7 @@ func TestFilterOutUnsupportedArches(t *testing.T) {
|
|||||||
android_filesystem {
|
android_filesystem {
|
||||||
name: "fs_64_32",
|
name: "fs_64_32",
|
||||||
compile_multilib: "both",
|
compile_multilib: "both",
|
||||||
multilib: {
|
deps: ["foo"],
|
||||||
first: {
|
|
||||||
deps: ["foo"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_binary {
|
cc_binary {
|
||||||
|
Reference in New Issue
Block a user