From 02e25c85eb32c337b3f8a2033c6c092b8fea91d3 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 22 Sep 2022 15:30:58 +0100 Subject: [PATCH] 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 --- android/sdk.go | 16 +++---- sdk/sdk_test.go | 108 ++++++++++++++++++++++++------------------------ sdk/update.go | 4 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/android/sdk.go b/android/sdk.go index a9cc547e0..42f95b76c 100644 --- a/android/sdk.go +++ b/android/sdk.go @@ -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"` diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go index 8b8e1d701..4be1e79a4 100644 --- a/sdk/sdk_test.go +++ b/sdk/sdk_test.go @@ -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", diff --git a/sdk/update.go b/sdk/update.go index 81f3672fc..f20f1d6e9 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -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 }