Do a better job removing tags from arch structs

Remove more android struct tags from runtime created arch structs
to reduce the size of their names, which hit the 64kB limit in
runtime.StructOf if they are too long.

Bug: 146234651
Test: m checkbuild
Change-Id: I6362765275b93c8932eb0b1abbcb4be47031d9b1
This commit is contained in:
Colin Cross
2020-01-21 11:38:47 -08:00
parent cbbd13f9bc
commit b4fecbfef4
2 changed files with 31 additions and 4 deletions

View File

@@ -1036,11 +1036,20 @@ func filterArchStruct(field reflect.StructField, prefix string) (bool, reflect.S
// 16-bit limit on structure name length. The name is constructed
// based on the Go source representation of the structure, so
// the tag names count towards that length.
//
// TODO: handle the uncommon case of other tags being involved
if field.Tag == `android:"arch_variant"` {
field.Tag = ""
androidTag := field.Tag.Get("android")
values := strings.Split(androidTag, ",")
if string(field.Tag) != `android:"`+strings.Join(values, ",")+`"` {
panic(fmt.Errorf("unexpected tag format %q", field.Tag))
}
// these tags don't need to be present in the runtime generated struct type.
values = RemoveListFromList(values, []string{"arch_variant", "variant_prepend", "path"})
if len(values) > 0 {
panic(fmt.Errorf("unknown tags %q in field %q", values, prefix+field.Name))
}
field.Tag = ""
return true, field
}
return false, field