Merge "Fix crash when missing platform sdk version" am: 5a15e9522c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2533719 Change-Id: I19150e195aa9c25f6c672e70637dc3032b3018b9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -833,6 +833,10 @@ func (c *config) PlatformSdkVersion() ApiLevel {
|
|||||||
return uncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version)
|
return uncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) RawPlatformSdkVersion() *int {
|
||||||
|
return c.productVariables.Platform_sdk_version
|
||||||
|
}
|
||||||
|
|
||||||
func (c *config) PlatformSdkFinal() bool {
|
func (c *config) PlatformSdkFinal() bool {
|
||||||
return Bool(c.productVariables.Platform_sdk_final)
|
return Bool(c.productVariables.Platform_sdk_final)
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -87,14 +88,19 @@ func platformVersionContents(cfg android.Config) string {
|
|||||||
platformVersionActiveCodenames = append(platformVersionActiveCodenames, fmt.Sprintf("%q", codename))
|
platformVersionActiveCodenames = append(platformVersionActiveCodenames, fmt.Sprintf("%q", codename))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platformSdkVersion := "None"
|
||||||
|
if cfg.RawPlatformSdkVersion() != nil {
|
||||||
|
platformSdkVersion = strconv.Itoa(*cfg.RawPlatformSdkVersion())
|
||||||
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
platform_versions = struct(
|
platform_versions = struct(
|
||||||
platform_sdk_final = %s,
|
platform_sdk_final = %s,
|
||||||
platform_sdk_version = %d,
|
platform_sdk_version = %s,
|
||||||
platform_sdk_codename = %q,
|
platform_sdk_codename = %q,
|
||||||
platform_version_active_codenames = [%s],
|
platform_version_active_codenames = [%s],
|
||||||
)
|
)
|
||||||
`, starlark_fmt.PrintBool(cfg.PlatformSdkFinal()), cfg.PlatformSdkVersion().FinalInt(), cfg.PlatformSdkCodename(), strings.Join(platformVersionActiveCodenames, ", "))
|
`, starlark_fmt.PrintBool(cfg.PlatformSdkFinal()), platformSdkVersion, cfg.PlatformSdkCodename(), strings.Join(platformVersionActiveCodenames, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateBazelFiles(
|
func CreateBazelFiles(
|
||||||
|
Reference in New Issue
Block a user