bpfix: remove hidl_interface types

These were needed to create/track dependencies, but since we use src
jars now, they are no longer needed.

Test: bpfix_test
Change-Id: Ife7942f937cf94c66547af92821a4c11bd747e3f
This commit is contained in:
Steven Moreland 2020-01-21 18:49:33 -08:00
parent f3cae775e9
commit 3cc2dfaf90
2 changed files with 47 additions and 0 deletions

View File

@ -120,6 +120,10 @@ var fixSteps = []FixStep{
Name: "removeEmptyLibDependencies",
Fix: removeEmptyLibDependencies,
},
{
Name: "removeHidlInterfaceTypes",
Fix: removeHidlInterfaceTypes,
},
}
func NewFixRequest() FixRequest {
@ -698,6 +702,18 @@ func removeEmptyLibDependencies(f *Fixer) error {
return nil
}
// Removes hidl_interface 'types' which are no longer needed
func removeHidlInterfaceTypes(f *Fixer) error {
for _, def := range f.tree.Defs {
mod, ok := def.(*parser.Module)
if !(ok && mod.Type == "hidl_interface") {
continue
}
removeProperty(mod, "types")
}
return nil
}
// Converts the default source list property, 'srcs', to a single source property with a given name.
// "LOCAL_MODULE" reference is also resolved during the conversion process.
func convertToSingleSource(mod *parser.Module, srcPropertyName string) {

View File

@ -887,3 +887,34 @@ func TestRemoveEmptyLibDependencies(t *testing.T) {
})
}
}
func TestRemoveHidlInterfaceTypes(t *testing.T) {
tests := []struct {
name string
in string
out string
}{
{
name: "remove types",
in: `
hidl_interface {
name: "foo@1.0",
types: ["ParcelFooBar"],
}
`,
out: `
hidl_interface {
name: "foo@1.0",
}
`,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
runPass(t, test.in, test.out, func(fixer *Fixer) error {
return removeHidlInterfaceTypes(fixer)
})
})
}
}