Revert "refactor of api_levels map for soong injection"
Revert submission 2441746-api_levels_refactor Reason for revert: broke Android kernel build tools build: https://ci.android.com/builds/branches/aosp_kernel-build-tools/grid? Reverted changes: /q/submissionid:2441746-api_levels_refactor Change-Id: I35206879b93ec95ae325025cb764c6c34880dccf
This commit is contained in:
committed by
Gerrit Code Review
parent
c566ad8a4f
commit
a865f4e905
@@ -302,8 +302,11 @@ func GetApiLevelsJson(ctx PathContext) WritablePath {
|
|||||||
return PathForOutput(ctx, "api_levels.json")
|
return PathForOutput(ctx, "api_levels.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getApiLevelsMapReleasedVersions() map[string]int {
|
var finalCodenamesMapKey = NewOnceKey("FinalCodenamesMap")
|
||||||
return map[string]int{
|
|
||||||
|
func getFinalCodenamesMap(config Config) map[string]int {
|
||||||
|
return config.Once(finalCodenamesMapKey, func() interface{} {
|
||||||
|
apiLevelsMap := map[string]int{
|
||||||
"G": 9,
|
"G": 9,
|
||||||
"I": 14,
|
"I": 14,
|
||||||
"J": 16,
|
"J": 16,
|
||||||
@@ -324,13 +327,6 @@ func getApiLevelsMapReleasedVersions() map[string]int {
|
|||||||
"S-V2": 32,
|
"S-V2": 32,
|
||||||
"Tiramisu": 33,
|
"Tiramisu": 33,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var finalCodenamesMapKey = NewOnceKey("FinalCodenamesMap")
|
|
||||||
|
|
||||||
func getFinalCodenamesMap(config Config) map[string]int {
|
|
||||||
return config.Once(finalCodenamesMapKey, func() interface{} {
|
|
||||||
apiLevelsMap := getApiLevelsMapReleasedVersions()
|
|
||||||
|
|
||||||
// TODO: Differentiate "current" and "future".
|
// TODO: Differentiate "current" and "future".
|
||||||
// The code base calls it FutureApiLevel, but the spelling is "current",
|
// The code base calls it FutureApiLevel, but the spelling is "current",
|
||||||
@@ -353,10 +349,29 @@ func getFinalCodenamesMap(config Config) map[string]int {
|
|||||||
|
|
||||||
var apiLevelsMapKey = NewOnceKey("ApiLevelsMap")
|
var apiLevelsMapKey = NewOnceKey("ApiLevelsMap")
|
||||||
|
|
||||||
// ApiLevelsMap has entries for preview API levels
|
|
||||||
func GetApiLevelsMap(config Config) map[string]int {
|
func GetApiLevelsMap(config Config) map[string]int {
|
||||||
return config.Once(apiLevelsMapKey, func() interface{} {
|
return config.Once(apiLevelsMapKey, func() interface{} {
|
||||||
apiLevelsMap := getApiLevelsMapReleasedVersions()
|
apiLevelsMap := map[string]int{
|
||||||
|
"G": 9,
|
||||||
|
"I": 14,
|
||||||
|
"J": 16,
|
||||||
|
"J-MR1": 17,
|
||||||
|
"J-MR2": 18,
|
||||||
|
"K": 19,
|
||||||
|
"L": 21,
|
||||||
|
"L-MR1": 22,
|
||||||
|
"M": 23,
|
||||||
|
"N": 24,
|
||||||
|
"N-MR1": 25,
|
||||||
|
"O": 26,
|
||||||
|
"O-MR1": 27,
|
||||||
|
"P": 28,
|
||||||
|
"Q": 29,
|
||||||
|
"R": 30,
|
||||||
|
"S": 31,
|
||||||
|
"S-V2": 32,
|
||||||
|
"Tiramisu": 33,
|
||||||
|
}
|
||||||
for i, codename := range config.PlatformVersionActiveCodenames() {
|
for i, codename := range config.PlatformVersionActiveCodenames() {
|
||||||
apiLevelsMap[codename] = previewAPILevelBase + i
|
apiLevelsMap[codename] = previewAPILevelBase + i
|
||||||
}
|
}
|
||||||
@@ -371,11 +386,20 @@ func (a *apiLevelsSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|||||||
createApiLevelsJson(ctx, apiLevelsJson, apiLevelsMap)
|
createApiLevelsJson(ctx, apiLevelsJson, apiLevelsMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printApiLevelsStarlarkDict(config Config) string {
|
||||||
|
apiLevelsMap := GetApiLevelsMap(config)
|
||||||
|
valDict := make(map[string]string, len(apiLevelsMap))
|
||||||
|
for k, v := range apiLevelsMap {
|
||||||
|
valDict[k] = strconv.Itoa(v)
|
||||||
|
}
|
||||||
|
return starlark_fmt.PrintDict(valDict, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func StarlarkApiLevelConfigs(config Config) string {
|
func StarlarkApiLevelConfigs(config Config) string {
|
||||||
return fmt.Sprintf(bazel.GeneratedBazelFileWarning+`
|
return fmt.Sprintf(bazel.GeneratedBazelFileWarning+`
|
||||||
_api_levels_released_versions = %s
|
_api_levels = %s
|
||||||
|
|
||||||
api_levels_released_versions = _api_levels_released_versions
|
api_levels = _api_levels
|
||||||
`, starlark_fmt.PrintStringIntDict(getApiLevelsMapReleasedVersions(), 0),
|
`, printApiLevelsStarlarkDict(config),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,6 @@ func soongInjectionFiles(cfg android.Config, metrics CodegenMetrics) ([]BazelFil
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
files = append(files, newFile("api_levels", GeneratedBuildFileName, `exports_files(["api_levels.json"])`))
|
files = append(files, newFile("api_levels", GeneratedBuildFileName, `exports_files(["api_levels.json"])`))
|
||||||
// TODO(b/269691302) value of apiLevelsContent is product variable dependent and should be avoided for soong injection
|
|
||||||
files = append(files, newFile("api_levels", "api_levels.json", string(apiLevelsContent)))
|
files = append(files, newFile("api_levels", "api_levels.json", string(apiLevelsContent)))
|
||||||
files = append(files, newFile("api_levels", "api_levels.bzl", android.StarlarkApiLevelConfigs(cfg)))
|
files = append(files, newFile("api_levels", "api_levels.bzl", android.StarlarkApiLevelConfigs(cfg)))
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ package starlark_fmt
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -85,16 +84,6 @@ func PrintBoolDict(dict map[string]bool, indentLevel int) string {
|
|||||||
return PrintDict(formattedValueDict, indentLevel)
|
return PrintDict(formattedValueDict, indentLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrintStringIntDict returns a Starlark-compatible string formatted as dictionary with
|
|
||||||
// string keys and int values.
|
|
||||||
func PrintStringIntDict(dict map[string]int, indentLevel int) string {
|
|
||||||
valDict := make(map[string]string, len(dict))
|
|
||||||
for k, v := range dict {
|
|
||||||
valDict[k] = strconv.Itoa(v)
|
|
||||||
}
|
|
||||||
return PrintDict(valDict, indentLevel)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrintDict returns a starlark-compatible string containing a dictionary with string keys and
|
// PrintDict returns a starlark-compatible string containing a dictionary with string keys and
|
||||||
// values printed with no additional formatting.
|
// values printed with no additional formatting.
|
||||||
func PrintDict(dict map[string]string, indentLevel int) string {
|
func PrintDict(dict map[string]string, indentLevel int) string {
|
||||||
|
Reference in New Issue
Block a user