Comments to keep Starlark/soong api logic in sync

Test: none, added comments
Change-Id: I706c516a3601716a439bd775666a93b63c5c4f27
This commit is contained in:
Alix 2023-03-02 19:35:02 +00:00 committed by Alix Espino
parent 8c41eca698
commit fb7f7b99ff
2 changed files with 8 additions and 0 deletions

View file

@ -225,6 +225,8 @@ func ApiLevelFromUser(ctx PathContext, raw string) (ApiLevel, error) {
// ApiLevelFromUserWithConfig implements ApiLevelFromUser, see comments for
// ApiLevelFromUser for more details.
func ApiLevelFromUserWithConfig(config Config, raw string) (ApiLevel, error) {
// This logic is replicated in starlark, if changing logic here update starlark code too
// https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=42;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
if raw == "" {
panic("API level string must be non-empty")
}
@ -329,6 +331,8 @@ func getApiLevelsMapReleasedVersions() map[string]int {
var finalCodenamesMapKey = NewOnceKey("FinalCodenamesMap")
func getFinalCodenamesMap(config Config) map[string]int {
// This logic is replicated in starlark, if changing logic here update starlark code too
// https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=30;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
return config.Once(finalCodenamesMapKey, func() interface{} {
apiLevelsMap := getApiLevelsMapReleasedVersions()
@ -355,6 +359,8 @@ var apiLevelsMapKey = NewOnceKey("ApiLevelsMap")
// ApiLevelsMap has entries for preview API levels
func GetApiLevelsMap(config Config) map[string]int {
// This logic is replicated in starlark, if changing logic here update starlark code too
// https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=23;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
return config.Once(apiLevelsMapKey, func() interface{} {
apiLevelsMap := getApiLevelsMapReleasedVersions()
for i, codename := range config.PlatformVersionActiveCodenames() {

View file

@ -875,6 +875,8 @@ func (c *config) AllSupportedApiLevels() []ApiLevel {
// DefaultAppTargetSdk returns the API level that platform apps are targeting.
// This converts a codename to the exact ApiLevel it represents.
func (c *config) DefaultAppTargetSdk(ctx EarlyModuleContext) ApiLevel {
// This logic is replicated in starlark, if changing logic here update starlark code too
// https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=72;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
if Bool(c.productVariables.Platform_sdk_final) {
return c.PlatformSdkVersion()
}