Merge "Unify handling of compat and normal libs in class loader contexts." am: c5b6f32751 am: 228f63b4c1 am: 4dc62516cb am: 182b45c981

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1450817

Change-Id: Idd32fb1f1cfdff57a152492794fddbb642629190
This commit is contained in:
Ulyana Trafimovich
2020-10-28 18:18:25 +00:00
committed by Automerger Merge Worker
4 changed files with 134 additions and 84 deletions

View File

@@ -2766,7 +2766,7 @@ func TestUsesLibraries(t *testing.T) {
name: "prebuilt",
apk: "prebuilts/apk/app.apk",
certificate: "platform",
uses_libs: ["foo"],
uses_libs: ["foo", "android.test.runner"],
optional_uses_libs: [
"bar",
"baz",
@@ -2804,7 +2804,7 @@ func TestUsesLibraries(t *testing.T) {
cmd = prebuilt.Rule("verify_uses_libraries").RuleParams.Command
if w := `uses_library_names="foo"`; !strings.Contains(cmd, w) {
if w := `uses_library_names="foo android.test.runner"`; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
@@ -2812,20 +2812,48 @@ func TestUsesLibraries(t *testing.T) {
t.Errorf("wanted %q in %q", w, cmd)
}
// Test that all present libraries are preopted, including implicit SDK dependencies, possibly stubs
// Test that all present libraries are preopted, including implicit SDK dependencies, possibly stubs.
cmd = app.Rule("dexpreopt").RuleParams.Command
w := `--target-classpath-for-sdk any` +
` /system/framework/foo.jar` +
`:/system/framework/quuz.jar` +
`:/system/framework/qux.jar` +
`:/system/framework/runtime-library.jar` +
`:/system/framework/bar.jar`
`:/system/framework/bar.jar `
if !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
// Test conditional context for target SDK version 28.
if w := `--target-classpath-for-sdk 28` +
` /system/framework/org.apache.http.legacy.jar `; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
// Test conditional context for target SDK version 29.
if w := `--target-classpath-for-sdk 29` +
` /system/framework/android.hidl.base-V1.0-java.jar` +
`:/system/framework/android.hidl.manager-V1.0-java.jar `; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
// Test conditional context for target SDK version 30.
if w := `--target-classpath-for-sdk 30` +
` /system/framework/android.test.base.jar `; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
cmd = prebuilt.Rule("dexpreopt").RuleParams.Command
if w := `--target-classpath-for-sdk any /system/framework/foo.jar:/system/framework/bar.jar`; !strings.Contains(cmd, w) {
if w := `--target-classpath-for-sdk any` +
` /system/framework/foo.jar` +
`:/system/framework/android.test.runner.jar` +
`:/system/framework/bar.jar `; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
// Test conditional context for target SDK version 30.
if w := `--target-classpath-for-sdk 30` +
` /system/framework/android.test.base.jar `; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
}

View File

@@ -22,6 +22,7 @@ import (
"android/soong/android"
"android/soong/cc"
"android/soong/dexpreopt"
"android/soong/python"
"github.com/google/blueprint"
@@ -152,6 +153,24 @@ func GatherRequiredDepsForTest() string {
`, extra)
}
// For class loader context and <uses-library> tests.
dexpreoptModules := []string{"android.test.runner"}
dexpreoptModules = append(dexpreoptModules, dexpreopt.CompatUsesLibs...)
dexpreoptModules = append(dexpreoptModules, dexpreopt.OptionalCompatUsesLibs...)
for _, extra := range dexpreoptModules {
bp += fmt.Sprintf(`
java_library {
name: "%s",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "stable-core-platform-api-stubs-system-modules",
compile_dex: true,
installable: true,
}
`, extra)
}
bp += `
java_library {
name: "framework",
@@ -166,48 +185,7 @@ func GatherRequiredDepsForTest() string {
android_app {
name: "framework-res",
sdk_version: "core_platform",
}
java_library {
name: "android.hidl.base-V1.0-java",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "stable-core-platform-api-stubs-system-modules",
installable: true,
}
java_library {
name: "android.hidl.manager-V1.0-java",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "stable-core-platform-api-stubs-system-modules",
installable: true,
}
java_library {
name: "org.apache.http.legacy",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "stable-core-platform-api-stubs-system-modules",
installable: true,
}
java_library {
name: "android.test.base",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "stable-core-platform-api-stubs-system-modules",
installable: true,
}
java_library {
name: "android.test.mock",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "stable-core-platform-api-stubs-system-modules",
installable: true,
}
`
}`
systemModules := []string{
"core-current-stubs-system-modules",