diff options
Diffstat (limited to 'android/api_levels.go')
| -rw-r--r-- | android/api_levels.go | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/android/api_levels.go b/android/api_levels.go index c83fae878..8f0fe458e 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -19,10 +19,10 @@ import ( "fmt" "strconv" "strings" - - "github.com/google/blueprint/gobtools" ) +//go:generate go run ../../blueprint/gobtools/codegen/gob_gen.go + func init() { RegisterParallelSingletonType("api_levels", ApiLevelsSingleton) } @@ -37,6 +37,7 @@ const previewAPILevelBase = 9000 // Java has these, and they're managed with the SdkKind enum of the SdkSpec. A // future cleanup should be to migrate SdkSpec to using ApiLevel instead of its // SdkVersion int, and to move SdkSpec into this package. +// @auto-generate: gob type ApiLevel struct { // The string representation of the API level. value string @@ -54,34 +55,6 @@ type ApiLevel struct { isPreview bool } -type apiLevelGob struct { - Value string - Number int - IsPreview bool -} - -func (a *ApiLevel) ToGob() *apiLevelGob { - return &apiLevelGob{ - Value: a.value, - Number: a.number, - IsPreview: a.isPreview, - } -} - -func (a *ApiLevel) FromGob(data *apiLevelGob) { - a.value = data.Value - a.number = data.Number - a.isPreview = data.IsPreview -} - -func (a ApiLevel) GobEncode() ([]byte, error) { - return gobtools.CustomGobEncode[apiLevelGob](&a) -} - -func (a *ApiLevel) GobDecode(data []byte) error { - return gobtools.CustomGobDecode[apiLevelGob](data, a) -} - func (this ApiLevel) FinalInt() int { if this.IsInvalid() { panic(fmt.Errorf("%v is not a recognized api_level\n", this)) @@ -259,7 +232,7 @@ func (this ApiLevel) LessThanOrEqualTo(other ApiLevel) bool { return this.CompareTo(other) <= 0 } -func uncheckedFinalApiLevel(num int) ApiLevel { +func UncheckedFinalApiLevel(num int) ApiLevel { return ApiLevel{ value: strconv.Itoa(num), number: num, @@ -299,32 +272,32 @@ func NewInvalidApiLevel(raw string) ApiLevel { } // The first version that introduced 64-bit ABIs. -var FirstLp64Version = uncheckedFinalApiLevel(21) +var FirstLp64Version = UncheckedFinalApiLevel(21) // Android has had various kinds of packed relocations over the years // (http://b/187907243). // // API level 30 is where the now-standard SHT_RELR is available. -var FirstShtRelrVersion = uncheckedFinalApiLevel(30) +var FirstShtRelrVersion = UncheckedFinalApiLevel(30) // API level 28 introduced SHT_RELR when it was still Android-only, and used an // Android-specific relocation. -var FirstAndroidRelrVersion = uncheckedFinalApiLevel(28) +var FirstAndroidRelrVersion = UncheckedFinalApiLevel(28) // API level 23 was when we first had the Chrome relocation packer, which is // obsolete and has been removed, but lld can now generate compatible packed // relocations itself. -var FirstPackedRelocationsVersion = uncheckedFinalApiLevel(23) +var FirstPackedRelocationsVersion = UncheckedFinalApiLevel(23) // LastWithoutModuleLibCoreSystemModules is the last API level where prebuilts/sdk does not contain // a core-for-system-modules.jar for the module-lib API scope. -var LastWithoutModuleLibCoreSystemModules = uncheckedFinalApiLevel(31) +var LastWithoutModuleLibCoreSystemModules = UncheckedFinalApiLevel(31) -var ApiLevelR = uncheckedFinalApiLevel(30) +var ApiLevelR = UncheckedFinalApiLevel(30) -var ApiLevelUpsideDownCake = uncheckedFinalApiLevel(34) +var ApiLevelUpsideDownCake = UncheckedFinalApiLevel(34) -var ApiLevelVanillaIceCream = uncheckedFinalApiLevel(35) +var ApiLevelVanillaIceCream = UncheckedFinalApiLevel(35) // ReplaceFinalizedCodenames returns the API level number associated with that API level // if the `raw` input is the codename of an API level has been finalized. @@ -399,10 +372,10 @@ func ApiLevelFromUserWithConfig(config Config, raw string) (ApiLevel, error) { if err != nil { return NoneApiLevel, fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", raw) } - return uncheckedFinalApiLevel(asInt), nil + return UncheckedFinalApiLevel(asInt), nil } - return uncheckedFinalApiLevel(canonical), nil + return UncheckedFinalApiLevel(canonical), nil } @@ -439,7 +412,7 @@ func ApiLevelForTest(raw string) ApiLevel { panic(fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", raw)) } - apiLevel := uncheckedFinalApiLevel(asInt) + apiLevel := UncheckedFinalApiLevel(asInt) return apiLevel } |
