Rename sdk field tag "keep" to "ignore"

"ignore" is a better description of the effect that this tag has on the
optimization that is done as part of the sdk snapshot generation.
"keep" implies that something special is done with the field during the
optimization process but actually the optimization process completely
ignores the property, just as it does with unexported fields.

Bug: 248258460
Test: m nothing
Change-Id: Idfdfd87f927d641d4d301cbbde72b463c89155bf
This commit is contained in:
Paul Duffin
2022-09-22 15:30:58 +01:00
parent 394a12b315
commit 02e25c85eb
3 changed files with 64 additions and 64 deletions

View File

@@ -735,8 +735,8 @@ type SdkMemberType interface {
// have common values. Those fields are cleared and the common value added to the common
// properties.
//
// A field annotated with a tag of `sdk:"keep"` will be treated as if it
// was not capitalized, i.e. not optimized for common values.
// A field annotated with a tag of `sdk:"ignore"` will be treated as if it
// was not capitalized, i.e. ignored and not optimized for common values.
//
// A field annotated with a tag of `android:"arch_variant"` will be allowed to have
// values that differ by arch, fields not tagged as such must have common values across
@@ -923,18 +923,18 @@ type SdkMemberPropertiesBase struct {
// the locations of any of their prebuilt files in the snapshot by os type to prevent them
// from colliding. See OsPrefix().
//
// This property is the same for all variants of a member and so would be optimized away
// if it was not explicitly kept.
Os_count int `sdk:"keep"`
// Ignore this property during optimization. This is needed because this property is the same for
// all variants of a member and so would be optimized away if it was not ignored.
Os_count int `sdk:"ignore"`
// The os type for which these properties refer.
//
// Provided to allow a member to differentiate between os types in the locations of their
// prebuilt files when it supports more than one os type.
//
// This property is the same for all os type specific variants of a member and so would be
// optimized away if it was not explicitly kept.
Os OsType `sdk:"keep"`
// Ignore this property during optimization. This is needed because this property is the same for
// all variants of a member and so would be optimized away if it was not ignored.
Os OsType `sdk:"ignore"`
// The setting to use for the compile_multilib property.
Compile_multilib string `android:"arch_variant"`

View File

@@ -218,15 +218,15 @@ type EmbeddedPropertiesStruct struct {
}
type testPropertiesStruct struct {
name string
private string
Public_Kept string `sdk:"keep"`
S_Common string
S_Different string `android:"arch_variant"`
A_Common []string
A_Different []string `android:"arch_variant"`
F_Common *bool
F_Different *bool `android:"arch_variant"`
name string
private string
Public_Ignore string `sdk:"ignore"`
S_Common string
S_Different string `android:"arch_variant"`
A_Common []string
A_Different []string `android:"arch_variant"`
F_Common *bool
F_Different *bool `android:"arch_variant"`
EmbeddedPropertiesStruct
}
@@ -244,30 +244,30 @@ func TestCommonValueOptimization(t *testing.T) {
common := &testPropertiesStruct{name: "common"}
structs := []propertiesContainer{
&testPropertiesStruct{
name: "struct-0",
private: "common",
Public_Kept: "common",
S_Common: "common",
S_Different: "upper",
A_Common: []string{"first", "second"},
A_Different: []string{"alpha", "beta"},
F_Common: proptools.BoolPtr(false),
F_Different: proptools.BoolPtr(false),
name: "struct-0",
private: "common",
Public_Ignore: "common",
S_Common: "common",
S_Different: "upper",
A_Common: []string{"first", "second"},
A_Different: []string{"alpha", "beta"},
F_Common: proptools.BoolPtr(false),
F_Different: proptools.BoolPtr(false),
EmbeddedPropertiesStruct: EmbeddedPropertiesStruct{
S_Embedded_Common: "embedded_common",
S_Embedded_Different: "embedded_upper",
},
},
&testPropertiesStruct{
name: "struct-1",
private: "common",
Public_Kept: "common",
S_Common: "common",
S_Different: "lower",
A_Common: []string{"first", "second"},
A_Different: []string{"alpha", "delta"},
F_Common: proptools.BoolPtr(false),
F_Different: proptools.BoolPtr(true),
name: "struct-1",
private: "common",
Public_Ignore: "common",
S_Common: "common",
S_Different: "lower",
A_Common: []string{"first", "second"},
A_Different: []string{"alpha", "delta"},
F_Common: proptools.BoolPtr(false),
F_Different: proptools.BoolPtr(true),
EmbeddedPropertiesStruct: EmbeddedPropertiesStruct{
S_Embedded_Common: "embedded_common",
S_Embedded_Different: "embedded_lower",
@@ -282,15 +282,15 @@ func TestCommonValueOptimization(t *testing.T) {
android.AssertDeepEquals(t, "common properties not correct",
&testPropertiesStruct{
name: "common",
private: "",
Public_Kept: "",
S_Common: "common",
S_Different: "",
A_Common: []string{"first", "second"},
A_Different: []string(nil),
F_Common: proptools.BoolPtr(false),
F_Different: nil,
name: "common",
private: "",
Public_Ignore: "",
S_Common: "common",
S_Different: "",
A_Common: []string{"first", "second"},
A_Different: []string(nil),
F_Common: proptools.BoolPtr(false),
F_Different: nil,
EmbeddedPropertiesStruct: EmbeddedPropertiesStruct{
S_Embedded_Common: "embedded_common",
S_Embedded_Different: "",
@@ -300,15 +300,15 @@ func TestCommonValueOptimization(t *testing.T) {
android.AssertDeepEquals(t, "updated properties[0] not correct",
&testPropertiesStruct{
name: "struct-0",
private: "common",
Public_Kept: "common",
S_Common: "",
S_Different: "upper",
A_Common: nil,
A_Different: []string{"alpha", "beta"},
F_Common: nil,
F_Different: proptools.BoolPtr(false),
name: "struct-0",
private: "common",
Public_Ignore: "common",
S_Common: "",
S_Different: "upper",
A_Common: nil,
A_Different: []string{"alpha", "beta"},
F_Common: nil,
F_Different: proptools.BoolPtr(false),
EmbeddedPropertiesStruct: EmbeddedPropertiesStruct{
S_Embedded_Common: "",
S_Embedded_Different: "embedded_upper",
@@ -318,15 +318,15 @@ func TestCommonValueOptimization(t *testing.T) {
android.AssertDeepEquals(t, "updated properties[1] not correct",
&testPropertiesStruct{
name: "struct-1",
private: "common",
Public_Kept: "common",
S_Common: "",
S_Different: "lower",
A_Common: nil,
A_Different: []string{"alpha", "delta"},
F_Common: nil,
F_Different: proptools.BoolPtr(true),
name: "struct-1",
private: "common",
Public_Ignore: "common",
S_Common: "",
S_Different: "lower",
A_Common: nil,
A_Different: []string{"alpha", "delta"},
F_Common: nil,
F_Different: proptools.BoolPtr(true),
EmbeddedPropertiesStruct: EmbeddedPropertiesStruct{
S_Embedded_Common: "",
S_Embedded_Different: "embedded_lower",

View File

@@ -2217,8 +2217,8 @@ func (e *commonValueExtractor) gatherFields(structType reflect.Type, containingS
continue
}
// Ignore fields whose value should be kept.
if proptools.HasTag(field, "sdk", "keep") {
// Ignore fields tagged with sdk:"ignore".
if proptools.HasTag(field, "sdk", "ignore") {
continue
}