Dedup path properties across property structs
Listing a property in multiple property structs would cause it to add multiple dependencies with the same dependency tag, which would trip the panic in getDirectDepInternal when calling PathForModuleSrc. Dedup the properties with the android:"path" struct tag across all property structs. Test: path_properties_test.go Change-Id: Ib6c0e7789443d340ee7551721df0135c5ee64c0f
This commit is contained in:
parent
ae11318633
commit
527f3e5511
|
@ -35,16 +35,17 @@ func pathDepsMutator(ctx BottomUpMutatorContext) {
|
||||||
|
|
||||||
props := m.base().generalProperties
|
props := m.base().generalProperties
|
||||||
|
|
||||||
|
var pathProperties []string
|
||||||
for _, ps := range props {
|
for _, ps := range props {
|
||||||
pathProperties := pathPropertiesForPropertyStruct(ctx, ps)
|
pathProperties = append(pathProperties, pathPropertiesForPropertyStruct(ctx, ps)...)
|
||||||
pathProperties = FirstUniqueStrings(pathProperties)
|
}
|
||||||
|
|
||||||
for _, s := range pathProperties {
|
pathProperties = FirstUniqueStrings(pathProperties)
|
||||||
if m, t := SrcIsModuleWithTag(s); m != "" {
|
|
||||||
ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(t), m)
|
for _, s := range pathProperties {
|
||||||
}
|
if m, t := SrcIsModuleWithTag(s); m != "" {
|
||||||
|
ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(t), m)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,17 @@ type pathDepsMutatorTestModule struct {
|
||||||
Qux string
|
Qux string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A second property struct with a duplicate property name
|
||||||
|
props2 struct {
|
||||||
|
Foo string `android:"path"`
|
||||||
|
}
|
||||||
|
|
||||||
sourceDeps []string
|
sourceDeps []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func pathDepsMutatorTestModuleFactory() Module {
|
func pathDepsMutatorTestModuleFactory() Module {
|
||||||
module := &pathDepsMutatorTestModule{}
|
module := &pathDepsMutatorTestModule{}
|
||||||
module.AddProperties(&module.props)
|
module.AddProperties(&module.props, &module.props2)
|
||||||
InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
|
InitAndroidArchModule(module, DeviceSupported, MultilibBoth)
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
@ -44,6 +49,13 @@ func (p *pathDepsMutatorTestModule) GenerateAndroidBuildActions(ctx ModuleContex
|
||||||
p.sourceDeps = append(p.sourceDeps, ctx.OtherModuleName(dep))
|
p.sourceDeps = append(p.sourceDeps, ctx.OtherModuleName(dep))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if p.props.Foo != "" {
|
||||||
|
// Make sure there is only one dependency on a module listed in a property present in multiple property structs
|
||||||
|
if ctx.GetDirectDepWithTag(SrcIsModule(p.props.Foo), sourceOrOutputDepTag("")) == nil {
|
||||||
|
ctx.ModuleErrorf("GetDirectDepWithTag failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPathDepsMutator(t *testing.T) {
|
func TestPathDepsMutator(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue