Use latest SDK version for current in PDK builds

PDK builds need to use the latest SDK version instead of "current"
to match the behavior of Make.

Bug: 118634643
Test: sdk_test.go
Change-Id: Ice10d0ccb4066f27ce5839fc96a4026510057121
This commit is contained in:
Colin Cross
2019-01-09 23:04:25 -08:00
parent fb6d781202
commit 98fd57460f
4 changed files with 109 additions and 17 deletions

View File

@@ -777,7 +777,18 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) string {
var ret string
sdk, err := sdkVersionToNumber(ctx, sdkContext.sdkVersion())
v := sdkContext.sdkVersion()
// For PDK builds, use the latest SDK version instead of "current"
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
sdkVersions := ctx.Config().Get(sdkSingletonKey).([]int)
latestSdkVersion := 0
if len(sdkVersions) > 0 {
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
}
v = strconv.Itoa(latestSdkVersion)
}
sdk, err := sdkVersionToNumber(ctx, v)
if err != nil {
ctx.PropertyErrorf("sdk_version", "%s", err)
}