Add sdk_version:"core_platform" to replace no_framework_libs:true
Where possible this duplicates any tests that use no_framework_libs:true with ones that use sdk_version:"core_platform". If not possible (e.g. in the default targets included in java/testing.go) it switches some to use sdk_version:"core_platform" to ensure that there is no regression in the behavior of no_framework_libs:true. Follow up changes will switch all usages of no_framework_libs:true over to use sdk_version:"core_platform" at which point no_framework_libs will be removed. Bug: 134566750 Test: m droid Change-Id: I42cb181f628b723c8f32a158ae4752b4c83365ae
This commit is contained in:
parent
a3d0986cfc
commit
50c217c744
5 changed files with 184 additions and 9 deletions
159
java/app_test.go
159
java/app_test.go
|
@ -546,7 +546,7 @@ func TestAppSdkVersion(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestJNIABI(t *testing.T) {
|
||||
func TestJNIABI_no_framework_libs_true(t *testing.T) {
|
||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||
cc_library {
|
||||
name: "libjni",
|
||||
|
@ -619,7 +619,80 @@ func TestJNIABI(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestJNIPackaging(t *testing.T) {
|
||||
func TestJNIABI(t *testing.T) {
|
||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||
cc_library {
|
||||
name: "libjni",
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "test",
|
||||
sdk_version: "core_platform",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "test_first",
|
||||
sdk_version: "core_platform",
|
||||
compile_multilib: "first",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "test_both",
|
||||
sdk_version: "core_platform",
|
||||
compile_multilib: "both",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "test_32",
|
||||
sdk_version: "core_platform",
|
||||
compile_multilib: "32",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "test_64",
|
||||
sdk_version: "core_platform",
|
||||
compile_multilib: "64",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
`)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
abis []string
|
||||
}{
|
||||
{"test", []string{"arm64-v8a"}},
|
||||
{"test_first", []string{"arm64-v8a"}},
|
||||
{"test_both", []string{"arm64-v8a", "armeabi-v7a"}},
|
||||
{"test_32", []string{"armeabi-v7a"}},
|
||||
{"test_64", []string{"arm64-v8a"}},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
app := ctx.ModuleForTests(test.name, "android_common")
|
||||
jniLibZip := app.Output("jnilibs.zip")
|
||||
var abis []string
|
||||
args := strings.Fields(jniLibZip.Args["jarArgs"])
|
||||
for i := 0; i < len(args); i++ {
|
||||
if args[i] == "-P" {
|
||||
abis = append(abis, filepath.Base(args[i+1]))
|
||||
i++
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(abis, test.abis) {
|
||||
t.Errorf("want abis %v, got %v", test.abis, abis)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestJNIPackaging_no_framework_libs_true(t *testing.T) {
|
||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||
cc_library {
|
||||
name: "libjni",
|
||||
|
@ -700,7 +773,89 @@ func TestJNIPackaging(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestJNIPackaging(t *testing.T) {
|
||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||
cc_library {
|
||||
name: "libjni",
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
android_app {
|
||||
name: "app",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
|
||||
android_app {
|
||||
name: "app_noembed",
|
||||
jni_libs: ["libjni"],
|
||||
use_embedded_native_libs: false,
|
||||
}
|
||||
|
||||
android_app {
|
||||
name: "app_embed",
|
||||
jni_libs: ["libjni"],
|
||||
use_embedded_native_libs: true,
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "test",
|
||||
sdk_version: "core_platform",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "test_noembed",
|
||||
sdk_version: "core_platform",
|
||||
jni_libs: ["libjni"],
|
||||
use_embedded_native_libs: false,
|
||||
}
|
||||
|
||||
android_test_helper_app {
|
||||
name: "test_helper",
|
||||
sdk_version: "core_platform",
|
||||
jni_libs: ["libjni"],
|
||||
}
|
||||
|
||||
android_test_helper_app {
|
||||
name: "test_helper_noembed",
|
||||
sdk_version: "core_platform",
|
||||
jni_libs: ["libjni"],
|
||||
use_embedded_native_libs: false,
|
||||
}
|
||||
`)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
packaged bool
|
||||
compressed bool
|
||||
}{
|
||||
{"app", false, false},
|
||||
{"app_noembed", false, false},
|
||||
{"app_embed", true, false},
|
||||
{"test", true, false},
|
||||
{"test_noembed", true, true},
|
||||
{"test_helper", true, false},
|
||||
{"test_helper_noembed", true, true},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
app := ctx.ModuleForTests(test.name, "android_common")
|
||||
jniLibZip := app.MaybeOutput("jnilibs.zip")
|
||||
if g, w := (jniLibZip.Rule != nil), test.packaged; g != w {
|
||||
t.Errorf("expected jni packaged %v, got %v", w, g)
|
||||
}
|
||||
|
||||
if jniLibZip.Rule != nil {
|
||||
if g, w := !strings.Contains(jniLibZip.Args["jarArgs"], "-L 0"), test.compressed; g != w {
|
||||
t.Errorf("expected jni compressed %v, got %v", w, g)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCertificates(t *testing.T) {
|
||||
|
|
11
java/java.go
11
java/java.go
|
@ -674,7 +674,7 @@ func getLinkType(m *Module, name string) (ret linkType, stubs bool) {
|
|||
return javaSdk, true
|
||||
case ver == "current":
|
||||
return javaSdk, false
|
||||
case ver == "" || ver == "none":
|
||||
case ver == "" || ver == "none" || ver == "core_platform":
|
||||
return javaPlatform, false
|
||||
default:
|
||||
if _, err := strconv.Atoi(ver); err != nil {
|
||||
|
@ -852,7 +852,8 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
|
|||
var ret string
|
||||
v := sdkContext.sdkVersion()
|
||||
// For PDK builds, use the latest SDK version instead of "current"
|
||||
if ctx.Config().IsPdkBuild() && (v == "" || v == "none" || v == "current") {
|
||||
if ctx.Config().IsPdkBuild() &&
|
||||
(v == "" || v == "none" || v == "core_platform" || v == "current") {
|
||||
sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
|
||||
latestSdkVersion := 0
|
||||
if len(sdkVersions) > 0 {
|
||||
|
@ -871,7 +872,11 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
|
|||
ret = "1.7"
|
||||
} else if ctx.Device() && sdk <= 29 || !ctx.Config().TargetOpenJDK9() {
|
||||
ret = "1.8"
|
||||
} else if ctx.Device() && sdkContext.sdkVersion() != "" && sdkContext.sdkVersion() != "none" && sdk == android.FutureApiLevel {
|
||||
} else if ctx.Device() &&
|
||||
sdkContext.sdkVersion() != "" &&
|
||||
sdkContext.sdkVersion() != "none" &&
|
||||
sdkContext.sdkVersion() != "core_platform" &&
|
||||
sdk == android.FutureApiLevel {
|
||||
// TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current"
|
||||
ret = "1.8"
|
||||
} else {
|
||||
|
|
13
java/sdk.go
13
java/sdk.go
|
@ -51,7 +51,7 @@ type sdkContext interface {
|
|||
|
||||
func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
|
||||
switch v {
|
||||
case "", "none", "current", "system_current", "test_current", "core_current":
|
||||
case "", "none", "current", "test_current", "system_current", "core_current", "core_platform":
|
||||
return ctx.Config().DefaultAppTargetSdk()
|
||||
default:
|
||||
return v
|
||||
|
@ -62,7 +62,7 @@ func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
|
|||
// it returns android.FutureApiLevel (10000).
|
||||
func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) {
|
||||
switch v {
|
||||
case "", "none", "current", "test_current", "system_current", "core_current":
|
||||
case "", "none", "current", "test_current", "system_current", "core_current", "core_platform":
|
||||
return ctx.Config().DefaultAppTargetSdkInt(), nil
|
||||
default:
|
||||
n := android.GetNumericSdkVersion(v)
|
||||
|
@ -182,7 +182,8 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
|||
}
|
||||
}
|
||||
|
||||
if ctx.Config().UnbundledBuildUsePrebuiltSdks() && v != "" && v != "none" {
|
||||
if ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
|
||||
v != "" && v != "none" && v != "core_platform" {
|
||||
return toPrebuilt(v)
|
||||
}
|
||||
|
||||
|
@ -199,6 +200,12 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
|||
return sdkDep{
|
||||
noStandardLibs: true,
|
||||
}
|
||||
case "core_platform":
|
||||
return sdkDep{
|
||||
useDefaultLibs: true,
|
||||
frameworkResModule: "framework-res",
|
||||
noFrameworksLibs: true,
|
||||
}
|
||||
case "current":
|
||||
return toModule("android_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
|
||||
case "system_current":
|
||||
|
|
|
@ -54,6 +54,14 @@ func TestClasspath(t *testing.T) {
|
|||
classpath: []string{},
|
||||
aidl: "",
|
||||
},
|
||||
{
|
||||
name: `sdk_version:"core_platform"`,
|
||||
properties: `sdk_version:"core_platform"`,
|
||||
bootclasspath: config.DefaultBootclasspathLibraries,
|
||||
system: config.DefaultSystemModules,
|
||||
classpath: []string{},
|
||||
aidl: "",
|
||||
},
|
||||
{
|
||||
name: "blank sdk version",
|
||||
properties: `sdk_version: "",`,
|
||||
|
|
|
@ -73,7 +73,7 @@ func GatherRequiredDepsForTest() string {
|
|||
|
||||
android_app {
|
||||
name: "framework-res",
|
||||
no_framework_libs: true,
|
||||
sdk_version: "core_platform",
|
||||
}
|
||||
|
||||
java_library {
|
||||
|
|
Loading…
Reference in a new issue