Loading android/config.go +8 −6 Original line number Diff line number Diff line Loading @@ -202,6 +202,8 @@ func TestConfig(buildDir string, env map[string]string) Config { productVariables: productVariables{ DeviceName: stringPtr("test_device"), Platform_sdk_version: intPtr(26), DeviceSystemSdkVersions: []string{"14", "15"}, Platform_systemsdk_versions: []string{"25", "26"}, AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}, AAPTPreferredConfig: stringPtr("xhdpi"), AAPTCharacteristics: stringPtr("nosdcard"), Loading java/java_test.go +3 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,9 @@ func testContext(config android.Config, bp string, "prebuilts/sdk/17/public/android.jar": nil, "prebuilts/sdk/17/public/framework.aidl": nil, "prebuilts/sdk/17/system/android.jar": nil, "prebuilts/sdk/25/public/android.jar": nil, "prebuilts/sdk/25/public/framework.aidl": nil, "prebuilts/sdk/25/system/android.jar": nil, "prebuilts/sdk/current/core/android.jar": nil, "prebuilts/sdk/current/public/android.jar": nil, "prebuilts/sdk/current/public/framework.aidl": nil, Loading java/sdk.go +3 −4 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep { v = strconv.Itoa(latestSdkVersion) } i, err := sdkVersionToNumber(ctx, v) numericSdkVersion, err := sdkVersionToNumber(ctx, v) if err != nil { ctx.PropertyErrorf("sdk_version", "%s", err) return sdkDep{} Loading Loading @@ -151,15 +151,14 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep { // Ensures that the specificed system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor apks) // or PRODUCT_SYSTEMSDK_VERSIONS (for other apks or when BOARD_SYSTEMSDK_VERSIONS is not set) if strings.HasPrefix(v, "system_") && i != android.FutureApiLevel { if strings.HasPrefix(v, "system_") && numericSdkVersion != android.FutureApiLevel { allowed_versions := ctx.DeviceConfig().PlatformSystemSdkVersions() if ctx.DeviceSpecific() || ctx.SocSpecific() { if len(ctx.DeviceConfig().SystemSdkVersions()) > 0 { allowed_versions = ctx.DeviceConfig().SystemSdkVersions() } } version := strings.TrimPrefix(v, "system_") if len(allowed_versions) > 0 && !android.InList(version, allowed_versions) { if len(allowed_versions) > 0 && !android.InList(strconv.Itoa(numericSdkVersion), allowed_versions) { ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q", v, allowed_versions) } Loading java/sdk_test.go +52 −14 Original line number Diff line number Diff line Loading @@ -50,11 +50,11 @@ var classpathTestcases = []struct { }, { name: "sdk v14", properties: `sdk_version: "14",`, name: "sdk v25", properties: `sdk_version: "25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { Loading @@ -72,11 +72,11 @@ var classpathTestcases = []struct { }, { name: "system_14", properties: `sdk_version: "system_14",`, name: "system_25", properties: `sdk_version: "system_25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { Loading Loading @@ -140,12 +140,12 @@ var classpathTestcases = []struct { }, { name: "unbundled sdk v14", name: "unbundled sdk v25", unbundled: true, properties: `sdk_version: "14",`, properties: `sdk_version: "25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { Loading @@ -162,7 +162,7 @@ var classpathTestcases = []struct { pdk: true, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/17/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { name: "pdk current", Loading @@ -170,15 +170,15 @@ var classpathTestcases = []struct { properties: `sdk_version: "current",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/17/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { name: "pdk 14", name: "pdk 25", pdk: true, properties: `sdk_version: "14",`, properties: `sdk_version: "25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, } Loading Loading @@ -285,6 +285,44 @@ func TestClasspath(t *testing.T) { t.Errorf("bootclasspath expected %q != got %q", expected, got) } }) // Test again with PLATFORM_VERSION_CODENAME=REL t.Run("REL", func(t *testing.T) { config := testConfig(nil) config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL") config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true) if testcase.unbundled { config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) } if testcase.pdk { config.TestProductVariables.Pdk = proptools.BoolPtr(true) } ctx := testContext(config, bp, nil) run(t, ctx, config) javac := ctx.ModuleForTests("foo", variant).Rule("javac") got := javac.Args["bootClasspath"] if got != bc { t.Errorf("bootclasspath expected %q != got %q", bc, got) } got = javac.Args["classpath"] if got != c { t.Errorf("classpath expected %q != got %q", c, got) } var deps []string if len(bootclasspath) > 0 && bootclasspath[0] != `""` { deps = append(deps, bootclasspath...) } deps = append(deps, classpath...) if !reflect.DeepEqual(javac.Implicits.Strings(), deps) { t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings()) } }) }) } Loading java/testing.go +0 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ func TestConfig(buildDir string, env map[string]string) android.Config { env["ANDROID_JAVA8_HOME"] = "jdk8" } config := android.TestArchConfig(buildDir, env) config.TestProductVariables.DeviceSystemSdkVersions = []string{"14", "15"} return config } Loading Loading
android/config.go +8 −6 Original line number Diff line number Diff line Loading @@ -202,6 +202,8 @@ func TestConfig(buildDir string, env map[string]string) Config { productVariables: productVariables{ DeviceName: stringPtr("test_device"), Platform_sdk_version: intPtr(26), DeviceSystemSdkVersions: []string{"14", "15"}, Platform_systemsdk_versions: []string{"25", "26"}, AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}, AAPTPreferredConfig: stringPtr("xhdpi"), AAPTCharacteristics: stringPtr("nosdcard"), Loading
java/java_test.go +3 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,9 @@ func testContext(config android.Config, bp string, "prebuilts/sdk/17/public/android.jar": nil, "prebuilts/sdk/17/public/framework.aidl": nil, "prebuilts/sdk/17/system/android.jar": nil, "prebuilts/sdk/25/public/android.jar": nil, "prebuilts/sdk/25/public/framework.aidl": nil, "prebuilts/sdk/25/system/android.jar": nil, "prebuilts/sdk/current/core/android.jar": nil, "prebuilts/sdk/current/public/android.jar": nil, "prebuilts/sdk/current/public/framework.aidl": nil, Loading
java/sdk.go +3 −4 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep { v = strconv.Itoa(latestSdkVersion) } i, err := sdkVersionToNumber(ctx, v) numericSdkVersion, err := sdkVersionToNumber(ctx, v) if err != nil { ctx.PropertyErrorf("sdk_version", "%s", err) return sdkDep{} Loading Loading @@ -151,15 +151,14 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep { // Ensures that the specificed system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor apks) // or PRODUCT_SYSTEMSDK_VERSIONS (for other apks or when BOARD_SYSTEMSDK_VERSIONS is not set) if strings.HasPrefix(v, "system_") && i != android.FutureApiLevel { if strings.HasPrefix(v, "system_") && numericSdkVersion != android.FutureApiLevel { allowed_versions := ctx.DeviceConfig().PlatformSystemSdkVersions() if ctx.DeviceSpecific() || ctx.SocSpecific() { if len(ctx.DeviceConfig().SystemSdkVersions()) > 0 { allowed_versions = ctx.DeviceConfig().SystemSdkVersions() } } version := strings.TrimPrefix(v, "system_") if len(allowed_versions) > 0 && !android.InList(version, allowed_versions) { if len(allowed_versions) > 0 && !android.InList(strconv.Itoa(numericSdkVersion), allowed_versions) { ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q", v, allowed_versions) } Loading
java/sdk_test.go +52 −14 Original line number Diff line number Diff line Loading @@ -50,11 +50,11 @@ var classpathTestcases = []struct { }, { name: "sdk v14", properties: `sdk_version: "14",`, name: "sdk v25", properties: `sdk_version: "25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { Loading @@ -72,11 +72,11 @@ var classpathTestcases = []struct { }, { name: "system_14", properties: `sdk_version: "system_14",`, name: "system_25", properties: `sdk_version: "system_25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { Loading Loading @@ -140,12 +140,12 @@ var classpathTestcases = []struct { }, { name: "unbundled sdk v14", name: "unbundled sdk v25", unbundled: true, properties: `sdk_version: "14",`, properties: `sdk_version: "25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { Loading @@ -162,7 +162,7 @@ var classpathTestcases = []struct { pdk: true, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/17/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { name: "pdk current", Loading @@ -170,15 +170,15 @@ var classpathTestcases = []struct { properties: `sdk_version: "current",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/17/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, { name: "pdk 14", name: "pdk 25", pdk: true, properties: `sdk_version: "14",`, properties: `sdk_version: "25",`, bootclasspath: []string{`""`}, system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath classpath: []string{"prebuilts/sdk/14/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, }, } Loading Loading @@ -285,6 +285,44 @@ func TestClasspath(t *testing.T) { t.Errorf("bootclasspath expected %q != got %q", expected, got) } }) // Test again with PLATFORM_VERSION_CODENAME=REL t.Run("REL", func(t *testing.T) { config := testConfig(nil) config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL") config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true) if testcase.unbundled { config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) } if testcase.pdk { config.TestProductVariables.Pdk = proptools.BoolPtr(true) } ctx := testContext(config, bp, nil) run(t, ctx, config) javac := ctx.ModuleForTests("foo", variant).Rule("javac") got := javac.Args["bootClasspath"] if got != bc { t.Errorf("bootclasspath expected %q != got %q", bc, got) } got = javac.Args["classpath"] if got != c { t.Errorf("classpath expected %q != got %q", c, got) } var deps []string if len(bootclasspath) > 0 && bootclasspath[0] != `""` { deps = append(deps, bootclasspath...) } deps = append(deps, classpath...) if !reflect.DeepEqual(javac.Implicits.Strings(), deps) { t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings()) } }) }) } Loading
java/testing.go +0 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ func TestConfig(buildDir string, env map[string]string) android.Config { env["ANDROID_JAVA8_HOME"] = "jdk8" } config := android.TestArchConfig(buildDir, env) config.TestProductVariables.DeviceSystemSdkVersions = []string{"14", "15"} return config } Loading