Merge "deps in the packaging modules supports select" into main
This commit is contained in:
commit
bd6b1fcab4
2 changed files with 75 additions and 23 deletions
|
@ -20,6 +20,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PackagingSpec abstracts a request to place a built artifact at a certain path in a package. A
|
// PackagingSpec abstracts a request to place a built artifact at a certain path in a package. A
|
||||||
|
@ -150,7 +151,7 @@ type PackagingBase struct {
|
||||||
|
|
||||||
type depsProperty struct {
|
type depsProperty struct {
|
||||||
// Modules to include in this package
|
// Modules to include in this package
|
||||||
Deps []string `android:"arch_variant"`
|
Deps proptools.Configurable[[]string] `android:"arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type packagingMultilibProperties struct {
|
type packagingMultilibProperties struct {
|
||||||
|
@ -169,8 +170,8 @@ type packagingArchProperties struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PackagingProperties struct {
|
type PackagingProperties struct {
|
||||||
Deps []string `android:"arch_variant"`
|
Deps proptools.Configurable[[]string] `android:"arch_variant"`
|
||||||
Multilib packagingMultilibProperties `android:"arch_variant"`
|
Multilib packagingMultilibProperties `android:"arch_variant"`
|
||||||
Arch packagingArchProperties
|
Arch packagingArchProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,38 +189,42 @@ func (p *PackagingBase) packagingBase() *PackagingBase {
|
||||||
// multi target, deps is selected for each of the targets and is NOT selected for the current
|
// multi target, deps is selected for each of the targets and is NOT selected for the current
|
||||||
// architecture which would be Common.
|
// architecture which would be Common.
|
||||||
func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) []string {
|
func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) []string {
|
||||||
|
get := func(prop proptools.Configurable[[]string]) []string {
|
||||||
|
return prop.GetOrDefault(ctx, nil)
|
||||||
|
}
|
||||||
|
|
||||||
var ret []string
|
var ret []string
|
||||||
if arch == ctx.Target().Arch.ArchType && len(ctx.MultiTargets()) == 0 {
|
if arch == ctx.Target().Arch.ArchType && len(ctx.MultiTargets()) == 0 {
|
||||||
ret = append(ret, p.properties.Deps...)
|
ret = append(ret, get(p.properties.Deps)...)
|
||||||
} else if arch.Multilib == "lib32" {
|
} else if arch.Multilib == "lib32" {
|
||||||
ret = append(ret, p.properties.Multilib.Lib32.Deps...)
|
ret = append(ret, get(p.properties.Multilib.Lib32.Deps)...)
|
||||||
} else if arch.Multilib == "lib64" {
|
} else if arch.Multilib == "lib64" {
|
||||||
ret = append(ret, p.properties.Multilib.Lib64.Deps...)
|
ret = append(ret, get(p.properties.Multilib.Lib64.Deps)...)
|
||||||
} else if arch == Common {
|
} else if arch == Common {
|
||||||
ret = append(ret, p.properties.Multilib.Common.Deps...)
|
ret = append(ret, get(p.properties.Multilib.Common.Deps)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.DepsCollectFirstTargetOnly {
|
if p.DepsCollectFirstTargetOnly {
|
||||||
if len(p.properties.Multilib.First.Deps) > 0 {
|
if len(get(p.properties.Multilib.First.Deps)) > 0 {
|
||||||
ctx.PropertyErrorf("multilib.first.deps", "not supported. use \"deps\" instead")
|
ctx.PropertyErrorf("multilib.first.deps", "not supported. use \"deps\" instead")
|
||||||
}
|
}
|
||||||
for i, t := range ctx.MultiTargets() {
|
for i, t := range ctx.MultiTargets() {
|
||||||
if t.Arch.ArchType == arch {
|
if t.Arch.ArchType == arch {
|
||||||
ret = append(ret, p.properties.Multilib.Both.Deps...)
|
ret = append(ret, get(p.properties.Multilib.Both.Deps)...)
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
ret = append(ret, p.properties.Deps...)
|
ret = append(ret, get(p.properties.Deps)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(p.properties.Multilib.Both.Deps) > 0 {
|
if len(get(p.properties.Multilib.Both.Deps)) > 0 {
|
||||||
ctx.PropertyErrorf("multilib.both.deps", "not supported. use \"deps\" instead")
|
ctx.PropertyErrorf("multilib.both.deps", "not supported. use \"deps\" instead")
|
||||||
}
|
}
|
||||||
for i, t := range ctx.MultiTargets() {
|
for i, t := range ctx.MultiTargets() {
|
||||||
if t.Arch.ArchType == arch {
|
if t.Arch.ArchType == arch {
|
||||||
ret = append(ret, p.properties.Deps...)
|
ret = append(ret, get(p.properties.Deps)...)
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
ret = append(ret, p.properties.Multilib.First.Deps...)
|
ret = append(ret, get(p.properties.Multilib.First.Deps)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,13 +233,13 @@ func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) []s
|
||||||
if ctx.Arch().ArchType == Common {
|
if ctx.Arch().ArchType == Common {
|
||||||
switch arch {
|
switch arch {
|
||||||
case Arm64:
|
case Arm64:
|
||||||
ret = append(ret, p.properties.Arch.Arm64.Deps...)
|
ret = append(ret, get(p.properties.Arch.Arm64.Deps)...)
|
||||||
case Arm:
|
case Arm:
|
||||||
ret = append(ret, p.properties.Arch.Arm.Deps...)
|
ret = append(ret, get(p.properties.Arch.Arm.Deps)...)
|
||||||
case X86_64:
|
case X86_64:
|
||||||
ret = append(ret, p.properties.Arch.X86_64.Deps...)
|
ret = append(ret, get(p.properties.Arch.X86_64.Deps)...)
|
||||||
case X86:
|
case X86:
|
||||||
ret = append(ret, p.properties.Arch.X86.Deps...)
|
ret = append(ret, get(p.properties.Arch.X86.Deps)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,12 +95,13 @@ func (m *packageTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
m.entries = m.CopyDepsToZip(ctx, m.GatherPackagingSpecs(ctx), zipFile)
|
m.entries = m.CopyDepsToZip(ctx, m.GatherPackagingSpecs(ctx), zipFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
type packageTestModuleConfig struct {
|
type testConfig struct {
|
||||||
multiTarget bool
|
multiTarget bool
|
||||||
depsCollectFirstTargetOnly bool
|
depsCollectFirstTargetOnly bool
|
||||||
|
debuggable bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPackagingTest(t *testing.T, config packageTestModuleConfig, bp string, expected []string) {
|
func runPackagingTest(t *testing.T, config testConfig, bp string, expected []string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
var archVariant string
|
var archVariant string
|
||||||
|
@ -120,6 +121,9 @@ func runPackagingTest(t *testing.T, config packageTestModuleConfig, bp string, e
|
||||||
ctx.RegisterModuleType("component", componentTestModuleFactory)
|
ctx.RegisterModuleType("component", componentTestModuleFactory)
|
||||||
ctx.RegisterModuleType("package_module", moduleFactory)
|
ctx.RegisterModuleType("package_module", moduleFactory)
|
||||||
}),
|
}),
|
||||||
|
FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||||
|
variables.Debuggable = proptools.BoolPtr(config.debuggable)
|
||||||
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
).RunTest(t)
|
).RunTest(t)
|
||||||
|
|
||||||
|
@ -131,7 +135,7 @@ func runPackagingTest(t *testing.T, config packageTestModuleConfig, bp string, e
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPackagingBaseMultiTarget(t *testing.T) {
|
func TestPackagingBaseMultiTarget(t *testing.T) {
|
||||||
config := packageTestModuleConfig{
|
config := testConfig{
|
||||||
multiTarget: true,
|
multiTarget: true,
|
||||||
depsCollectFirstTargetOnly: false,
|
depsCollectFirstTargetOnly: false,
|
||||||
}
|
}
|
||||||
|
@ -258,7 +262,7 @@ func TestPackagingBaseMultiTarget(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPackagingBaseSingleTarget(t *testing.T) {
|
func TestPackagingBaseSingleTarget(t *testing.T) {
|
||||||
config := packageTestModuleConfig{
|
config := testConfig{
|
||||||
multiTarget: false,
|
multiTarget: false,
|
||||||
depsCollectFirstTargetOnly: false,
|
depsCollectFirstTargetOnly: false,
|
||||||
}
|
}
|
||||||
|
@ -383,7 +387,7 @@ 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.
|
||||||
config := packageTestModuleConfig{
|
config := testConfig{
|
||||||
multiTarget: false,
|
multiTarget: false,
|
||||||
depsCollectFirstTargetOnly: false,
|
depsCollectFirstTargetOnly: false,
|
||||||
}
|
}
|
||||||
|
@ -412,7 +416,7 @@ func TestPackagingWithSkipInstallDeps(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPackagingWithDepsCollectFirstTargetOnly(t *testing.T) {
|
func TestPackagingWithDepsCollectFirstTargetOnly(t *testing.T) {
|
||||||
config := packageTestModuleConfig{
|
config := testConfig{
|
||||||
multiTarget: true,
|
multiTarget: true,
|
||||||
depsCollectFirstTargetOnly: true,
|
depsCollectFirstTargetOnly: true,
|
||||||
}
|
}
|
||||||
|
@ -537,3 +541,46 @@ func TestPackagingWithDepsCollectFirstTargetOnly(t *testing.T) {
|
||||||
}
|
}
|
||||||
`, []string{"lib64/foo", "lib64/bar"})
|
`, []string{"lib64/foo", "lib64/bar"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDebuggableDeps(t *testing.T) {
|
||||||
|
bp := `
|
||||||
|
component {
|
||||||
|
name: "foo",
|
||||||
|
}
|
||||||
|
|
||||||
|
component {
|
||||||
|
name: "bar",
|
||||||
|
deps: ["baz"],
|
||||||
|
}
|
||||||
|
|
||||||
|
component {
|
||||||
|
name: "baz",
|
||||||
|
}
|
||||||
|
|
||||||
|
package_module {
|
||||||
|
name: "package",
|
||||||
|
deps: ["foo"] + select(product_variable("debuggable"), {
|
||||||
|
true: ["bar"],
|
||||||
|
default: [],
|
||||||
|
}),
|
||||||
|
}`
|
||||||
|
testcases := []struct {
|
||||||
|
debuggable bool
|
||||||
|
expected []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
debuggable: true,
|
||||||
|
expected: []string{"lib64/foo", "lib64/bar", "lib64/baz"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
debuggable: false,
|
||||||
|
expected: []string{"lib64/foo"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testcases {
|
||||||
|
config := testConfig{
|
||||||
|
debuggable: tc.debuggable,
|
||||||
|
}
|
||||||
|
runPackagingTest(t, config, bp, tc.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue