2021-03-10 16:00:46 +01:00
|
|
|
// Copyright (C) 2021 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package sdk
|
|
|
|
|
2021-03-18 11:12:26 +01:00
|
|
|
import (
|
2021-06-09 17:17:58 +02:00
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
2022-10-04 20:03:31 +02:00
|
|
|
"strings"
|
2021-03-18 11:12:26 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"android/soong/android"
|
2021-04-19 14:23:06 +02:00
|
|
|
"android/soong/java"
|
2021-03-18 11:12:26 +01:00
|
|
|
)
|
2021-03-10 16:00:46 +01:00
|
|
|
|
2021-06-09 17:17:58 +02:00
|
|
|
// fixtureAddPlatformBootclasspathForBootclasspathFragment adds a platform_bootclasspath module that
|
|
|
|
// references the bootclasspath fragment.
|
|
|
|
func fixtureAddPlatformBootclasspathForBootclasspathFragment(apex, fragment string) android.FixturePreparer {
|
|
|
|
return android.GroupFixturePreparers(
|
|
|
|
// Add a platform_bootclasspath module.
|
|
|
|
android.FixtureAddTextFile("frameworks/base/boot/Android.bp", fmt.Sprintf(`
|
|
|
|
platform_bootclasspath {
|
|
|
|
name: "platform-bootclasspath",
|
|
|
|
fragments: [
|
|
|
|
{
|
|
|
|
apex: "%s",
|
|
|
|
module: "%s",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`, apex, fragment)),
|
|
|
|
android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil),
|
2021-11-26 19:09:27 +01:00
|
|
|
android.FixtureAddFile("frameworks/base/config/boot-image-profile.txt", nil),
|
2021-06-07 20:28:15 +02:00
|
|
|
android.FixtureAddFile("build/soong/scripts/check_boot_jars/package_allowed_list.txt", nil),
|
2021-06-09 17:17:58 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// fixtureAddPrebuiltApexForBootclasspathFragment adds a prebuilt_apex that exports the fragment.
|
|
|
|
func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) android.FixturePreparer {
|
|
|
|
apexFile := fmt.Sprintf("%s.apex", apex)
|
|
|
|
dir := "prebuilts/apex"
|
|
|
|
return android.GroupFixturePreparers(
|
|
|
|
// A preparer to add a prebuilt apex to the test fixture.
|
|
|
|
android.FixtureAddTextFile(filepath.Join(dir, "Android.bp"), fmt.Sprintf(`
|
|
|
|
prebuilt_apex {
|
|
|
|
name: "%s",
|
|
|
|
src: "%s",
|
|
|
|
exported_bootclasspath_fragments: [
|
|
|
|
"%s",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`, apex, apexFile, fragment)),
|
|
|
|
android.FixtureAddFile(filepath.Join(dir, apexFile), nil),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-04-19 14:23:06 +02:00
|
|
|
func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
|
2021-03-18 11:12:26 +01:00
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForSdkTestWithJava,
|
2021-04-22 02:45:29 +02:00
|
|
|
java.PrepareForTestWithJavaDefaultModules,
|
2021-04-19 14:23:06 +02:00
|
|
|
prepareForSdkTestWithApex,
|
|
|
|
|
|
|
|
// Some additional files needed for the art apex.
|
|
|
|
android.FixtureMergeMockFs(android.MockFS{
|
|
|
|
"com.android.art.avbpubkey": nil,
|
|
|
|
"com.android.art.pem": nil,
|
|
|
|
"system/sepolicy/apex/com.android.art-file_contexts": nil,
|
|
|
|
}),
|
2021-04-22 02:45:29 +02:00
|
|
|
|
2021-06-09 17:17:58 +02:00
|
|
|
// Add a platform_bootclasspath that depends on the fragment.
|
|
|
|
fixtureAddPlatformBootclasspathForBootclasspathFragment("com.android.art", "mybootclasspathfragment"),
|
2021-04-22 02:45:29 +02:00
|
|
|
|
2022-10-04 20:03:31 +02:00
|
|
|
java.PrepareForBootImageConfigTest,
|
2021-03-18 11:12:26 +01:00
|
|
|
android.FixtureWithRootAndroidBp(`
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
2021-04-22 00:38:34 +02:00
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
apex {
|
|
|
|
name: "com.android.art",
|
|
|
|
key: "com.android.art.key",
|
|
|
|
bootclasspath_fragments: [
|
|
|
|
"mybootclasspathfragment",
|
|
|
|
],
|
|
|
|
updatable: false,
|
2021-03-18 11:12:26 +01:00
|
|
|
}
|
|
|
|
|
2021-04-22 00:38:34 +02:00
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
2021-03-18 11:12:26 +01:00
|
|
|
image_name: "art",
|
2022-10-04 20:03:31 +02:00
|
|
|
contents: ["core1", "core2"],
|
2021-04-19 14:23:06 +02:00
|
|
|
apex_available: ["com.android.art"],
|
2022-03-31 16:42:30 +02:00
|
|
|
hidden_api: {
|
|
|
|
split_packages: ["*"],
|
|
|
|
},
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
apex_key {
|
|
|
|
name: "com.android.art.key",
|
|
|
|
public_key: "com.android.art.avbpubkey",
|
|
|
|
private_key: "com.android.art.pem",
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
2022-10-04 20:03:31 +02:00
|
|
|
name: "core1",
|
2021-04-19 14:23:06 +02:00
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
apex_available: ["com.android.art"],
|
2021-03-18 11:12:26 +01:00
|
|
|
}
|
2022-10-04 20:03:31 +02:00
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "core2",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
apex_available: ["com.android.art"],
|
|
|
|
}
|
|
|
|
`),
|
2021-03-18 11:12:26 +01:00
|
|
|
).RunTest(t)
|
2021-03-10 16:00:46 +01:00
|
|
|
|
2021-06-09 17:17:58 +02:00
|
|
|
// A preparer to update the test fixture used when processing an unpackage snapshot.
|
|
|
|
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment")
|
2021-04-22 02:45:29 +02:00
|
|
|
|
2022-10-04 20:03:31 +02:00
|
|
|
// Check that source on its own configures the bootImageConfig correctly.
|
|
|
|
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
|
|
|
|
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
|
|
|
|
2021-03-12 13:19:43 +01:00
|
|
|
CheckSnapshot(t, result, "mysdk", "",
|
2022-05-24 22:10:05 +02:00
|
|
|
checkAndroidBpContents(`
|
2021-03-10 16:00:46 +01:00
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
2021-04-22 00:38:34 +02:00
|
|
|
prebuilt_bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
2021-03-10 16:00:46 +01:00
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-04-19 14:23:06 +02:00
|
|
|
apex_available: ["com.android.art"],
|
2021-03-10 16:00:46 +01:00
|
|
|
image_name: "art",
|
2022-10-04 20:03:31 +02:00
|
|
|
contents: [
|
|
|
|
"core1",
|
|
|
|
"core2",
|
|
|
|
],
|
2021-06-29 12:59:23 +02:00
|
|
|
hidden_api: {
|
|
|
|
annotation_flags: "hiddenapi/annotation-flags.csv",
|
|
|
|
metadata: "hiddenapi/metadata.csv",
|
|
|
|
index: "hiddenapi/index.csv",
|
2021-07-22 13:00:49 +02:00
|
|
|
signature_patterns: "hiddenapi/signature-patterns.csv",
|
2021-08-10 17:14:16 +02:00
|
|
|
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
|
|
|
|
filtered_flags: "hiddenapi/filtered-flags.csv",
|
2021-06-29 12:59:23 +02:00
|
|
|
},
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
2021-04-19 14:23:06 +02:00
|
|
|
|
|
|
|
java_import {
|
2022-10-04 20:03:31 +02:00
|
|
|
name: "core1",
|
2021-04-19 14:23:06 +02:00
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["com.android.art"],
|
2022-11-21 11:57:30 +01:00
|
|
|
jars: ["java_boot_libs/snapshot/jars/are/invalid/core1.jar"],
|
2022-10-04 20:03:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "core2",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["com.android.art"],
|
2022-11-21 11:57:30 +01:00
|
|
|
jars: ["java_boot_libs/snapshot/jars/are/invalid/core2.jar"],
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
2021-06-29 12:59:23 +02:00
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
2021-07-22 13:00:49 +02:00
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
|
2021-07-20 19:03:53 +02:00
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
|
2022-11-21 11:57:30 +01:00
|
|
|
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar
|
|
|
|
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar
|
2021-06-29 12:59:23 +02:00
|
|
|
`),
|
2021-06-09 17:17:58 +02:00
|
|
|
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
|
2021-06-07 20:28:15 +02:00
|
|
|
|
|
|
|
// Check the behavior of the snapshot without the source.
|
|
|
|
snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
|
2022-10-04 20:03:31 +02:00
|
|
|
// Make sure that the boot jars package check rule includes the dex jars retrieved from the prebuilt apex.
|
|
|
|
checkBootJarsPackageCheckRule(t, result,
|
|
|
|
"out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core1.jar",
|
|
|
|
"out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core2.jar",
|
|
|
|
"out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar")
|
|
|
|
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/mybootclasspathfragment/android_common_com.android.art/meta_lic")
|
|
|
|
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
2021-06-07 20:28:15 +02:00
|
|
|
}),
|
|
|
|
|
2021-06-09 17:17:58 +02:00
|
|
|
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
|
2022-10-04 20:03:31 +02:00
|
|
|
|
|
|
|
// Check the behavior of the snapshot when the source is preferred.
|
|
|
|
snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) {
|
|
|
|
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
|
|
|
|
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
|
|
|
}),
|
|
|
|
|
2021-06-09 17:17:58 +02:00
|
|
|
snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
|
2022-10-04 20:03:31 +02:00
|
|
|
|
|
|
|
// Check the behavior of the snapshot when it is preferred.
|
|
|
|
snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) {
|
2022-10-04 21:01:04 +02:00
|
|
|
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/prebuilt_mybootclasspathfragment/android_common_com.android.art/meta_lic")
|
2022-10-04 20:03:31 +02:00
|
|
|
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
|
|
|
}),
|
2021-04-19 14:23:06 +02:00
|
|
|
)
|
2021-06-07 20:28:15 +02:00
|
|
|
|
2022-10-04 20:03:31 +02:00
|
|
|
// Make sure that the boot jars package check rule includes the dex jars created from the source.
|
|
|
|
checkBootJarsPackageCheckRule(t, result,
|
|
|
|
"out/soong/.intermediates/core1/android_common_apex10000/aligned/core1.jar",
|
|
|
|
"out/soong/.intermediates/core2/android_common_apex10000/aligned/core2.jar",
|
|
|
|
"out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar")
|
2021-06-07 20:28:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars
|
|
|
|
// package check rule.
|
2022-10-04 20:03:31 +02:00
|
|
|
func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModules ...string) {
|
|
|
|
t.Helper()
|
2021-06-07 20:28:15 +02:00
|
|
|
platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common")
|
|
|
|
bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check")
|
|
|
|
command := bootJarsCheckRule.RuleParams.Command
|
2022-10-04 20:03:31 +02:00
|
|
|
expectedCommandArgs := " build/soong/scripts/check_boot_jars/package_allowed_list.txt " + strings.Join(expectedModules, " ") + " &&"
|
2021-06-07 20:28:15 +02:00
|
|
|
android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs)
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
|
|
|
|
2022-05-13 15:12:19 +02:00
|
|
|
func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, copyRules string) {
|
2021-04-19 14:23:06 +02:00
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForSdkTestWithJava,
|
2021-04-25 14:40:15 +02:00
|
|
|
java.PrepareForTestWithJavaDefaultModules,
|
|
|
|
java.PrepareForTestWithJavaSdkLibraryFiles,
|
2021-05-12 14:46:54 +02:00
|
|
|
java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"),
|
2021-07-21 15:23:52 +02:00
|
|
|
java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:myothersdklibrary"),
|
2021-06-09 17:17:58 +02:00
|
|
|
prepareForSdkTestWithApex,
|
|
|
|
|
|
|
|
// Add a platform_bootclasspath that depends on the fragment.
|
|
|
|
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
|
|
|
|
|
2022-05-13 15:12:19 +02:00
|
|
|
android.FixtureWithRootAndroidBp(sdk+`
|
2021-06-09 17:17:58 +02:00
|
|
|
apex {
|
|
|
|
name: "myapex",
|
|
|
|
key: "myapex.key",
|
|
|
|
min_sdk_version: "2",
|
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
|
|
|
}
|
|
|
|
|
2021-04-19 14:23:06 +02:00
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-05-12 14:46:54 +02:00
|
|
|
contents: [
|
|
|
|
// This should be automatically added to the sdk_snapshot as a java_boot_libs module.
|
|
|
|
"mybootlib",
|
|
|
|
// This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
|
|
|
|
"myothersdklibrary",
|
|
|
|
],
|
2021-04-25 14:40:15 +02:00
|
|
|
api: {
|
|
|
|
stub_libs: ["mysdklibrary"],
|
|
|
|
},
|
|
|
|
core_platform_api: {
|
2021-05-12 14:46:54 +02:00
|
|
|
// This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
|
2021-04-25 14:40:15 +02:00
|
|
|
stub_libs: ["mycoreplatform"],
|
|
|
|
},
|
2022-03-31 16:42:30 +02:00
|
|
|
hidden_api: {
|
|
|
|
split_packages: ["*"],
|
|
|
|
},
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "mybootlib",
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-04-19 14:23:06 +02:00
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
2021-06-09 17:17:58 +02:00
|
|
|
min_sdk_version: "2",
|
2021-04-19 14:23:06 +02:00
|
|
|
compile_dex: true,
|
2021-06-09 17:17:58 +02:00
|
|
|
permitted_packages: ["mybootlib"],
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
2021-04-25 14:40:15 +02:00
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mysdklibrary",
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-04-25 14:40:15 +02:00
|
|
|
srcs: ["Test.java"],
|
2021-05-13 23:34:45 +02:00
|
|
|
shared_library: false,
|
2021-04-25 14:40:15 +02:00
|
|
|
public: {enabled: true},
|
2021-06-09 17:17:58 +02:00
|
|
|
min_sdk_version: "2",
|
2021-04-25 14:40:15 +02:00
|
|
|
}
|
|
|
|
|
2021-05-12 14:46:54 +02:00
|
|
|
java_sdk_library {
|
|
|
|
name: "myothersdklibrary",
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-05-12 14:46:54 +02:00
|
|
|
srcs: ["Test.java"],
|
2021-06-24 14:25:57 +02:00
|
|
|
compile_dex: true,
|
2021-05-12 14:46:54 +02:00
|
|
|
public: {enabled: true},
|
2021-06-09 17:17:58 +02:00
|
|
|
min_sdk_version: "2",
|
|
|
|
permitted_packages: ["myothersdklibrary"],
|
2021-05-12 14:46:54 +02:00
|
|
|
}
|
|
|
|
|
2021-04-25 14:40:15 +02:00
|
|
|
java_sdk_library {
|
|
|
|
name: "mycoreplatform",
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-04-25 14:40:15 +02:00
|
|
|
srcs: ["Test.java"],
|
2021-06-24 14:25:57 +02:00
|
|
|
compile_dex: true,
|
2021-04-25 14:40:15 +02:00
|
|
|
public: {enabled: true},
|
2021-06-09 17:17:58 +02:00
|
|
|
min_sdk_version: "2",
|
2021-04-25 14:40:15 +02:00
|
|
|
}
|
2021-04-19 14:23:06 +02:00
|
|
|
`),
|
|
|
|
).RunTest(t)
|
|
|
|
|
2021-06-09 17:17:58 +02:00
|
|
|
// A preparer to update the test fixture used when processing an unpackage snapshot.
|
|
|
|
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
|
|
|
|
|
2021-04-19 14:23:06 +02:00
|
|
|
CheckSnapshot(t, result, "mysdk", "",
|
2022-05-24 22:10:05 +02:00
|
|
|
checkAndroidBpContents(`
|
2021-04-19 14:23:06 +02:00
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
prebuilt_bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-05-12 14:46:54 +02:00
|
|
|
contents: [
|
|
|
|
"mybootlib",
|
|
|
|
"myothersdklibrary",
|
|
|
|
],
|
2021-04-25 14:40:15 +02:00
|
|
|
api: {
|
|
|
|
stub_libs: ["mysdklibrary"],
|
|
|
|
},
|
|
|
|
core_platform_api: {
|
|
|
|
stub_libs: ["mycoreplatform"],
|
|
|
|
},
|
2021-04-15 14:32:00 +02:00
|
|
|
hidden_api: {
|
|
|
|
annotation_flags: "hiddenapi/annotation-flags.csv",
|
|
|
|
metadata: "hiddenapi/metadata.csv",
|
|
|
|
index: "hiddenapi/index.csv",
|
2021-07-22 13:00:49 +02:00
|
|
|
signature_patterns: "hiddenapi/signature-patterns.csv",
|
2021-08-10 17:14:16 +02:00
|
|
|
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
|
|
|
|
filtered_flags: "hiddenapi/filtered-flags.csv",
|
2021-04-15 14:32:00 +02:00
|
|
|
},
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "mybootlib",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2022-11-21 11:57:30 +01:00
|
|
|
jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
|
2021-07-15 15:14:41 +02:00
|
|
|
permitted_packages: ["mybootlib"],
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
2021-04-25 14:40:15 +02:00
|
|
|
|
2021-05-12 14:46:54 +02:00
|
|
|
java_sdk_library_import {
|
|
|
|
name: "myothersdklibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-06-24 14:25:57 +02:00
|
|
|
shared_library: true,
|
|
|
|
compile_dex: true,
|
2021-07-15 15:14:41 +02:00
|
|
|
permitted_packages: ["myothersdklibrary"],
|
2021-05-12 14:46:54 +02:00
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/myothersdklibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/myothersdklibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/myothersdklibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-04-25 14:40:15 +02:00
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-05-13 23:34:45 +02:00
|
|
|
shared_library: false,
|
2021-04-25 14:40:15 +02:00
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mysdklibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mycoreplatform",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-06-09 17:17:58 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-06-24 14:25:57 +02:00
|
|
|
shared_library: true,
|
|
|
|
compile_dex: true,
|
2021-04-25 14:40:15 +02:00
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mycoreplatform-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mycoreplatform.txt",
|
|
|
|
removed_api: "sdk_library/public/mycoreplatform-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
2021-05-12 14:46:54 +02:00
|
|
|
`),
|
2022-05-13 15:12:19 +02:00
|
|
|
checkAllCopyRules(copyRules),
|
2021-06-09 17:17:58 +02:00
|
|
|
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
|
2021-06-07 22:36:01 +02:00
|
|
|
snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
|
|
|
|
module := result.ModuleForTests("platform-bootclasspath", "android_common")
|
|
|
|
var rule android.TestingBuildParams
|
|
|
|
rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv")
|
|
|
|
java.CheckHiddenAPIRuleInputs(t, "monolithic flags", `
|
|
|
|
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv
|
|
|
|
out/soong/hiddenapi/hiddenapi-stub-flags.txt
|
|
|
|
snapshot/hiddenapi/annotation-flags.csv
|
|
|
|
`, rule)
|
|
|
|
|
|
|
|
rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv")
|
|
|
|
java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", `
|
|
|
|
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv
|
|
|
|
snapshot/hiddenapi/metadata.csv
|
|
|
|
`, rule)
|
|
|
|
|
|
|
|
rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv")
|
|
|
|
java.CheckHiddenAPIRuleInputs(t, "monolithic index", `
|
|
|
|
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
|
|
|
|
snapshot/hiddenapi/index.csv
|
|
|
|
`, rule)
|
2021-07-15 14:35:26 +02:00
|
|
|
|
2021-07-22 13:00:49 +02:00
|
|
|
rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid")
|
2021-07-20 19:03:53 +02:00
|
|
|
android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " snapshot/hiddenapi/filtered-flags.csv:snapshot/hiddenapi/signature-patterns.csv ")
|
2021-06-07 22:36:01 +02:00
|
|
|
}),
|
2021-06-09 17:17:58 +02:00
|
|
|
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
|
2021-07-22 13:00:49 +02:00
|
|
|
snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) {
|
|
|
|
module := result.ModuleForTests("platform-bootclasspath", "android_common")
|
|
|
|
rule := module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid")
|
2021-07-20 19:03:53 +02:00
|
|
|
android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv ")
|
2021-07-22 13:00:49 +02:00
|
|
|
}),
|
2021-06-09 17:17:58 +02:00
|
|
|
snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
|
|
|
|
)
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
2021-03-18 12:05:31 +01:00
|
|
|
|
2022-05-13 15:12:19 +02:00
|
|
|
func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
|
|
|
|
t.Run("added-directly", func(t *testing.T) {
|
|
|
|
testSnapshotWithBootClasspathFragment_Contents(t, `
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
|
|
|
java_sdk_libs: [
|
|
|
|
// This is not strictly needed as it should be automatically added to the sdk_snapshot as
|
|
|
|
// a java_sdk_libs module because it is used in the mybootclasspathfragment's
|
|
|
|
// api.stub_libs property. However, it is specified here to ensure that duplicates are
|
|
|
|
// correctly deduped.
|
|
|
|
"mysdklibrary",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`, `
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
|
2022-11-21 11:57:30 +01:00
|
|
|
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
|
2022-05-13 15:12:19 +02:00
|
|
|
.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
|
|
|
|
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
|
|
|
|
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
|
|
|
|
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
|
|
|
|
.intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
|
|
|
|
.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
|
|
|
|
.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
|
|
|
|
`)
|
|
|
|
})
|
|
|
|
|
|
|
|
copyBootclasspathFragmentFromApexVariantRules := `
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
|
2022-11-21 11:57:30 +01:00
|
|
|
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
|
2022-05-13 15:12:19 +02:00
|
|
|
.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
|
|
|
|
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
|
|
|
|
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
|
|
|
|
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
|
|
|
|
.intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
|
|
|
|
.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
|
|
|
|
.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
|
|
|
|
`
|
|
|
|
t.Run("added-via-apex", func(t *testing.T) {
|
|
|
|
testSnapshotWithBootClasspathFragment_Contents(t, `
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
apexes: ["myapex"],
|
|
|
|
}
|
|
|
|
`, copyBootclasspathFragmentFromApexVariantRules)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("added-directly-and-indirectly", func(t *testing.T) {
|
|
|
|
testSnapshotWithBootClasspathFragment_Contents(t, `
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
apexes: ["myapex"],
|
|
|
|
// This is not strictly needed as it should be automatically added to the sdk_snapshot as
|
|
|
|
// a bootclasspath_fragments module because it is used in the myapex's
|
|
|
|
// bootclasspath_fragments property. However, it is specified here to ensure that duplicates
|
|
|
|
// are correctly deduped.
|
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
|
|
|
java_sdk_libs: [
|
|
|
|
// This is not strictly needed as it should be automatically added to the sdk_snapshot as
|
|
|
|
// a java_sdk_libs module because it is used in the mybootclasspathfragment's
|
|
|
|
// api.stub_libs property. However, it is specified here to ensure that duplicates are
|
|
|
|
// correctly deduped.
|
|
|
|
"mysdklibrary",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`, copyBootclasspathFragmentFromApexVariantRules)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-05-18 13:54:27 +02:00
|
|
|
// TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a
|
|
|
|
// bootclasspath_fragment is correctly output to the sdk snapshot.
|
|
|
|
func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForSdkTestWithJava,
|
|
|
|
java.PrepareForTestWithJavaDefaultModules,
|
|
|
|
java.PrepareForTestWithJavaSdkLibraryFiles,
|
|
|
|
java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"),
|
2021-08-06 18:49:46 +02:00
|
|
|
java.FixtureConfigureApexBootJars("someapex:mysdklibrary", "myotherapex:myotherlib"),
|
2021-05-18 13:54:27 +02:00
|
|
|
prepareForSdkTestWithApex,
|
|
|
|
|
|
|
|
// Some additional files needed for the myotherapex.
|
|
|
|
android.FixtureMergeMockFs(android.MockFS{
|
|
|
|
"system/sepolicy/apex/myotherapex-file_contexts": nil,
|
|
|
|
"myotherapex/apex_manifest.json": nil,
|
|
|
|
"myotherapex/Test.java": nil,
|
|
|
|
}),
|
|
|
|
|
|
|
|
android.FixtureAddTextFile("myotherapex/Android.bp", `
|
|
|
|
apex {
|
|
|
|
name: "myotherapex",
|
|
|
|
key: "myapex.key",
|
|
|
|
min_sdk_version: "2",
|
|
|
|
bootclasspath_fragments: ["myotherbootclasspathfragment"],
|
|
|
|
}
|
|
|
|
|
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "myotherbootclasspathfragment",
|
|
|
|
apex_available: ["myotherapex"],
|
|
|
|
contents: [
|
|
|
|
"myotherlib",
|
|
|
|
],
|
2022-03-31 16:42:30 +02:00
|
|
|
hidden_api: {
|
|
|
|
split_packages: ["*"],
|
|
|
|
},
|
2021-05-18 13:54:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "myotherlib",
|
|
|
|
apex_available: ["myotherapex"],
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
min_sdk_version: "2",
|
|
|
|
permitted_packages: ["myothersdklibrary"],
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
|
|
|
|
android.FixtureWithRootAndroidBp(`
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
|
|
|
}
|
|
|
|
|
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
contents: [
|
|
|
|
"mysdklibrary",
|
|
|
|
],
|
|
|
|
fragments: [
|
|
|
|
{
|
|
|
|
apex: "myotherapex",
|
|
|
|
module: "myotherbootclasspathfragment"
|
|
|
|
},
|
|
|
|
],
|
2022-03-31 16:42:30 +02:00
|
|
|
hidden_api: {
|
|
|
|
split_packages: ["*"],
|
|
|
|
},
|
2021-05-18 13:54:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
shared_library: false,
|
|
|
|
public: {enabled: true},
|
|
|
|
min_sdk_version: "2",
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
).RunTest(t)
|
|
|
|
|
|
|
|
// A preparer to update the test fixture used when processing an unpackage snapshot.
|
|
|
|
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
|
|
|
|
|
|
|
|
CheckSnapshot(t, result, "mysdk", "",
|
2022-05-24 22:10:05 +02:00
|
|
|
checkAndroidBpContents(`
|
2021-05-18 13:54:27 +02:00
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
prebuilt_bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["//apex_available:platform"],
|
|
|
|
contents: ["mysdklibrary"],
|
|
|
|
fragments: [
|
|
|
|
{
|
|
|
|
apex: "myotherapex",
|
|
|
|
module: "myotherbootclasspathfragment",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
hidden_api: {
|
|
|
|
annotation_flags: "hiddenapi/annotation-flags.csv",
|
|
|
|
metadata: "hiddenapi/metadata.csv",
|
|
|
|
index: "hiddenapi/index.csv",
|
2021-07-22 13:00:49 +02:00
|
|
|
signature_patterns: "hiddenapi/signature-patterns.csv",
|
2021-08-10 17:14:16 +02:00
|
|
|
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
|
|
|
|
filtered_flags: "hiddenapi/filtered-flags.csv",
|
2021-05-18 13:54:27 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["//apex_available:platform"],
|
|
|
|
shared_library: false,
|
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mysdklibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
|
|
|
|
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
|
|
|
|
snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-04-22 00:38:34 +02:00
|
|
|
// Test that bootclasspath_fragment works with sdk.
|
|
|
|
func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
|
2021-03-18 12:05:31 +01:00
|
|
|
android.GroupFixturePreparers(
|
|
|
|
prepareForSdkTestWithApex,
|
|
|
|
prepareForSdkTestWithJava,
|
2021-05-21 20:28:09 +02:00
|
|
|
android.FixtureAddFile("java/mybootlib.jar", nil),
|
2021-03-18 12:05:31 +01:00
|
|
|
android.FixtureWithRootAndroidBp(`
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
2021-04-22 00:38:34 +02:00
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
2021-03-18 12:05:31 +01:00
|
|
|
}
|
|
|
|
|
2021-04-22 00:38:34 +02:00
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
2021-03-18 12:05:31 +01:00
|
|
|
image_name: "art",
|
2021-05-21 20:28:09 +02:00
|
|
|
contents: ["mybootlib"],
|
2021-03-18 12:05:31 +01:00
|
|
|
apex_available: ["myapex"],
|
2022-03-31 16:42:30 +02:00
|
|
|
hidden_api: {
|
|
|
|
split_packages: ["*"],
|
|
|
|
},
|
2021-03-18 12:05:31 +01:00
|
|
|
}
|
|
|
|
|
2021-05-21 20:28:09 +02:00
|
|
|
java_library {
|
|
|
|
name: "mybootlib",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
min_sdk_version: "1",
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
|
|
|
|
2021-03-18 12:05:31 +01:00
|
|
|
sdk_snapshot {
|
|
|
|
name: "mysdk@1",
|
2021-05-21 20:28:09 +02:00
|
|
|
bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"],
|
2021-03-18 12:05:31 +01:00
|
|
|
}
|
|
|
|
|
2021-04-22 00:38:34 +02:00
|
|
|
prebuilt_bootclasspath_fragment {
|
2021-05-21 20:28:09 +02:00
|
|
|
name: "mysdk_mybootclasspathfragment@1",
|
2021-04-22 00:38:34 +02:00
|
|
|
sdk_member_name: "mybootclasspathfragment",
|
2021-03-18 12:05:31 +01:00
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: [
|
|
|
|
"myapex",
|
|
|
|
],
|
|
|
|
image_name: "art",
|
2021-05-21 20:28:09 +02:00
|
|
|
contents: ["mysdk_mybootlib@1"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "mysdk_mybootlib@1",
|
|
|
|
sdk_member_name: "mybootlib",
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["com.android.art"],
|
|
|
|
jars: ["java/mybootlib.jar"],
|
2021-03-18 12:05:31 +01:00
|
|
|
}
|
|
|
|
`),
|
|
|
|
).RunTest(t)
|
|
|
|
}
|
2021-04-19 14:23:53 +02:00
|
|
|
|
|
|
|
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForSdkTestWithJava,
|
2021-05-13 01:57:55 +02:00
|
|
|
java.PrepareForTestWithJavaDefaultModules,
|
|
|
|
java.PrepareForTestWithJavaSdkLibraryFiles,
|
2022-07-27 18:27:42 +02:00
|
|
|
java.FixtureWithLastReleaseApis("mysdklibrary", "mynewlibrary"),
|
|
|
|
java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:mynewlibrary"),
|
2021-05-13 01:57:55 +02:00
|
|
|
prepareForSdkTestWithApex,
|
2021-06-09 17:17:58 +02:00
|
|
|
|
|
|
|
// Add a platform_bootclasspath that depends on the fragment.
|
|
|
|
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
|
|
|
|
|
2021-04-19 14:23:53 +02:00
|
|
|
android.MockFS{
|
|
|
|
"my-blocked.txt": nil,
|
|
|
|
"my-max-target-o-low-priority.txt": nil,
|
|
|
|
"my-max-target-p.txt": nil,
|
|
|
|
"my-max-target-q.txt": nil,
|
|
|
|
"my-max-target-r-low-priority.txt": nil,
|
|
|
|
"my-removed.txt": nil,
|
|
|
|
"my-unsupported-packages.txt": nil,
|
|
|
|
"my-unsupported.txt": nil,
|
2022-07-27 18:27:42 +02:00
|
|
|
"my-new-max-target-q.txt": nil,
|
2021-04-19 14:23:53 +02:00
|
|
|
}.AddToFixture(),
|
|
|
|
android.FixtureWithRootAndroidBp(`
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
|
|
|
}
|
|
|
|
|
2021-05-13 01:57:55 +02:00
|
|
|
apex {
|
|
|
|
name: "myapex",
|
|
|
|
key: "myapex.key",
|
|
|
|
min_sdk_version: "1",
|
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
|
|
|
}
|
|
|
|
|
2021-04-19 14:23:53 +02:00
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
2021-05-13 01:57:55 +02:00
|
|
|
apex_available: ["myapex"],
|
2022-07-27 18:27:42 +02:00
|
|
|
contents: ["mybootlib", "mynewlibrary"],
|
2021-05-13 01:57:55 +02:00
|
|
|
api: {
|
|
|
|
stub_libs: ["mysdklibrary"],
|
|
|
|
},
|
2021-04-19 14:23:53 +02:00
|
|
|
hidden_api: {
|
|
|
|
unsupported: [
|
|
|
|
"my-unsupported.txt",
|
|
|
|
],
|
|
|
|
removed: [
|
|
|
|
"my-removed.txt",
|
|
|
|
],
|
|
|
|
max_target_r_low_priority: [
|
|
|
|
"my-max-target-r-low-priority.txt",
|
|
|
|
],
|
|
|
|
max_target_q: [
|
|
|
|
"my-max-target-q.txt",
|
|
|
|
],
|
|
|
|
max_target_p: [
|
|
|
|
"my-max-target-p.txt",
|
|
|
|
],
|
|
|
|
max_target_o_low_priority: [
|
|
|
|
"my-max-target-o-low-priority.txt",
|
|
|
|
],
|
|
|
|
blocked: [
|
|
|
|
"my-blocked.txt",
|
|
|
|
],
|
|
|
|
unsupported_packages: [
|
|
|
|
"my-unsupported-packages.txt",
|
|
|
|
],
|
2022-07-27 18:27:42 +02:00
|
|
|
split_packages: ["sdklibrary"],
|
|
|
|
package_prefixes: ["sdklibrary.all.mine"],
|
|
|
|
single_packages: ["sdklibrary.mine"],
|
2021-04-19 14:23:53 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "mybootlib",
|
2021-05-13 01:57:55 +02:00
|
|
|
apex_available: ["myapex"],
|
2021-04-19 14:23:53 +02:00
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
2021-05-13 01:57:55 +02:00
|
|
|
min_sdk_version: "1",
|
2021-04-19 14:23:53 +02:00
|
|
|
compile_dex: true,
|
2021-06-09 17:17:58 +02:00
|
|
|
permitted_packages: ["mybootlib"],
|
2021-04-19 14:23:53 +02:00
|
|
|
}
|
2021-05-13 01:57:55 +02:00
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
compile_dex: true,
|
|
|
|
public: {enabled: true},
|
2021-07-15 15:14:41 +02:00
|
|
|
permitted_packages: ["mysdklibrary"],
|
2021-05-13 01:57:55 +02:00
|
|
|
}
|
2022-07-27 18:27:42 +02:00
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mynewlibrary",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
min_sdk_version: "10",
|
|
|
|
compile_dex: true,
|
|
|
|
public: {enabled: true},
|
|
|
|
permitted_packages: ["mysdklibrary"],
|
|
|
|
hidden_api: {
|
|
|
|
max_target_q: [
|
|
|
|
"my-new-max-target-q.txt",
|
|
|
|
],
|
|
|
|
split_packages: ["sdklibrary", "newlibrary"],
|
|
|
|
package_prefixes: ["newlibrary.all.mine"],
|
|
|
|
single_packages: ["newlibrary.mine"],
|
|
|
|
},
|
|
|
|
}
|
2021-04-19 14:23:53 +02:00
|
|
|
`),
|
|
|
|
).RunTest(t)
|
|
|
|
|
2021-06-09 17:17:58 +02:00
|
|
|
// A preparer to update the test fixture used when processing an unpackage snapshot.
|
|
|
|
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
|
|
|
|
|
2021-04-19 14:23:53 +02:00
|
|
|
CheckSnapshot(t, result, "mysdk", "",
|
2022-05-24 22:10:05 +02:00
|
|
|
checkAndroidBpContents(`
|
2021-04-19 14:23:53 +02:00
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
prebuilt_bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-05-13 01:57:55 +02:00
|
|
|
apex_available: ["myapex"],
|
2022-07-27 18:27:42 +02:00
|
|
|
contents: [
|
|
|
|
"mybootlib",
|
|
|
|
"mynewlibrary",
|
|
|
|
],
|
2021-05-13 01:57:55 +02:00
|
|
|
api: {
|
|
|
|
stub_libs: ["mysdklibrary"],
|
|
|
|
},
|
2021-04-19 14:23:53 +02:00
|
|
|
hidden_api: {
|
|
|
|
unsupported: ["hiddenapi/my-unsupported.txt"],
|
|
|
|
removed: ["hiddenapi/my-removed.txt"],
|
|
|
|
max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"],
|
2022-07-27 18:27:42 +02:00
|
|
|
max_target_q: [
|
|
|
|
"hiddenapi/my-max-target-q.txt",
|
|
|
|
"hiddenapi/my-new-max-target-q.txt",
|
|
|
|
],
|
2021-04-19 14:23:53 +02:00
|
|
|
max_target_p: ["hiddenapi/my-max-target-p.txt"],
|
|
|
|
max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"],
|
|
|
|
blocked: ["hiddenapi/my-blocked.txt"],
|
|
|
|
unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"],
|
2021-04-15 14:32:00 +02:00
|
|
|
annotation_flags: "hiddenapi/annotation-flags.csv",
|
|
|
|
metadata: "hiddenapi/metadata.csv",
|
|
|
|
index: "hiddenapi/index.csv",
|
2021-07-22 13:00:49 +02:00
|
|
|
signature_patterns: "hiddenapi/signature-patterns.csv",
|
2021-08-10 17:14:16 +02:00
|
|
|
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
|
|
|
|
filtered_flags: "hiddenapi/filtered-flags.csv",
|
2021-04-19 14:23:53 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "mybootlib",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
2021-05-13 01:57:55 +02:00
|
|
|
apex_available: ["myapex"],
|
2022-11-21 11:57:30 +01:00
|
|
|
jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
|
2021-07-15 15:14:41 +02:00
|
|
|
permitted_packages: ["mybootlib"],
|
2021-04-19 14:23:53 +02:00
|
|
|
}
|
2021-05-13 01:57:55 +02:00
|
|
|
|
2022-07-27 18:27:42 +02:00
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mynewlibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
shared_library: true,
|
|
|
|
compile_dex: true,
|
|
|
|
permitted_packages: ["mysdklibrary"],
|
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mynewlibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mynewlibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mynewlibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/mynewlibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-05-13 01:57:55 +02:00
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["//apex_available:platform"],
|
|
|
|
shared_library: true,
|
|
|
|
compile_dex: true,
|
2021-07-15 15:14:41 +02:00
|
|
|
permitted_packages: ["mysdklibrary"],
|
2021-05-13 01:57:55 +02:00
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mysdklibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
2021-04-19 14:23:53 +02:00
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
|
|
|
my-unsupported.txt -> hiddenapi/my-unsupported.txt
|
|
|
|
my-removed.txt -> hiddenapi/my-removed.txt
|
|
|
|
my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt
|
|
|
|
my-max-target-q.txt -> hiddenapi/my-max-target-q.txt
|
2022-07-27 18:27:42 +02:00
|
|
|
my-new-max-target-q.txt -> hiddenapi/my-new-max-target-q.txt
|
2021-04-19 14:23:53 +02:00
|
|
|
my-max-target-p.txt -> hiddenapi/my-max-target-p.txt
|
|
|
|
my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt
|
|
|
|
my-blocked.txt -> hiddenapi/my-blocked.txt
|
|
|
|
my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt
|
2021-04-15 14:32:00 +02:00
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
2021-07-22 13:00:49 +02:00
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
|
2021-07-20 19:03:53 +02:00
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
|
2022-11-21 11:57:30 +01:00
|
|
|
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
|
2022-07-27 18:27:42 +02:00
|
|
|
.intermediates/mynewlibrary.stubs/android_common/javac/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar
|
|
|
|
.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
|
|
|
|
.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
|
2021-05-13 01:57:55 +02:00
|
|
|
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
|
2021-04-19 14:23:53 +02:00
|
|
|
`),
|
2021-06-09 17:17:58 +02:00
|
|
|
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
|
|
|
|
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
|
|
|
|
snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
|
2021-04-19 14:23:53 +02:00
|
|
|
)
|
|
|
|
}
|
2022-07-27 01:53:00 +02:00
|
|
|
|
|
|
|
func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBuildRelease string,
|
|
|
|
expectedSdkSnapshot string,
|
|
|
|
expectedCopyRules string,
|
|
|
|
expectedStubFlagsInputs []string,
|
|
|
|
suffix string) {
|
|
|
|
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForSdkTestWithJava,
|
|
|
|
java.PrepareForTestWithJavaDefaultModules,
|
|
|
|
java.PrepareForTestWithJavaSdkLibraryFiles,
|
|
|
|
java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"),
|
|
|
|
java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"),
|
|
|
|
prepareForSdkTestWithApex,
|
|
|
|
|
|
|
|
// Add a platform_bootclasspath that depends on the fragment.
|
|
|
|
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
|
|
|
|
|
|
|
|
android.FixtureMergeEnv(map[string]string{
|
|
|
|
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease,
|
|
|
|
}),
|
|
|
|
|
|
|
|
android.FixtureWithRootAndroidBp(`
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
apexes: ["myapex"],
|
|
|
|
}
|
|
|
|
|
|
|
|
apex {
|
|
|
|
name: "myapex",
|
|
|
|
key: "myapex.key",
|
|
|
|
min_sdk_version: "S",
|
|
|
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
|
|
|
}
|
|
|
|
|
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
contents: [
|
|
|
|
"mysdklibrary",
|
|
|
|
"mynewsdklibrary",
|
|
|
|
],
|
|
|
|
|
|
|
|
hidden_api: {
|
|
|
|
split_packages: [],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
shared_library: false,
|
|
|
|
public: {enabled: true},
|
|
|
|
min_sdk_version: "S",
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mynewsdklibrary",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
compile_dex: true,
|
|
|
|
public: {enabled: true},
|
|
|
|
min_sdk_version: "Tiramisu",
|
|
|
|
permitted_packages: ["mynewsdklibrary"],
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
).RunTest(t)
|
|
|
|
|
|
|
|
bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common")
|
|
|
|
rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv")
|
|
|
|
android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits)
|
|
|
|
|
|
|
|
CheckSnapshot(t, result, "mysdk", "",
|
|
|
|
checkAndroidBpContents(expectedSdkSnapshot),
|
|
|
|
checkAllCopyRules(expectedCopyRules),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) {
|
|
|
|
t.Run("target S build", func(t *testing.T) {
|
|
|
|
expectedSnapshot := `
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
prebuilt_bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
contents: ["mysdklibrary"],
|
|
|
|
hidden_api: {
|
|
|
|
annotation_flags: "hiddenapi/annotation-flags.csv",
|
|
|
|
metadata: "hiddenapi/metadata.csv",
|
|
|
|
index: "hiddenapi/index.csv",
|
|
|
|
stub_flags: "hiddenapi/stub-flags.csv",
|
|
|
|
all_flags: "hiddenapi/all-flags.csv",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
shared_library: false,
|
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mysdklibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`
|
|
|
|
expectedCopyRules := `
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/annotation-flags.csv -> hiddenapi/annotation-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/metadata.csv -> hiddenapi/metadata.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/index.csv -> hiddenapi/index.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv
|
|
|
|
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
|
|
|
|
`
|
|
|
|
|
|
|
|
// On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part
|
|
|
|
// of the snapshot.
|
|
|
|
expectedStubFlagsInputs := []string{
|
|
|
|
"out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar",
|
|
|
|
"out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
|
|
|
|
}
|
|
|
|
|
|
|
|
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S",
|
|
|
|
expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "-for-sdk-snapshot")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("target-Tiramisu-build", func(t *testing.T) {
|
|
|
|
expectedSnapshot := `
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
prebuilt_bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
contents: [
|
|
|
|
"mysdklibrary",
|
|
|
|
"mynewsdklibrary",
|
|
|
|
],
|
|
|
|
hidden_api: {
|
|
|
|
annotation_flags: "hiddenapi/annotation-flags.csv",
|
|
|
|
metadata: "hiddenapi/metadata.csv",
|
|
|
|
index: "hiddenapi/index.csv",
|
|
|
|
signature_patterns: "hiddenapi/signature-patterns.csv",
|
|
|
|
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
|
|
|
|
filtered_flags: "hiddenapi/filtered-flags.csv",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
shared_library: false,
|
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mysdklibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library_import {
|
|
|
|
name: "mynewsdklibrary",
|
|
|
|
prefer: false,
|
|
|
|
visibility: ["//visibility:public"],
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
shared_library: true,
|
|
|
|
compile_dex: true,
|
|
|
|
permitted_packages: ["mynewsdklibrary"],
|
|
|
|
public: {
|
|
|
|
jars: ["sdk_library/public/mynewsdklibrary-stubs.jar"],
|
|
|
|
stub_srcs: ["sdk_library/public/mynewsdklibrary_stub_sources"],
|
|
|
|
current_api: "sdk_library/public/mynewsdklibrary.txt",
|
|
|
|
removed_api: "sdk_library/public/mynewsdklibrary-removed.txt",
|
|
|
|
sdk_version: "current",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`
|
|
|
|
expectedCopyRules := `
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
|
|
|
|
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
|
|
|
|
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
|
|
|
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
|
|
|
|
.intermediates/mynewsdklibrary.stubs/android_common/javac/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar
|
|
|
|
.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
|
|
|
|
.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
|
|
|
|
`
|
|
|
|
|
|
|
|
// On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as
|
|
|
|
// they are both part of the snapshot.
|
|
|
|
expectedStubFlagsInputs := []string{
|
|
|
|
"out/soong/.intermediates/mynewsdklibrary.stubs/android_common/dex/mynewsdklibrary.stubs.jar",
|
|
|
|
"out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar",
|
|
|
|
"out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar",
|
|
|
|
"out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
|
|
|
|
}
|
|
|
|
|
|
|
|
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu",
|
|
|
|
expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "")
|
|
|
|
})
|
|
|
|
}
|