Merge "Add system_$(VER)"

This commit is contained in:
TreeHugger Robot 2017-11-30 06:52:39 +00:00 committed by Android (Google) Code Review
commit 90370098f5
4 changed files with 26 additions and 3 deletions

View File

@ -157,3 +157,10 @@ func callerName(skip int) (pkgPath, funcName string, ok bool) {
ok = true
return
}
func GetNumericSdkVersion(v string) string {
if strings.Contains(v, "system_") {
return strings.Replace(v, "system_", "", 1)
}
return v
}

View File

@ -86,7 +86,7 @@ func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties)
case "current", "system_current", "test_current":
// Nothing
default:
targetApi = ctx.sdkVersion()
targetApi = android.GetNumericSdkVersion(ctx.sdkVersion())
}
}

View File

@ -248,7 +248,7 @@ func sdkStringToNumber(ctx android.BaseContext, v string) int {
case "", "current", "system_current", "test_current":
return 10000
default:
if i, err := strconv.Atoi(v); err != nil {
if i, err := strconv.Atoi(android.GetNumericSdkVersion(v)); err != nil {
ctx.PropertyErrorf("sdk_version", "invalid sdk version")
return -1
} else {
@ -272,6 +272,12 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
if strings.Contains(v, "system_") {
return sdkDep{
invalidVersion: true,
module: "vsdk_v" + strings.Replace(v, "system_", "", 1),
}
}
return sdkDep{
invalidVersion: true,
module: "sdk_v" + v,
@ -877,7 +883,7 @@ func (j *Module) minSdkVersionNumber(ctx android.ModuleContext) string {
case "", "current", "test_current", "system_current":
return strconv.Itoa(ctx.Config().DefaultAppTargetSdkInt())
default:
return String(j.deviceProperties.Sdk_version)
return android.GetNumericSdkVersion(String(j.deviceProperties.Sdk_version))
}
}

View File

@ -132,6 +132,8 @@ func testJavaWithEnvFs(t *testing.T, bp string,
"prebuilts/sdk/current/framework.aidl": nil,
"prebuilts/sdk/system_current/android.jar": nil,
"prebuilts/sdk/system_current/framework.aidl": nil,
"prebuilts/sdk/system_14/android.jar": nil,
"prebuilts/sdk/system_14/framework.aidl": nil,
"prebuilts/sdk/test_current/android.jar": nil,
"prebuilts/sdk/test_current/framework.aidl": nil,
}
@ -273,6 +275,14 @@ var classpathTestcases = []struct {
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/system_current/android.jar"},
},
{
name: "system_14",
properties: `sdk_version: "system_14",`,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/system_14/android.jar"},
},
{
name: "test_current",