Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 1 | // Copyright (C) 2021 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package sdk |
| 16 | |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 17 | import ( |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 18 | "fmt" |
| 19 | "path/filepath" |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 20 | "strings" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 21 | "testing" |
| 22 | |
| 23 | "android/soong/android" |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 24 | "android/soong/java" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 25 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 26 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 27 | // fixtureAddPlatformBootclasspathForBootclasspathFragment adds a platform_bootclasspath module that |
| 28 | // references the bootclasspath fragment. |
| 29 | func fixtureAddPlatformBootclasspathForBootclasspathFragment(apex, fragment string) android.FixturePreparer { |
| 30 | return android.GroupFixturePreparers( |
| 31 | // Add a platform_bootclasspath module. |
| 32 | android.FixtureAddTextFile("frameworks/base/boot/Android.bp", fmt.Sprintf(` |
| 33 | platform_bootclasspath { |
| 34 | name: "platform-bootclasspath", |
| 35 | fragments: [ |
| 36 | { |
| 37 | apex: "%s", |
| 38 | module: "%s", |
| 39 | }, |
| 40 | ], |
| 41 | } |
Jiakai Zhang | db160c0 | 2023-03-02 12:56:13 +0000 | [diff] [blame^] | 42 | `, apex, fragment)), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 43 | android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil), |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 44 | android.FixtureAddFile("frameworks/base/config/boot-image-profile.txt", nil), |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 45 | android.FixtureAddFile("build/soong/scripts/check_boot_jars/package_allowed_list.txt", nil), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 46 | ) |
| 47 | } |
| 48 | |
| 49 | // fixtureAddPrebuiltApexForBootclasspathFragment adds a prebuilt_apex that exports the fragment. |
| 50 | func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) android.FixturePreparer { |
| 51 | apexFile := fmt.Sprintf("%s.apex", apex) |
| 52 | dir := "prebuilts/apex" |
| 53 | return android.GroupFixturePreparers( |
| 54 | // A preparer to add a prebuilt apex to the test fixture. |
| 55 | android.FixtureAddTextFile(filepath.Join(dir, "Android.bp"), fmt.Sprintf(` |
| 56 | prebuilt_apex { |
| 57 | name: "%s", |
| 58 | src: "%s", |
| 59 | exported_bootclasspath_fragments: [ |
| 60 | "%s", |
| 61 | ], |
| 62 | } |
| 63 | `, apex, apexFile, fragment)), |
| 64 | android.FixtureAddFile(filepath.Join(dir, apexFile), nil), |
| 65 | ) |
| 66 | } |
| 67 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 68 | func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) { |
| 69 | result := android.GroupFixturePreparers( |
| 70 | prepareForSdkTestWithJava, |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 71 | java.PrepareForTestWithJavaDefaultModules, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 72 | prepareForSdkTestWithApex, |
| 73 | |
| 74 | // Some additional files needed for the art apex. |
| 75 | android.FixtureMergeMockFs(android.MockFS{ |
| 76 | "com.android.art.avbpubkey": nil, |
| 77 | "com.android.art.pem": nil, |
| 78 | "system/sepolicy/apex/com.android.art-file_contexts": nil, |
| 79 | }), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 80 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 81 | // Add a platform_bootclasspath that depends on the fragment. |
Jiakai Zhang | db160c0 | 2023-03-02 12:56:13 +0000 | [diff] [blame^] | 82 | fixtureAddPlatformBootclasspathForBootclasspathFragment("com.android.art", "mybootclasspathfragment"), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 83 | |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 84 | java.PrepareForBootImageConfigTest, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 85 | android.FixtureWithRootAndroidBp(` |
| 86 | sdk { |
| 87 | name: "mysdk", |
| 88 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | apex { |
| 92 | name: "com.android.art", |
| 93 | key: "com.android.art.key", |
| 94 | bootclasspath_fragments: [ |
| 95 | "mybootclasspathfragment", |
| 96 | ], |
| 97 | updatable: false, |
| 98 | } |
| 99 | |
| 100 | bootclasspath_fragment { |
| 101 | name: "mybootclasspathfragment", |
| 102 | image_name: "art", |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 103 | contents: ["core1", "core2"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 104 | apex_available: ["com.android.art"], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 105 | hidden_api: { |
| 106 | split_packages: ["*"], |
| 107 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | apex_key { |
| 111 | name: "com.android.art.key", |
| 112 | public_key: "com.android.art.avbpubkey", |
| 113 | private_key: "com.android.art.pem", |
| 114 | } |
| 115 | |
| 116 | java_library { |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 117 | name: "core1", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 118 | srcs: ["Test.java"], |
| 119 | system_modules: "none", |
| 120 | sdk_version: "none", |
| 121 | compile_dex: true, |
| 122 | apex_available: ["com.android.art"], |
| 123 | } |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 124 | |
| 125 | java_library { |
| 126 | name: "core2", |
| 127 | srcs: ["Test.java"], |
| 128 | system_modules: "none", |
| 129 | sdk_version: "none", |
| 130 | compile_dex: true, |
| 131 | apex_available: ["com.android.art"], |
| 132 | } |
| 133 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 134 | ).RunTest(t) |
| 135 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 136 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 137 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment") |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 138 | |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 139 | // Check that source on its own configures the bootImageConfig correctly. |
| 140 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic") |
| 141 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
| 142 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 143 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 144 | checkAndroidBpContents(` |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 145 | // This is auto-generated. DO NOT EDIT. |
| 146 | |
| 147 | prebuilt_bootclasspath_fragment { |
| 148 | name: "mybootclasspathfragment", |
| 149 | prefer: false, |
| 150 | visibility: ["//visibility:public"], |
| 151 | apex_available: ["com.android.art"], |
| 152 | image_name: "art", |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 153 | contents: [ |
| 154 | "core1", |
| 155 | "core2", |
| 156 | ], |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 157 | hidden_api: { |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 158 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 159 | metadata: "hiddenapi/metadata.csv", |
| 160 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 161 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 162 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 163 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 164 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | java_import { |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 168 | name: "core1", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 169 | prefer: false, |
| 170 | visibility: ["//visibility:public"], |
| 171 | apex_available: ["com.android.art"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 172 | jars: ["java_boot_libs/snapshot/jars/are/invalid/core1.jar"], |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | java_import { |
| 176 | name: "core2", |
| 177 | prefer: false, |
| 178 | visibility: ["//visibility:public"], |
| 179 | apex_available: ["com.android.art"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 180 | jars: ["java_boot_libs/snapshot/jars/are/invalid/core2.jar"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 181 | } |
| 182 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 183 | checkAllCopyRules(` |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 184 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 185 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 186 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 187 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 188 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 189 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 190 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar |
| 191 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 192 | `), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 193 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 194 | |
| 195 | // Check the behavior of the snapshot without the source. |
| 196 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 197 | // Make sure that the boot jars package check rule includes the dex jars retrieved from the prebuilt apex. |
| 198 | checkBootJarsPackageCheckRule(t, result, |
Jiakai Zhang | db160c0 | 2023-03-02 12:56:13 +0000 | [diff] [blame^] | 199 | "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core1.jar", |
| 200 | "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core2.jar", |
| 201 | "out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar") |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 202 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/mybootclasspathfragment/android_common_com.android.art/meta_lic") |
| 203 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 204 | }), |
| 205 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 206 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 207 | |
| 208 | // Check the behavior of the snapshot when the source is preferred. |
| 209 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { |
| 210 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic") |
| 211 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
| 212 | }), |
| 213 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 214 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 215 | |
| 216 | // Check the behavior of the snapshot when it is preferred. |
| 217 | snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) { |
Paul Duffin | 20d90e3 | 2022-10-04 20:01:04 +0100 | [diff] [blame] | 218 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/prebuilt_mybootclasspathfragment/android_common_com.android.art/meta_lic") |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 219 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
| 220 | }), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 221 | ) |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 222 | |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 223 | // Make sure that the boot jars package check rule includes the dex jars created from the source. |
| 224 | checkBootJarsPackageCheckRule(t, result, |
Jiakai Zhang | db160c0 | 2023-03-02 12:56:13 +0000 | [diff] [blame^] | 225 | "out/soong/.intermediates/core1/android_common_apex10000/aligned/core1.jar", |
| 226 | "out/soong/.intermediates/core2/android_common_apex10000/aligned/core2.jar", |
| 227 | "out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar") |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | // checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars |
| 231 | // package check rule. |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 232 | func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModules ...string) { |
| 233 | t.Helper() |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 234 | platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 235 | bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check") |
| 236 | command := bootJarsCheckRule.RuleParams.Command |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 237 | expectedCommandArgs := " build/soong/scripts/check_boot_jars/package_allowed_list.txt " + strings.Join(expectedModules, " ") + " &&" |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 238 | android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs) |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 239 | } |
| 240 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 241 | func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, copyRules string) { |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 242 | result := android.GroupFixturePreparers( |
| 243 | prepareForSdkTestWithJava, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 244 | java.PrepareForTestWithJavaDefaultModules, |
| 245 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 246 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), |
satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 247 | java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:myothersdklibrary"), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 248 | prepareForSdkTestWithApex, |
| 249 | |
| 250 | // Add a platform_bootclasspath that depends on the fragment. |
| 251 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 252 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 253 | android.FixtureWithRootAndroidBp(sdk+` |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 254 | apex { |
| 255 | name: "myapex", |
| 256 | key: "myapex.key", |
| 257 | min_sdk_version: "2", |
| 258 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 259 | } |
| 260 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 261 | bootclasspath_fragment { |
| 262 | name: "mybootclasspathfragment", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 263 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 264 | contents: [ |
| 265 | // This should be automatically added to the sdk_snapshot as a java_boot_libs module. |
| 266 | "mybootlib", |
| 267 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. |
| 268 | "myothersdklibrary", |
| 269 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 270 | api: { |
| 271 | stub_libs: ["mysdklibrary"], |
| 272 | }, |
| 273 | core_platform_api: { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 274 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 275 | stub_libs: ["mycoreplatform"], |
| 276 | }, |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 277 | hidden_api: { |
| 278 | split_packages: ["*"], |
| 279 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | java_library { |
| 283 | name: "mybootlib", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 284 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 285 | srcs: ["Test.java"], |
| 286 | system_modules: "none", |
| 287 | sdk_version: "none", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 288 | min_sdk_version: "2", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 289 | compile_dex: true, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 290 | permitted_packages: ["mybootlib"], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 291 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 292 | |
| 293 | java_sdk_library { |
| 294 | name: "mysdklibrary", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 295 | apex_available: ["myapex"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 296 | srcs: ["Test.java"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 297 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 298 | public: {enabled: true}, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 299 | min_sdk_version: "2", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | java_sdk_library { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 303 | name: "myothersdklibrary", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 304 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 305 | srcs: ["Test.java"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 306 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 307 | public: {enabled: true}, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 308 | min_sdk_version: "2", |
| 309 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | java_sdk_library { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 313 | name: "mycoreplatform", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 314 | apex_available: ["myapex"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 315 | srcs: ["Test.java"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 316 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 317 | public: {enabled: true}, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 318 | min_sdk_version: "2", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 319 | } |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 320 | `), |
| 321 | ).RunTest(t) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 322 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 323 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 324 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 325 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 326 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 327 | checkAndroidBpContents(` |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 328 | // This is auto-generated. DO NOT EDIT. |
| 329 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 330 | prebuilt_bootclasspath_fragment { |
| 331 | name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 332 | prefer: false, |
| 333 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 334 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 335 | contents: [ |
| 336 | "mybootlib", |
| 337 | "myothersdklibrary", |
| 338 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 339 | api: { |
| 340 | stub_libs: ["mysdklibrary"], |
| 341 | }, |
| 342 | core_platform_api: { |
| 343 | stub_libs: ["mycoreplatform"], |
| 344 | }, |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 345 | hidden_api: { |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 346 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 347 | metadata: "hiddenapi/metadata.csv", |
| 348 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 349 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 350 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 351 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 352 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | java_import { |
| 356 | name: "mybootlib", |
| 357 | prefer: false, |
| 358 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 359 | apex_available: ["myapex"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 360 | jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"], |
Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame] | 361 | min_sdk_version: "2", |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 362 | permitted_packages: ["mybootlib"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 363 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 364 | |
| 365 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 366 | name: "myothersdklibrary", |
| 367 | prefer: false, |
| 368 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 369 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 370 | shared_library: true, |
| 371 | compile_dex: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 372 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 373 | public: { |
| 374 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 375 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 376 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 377 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 378 | sdk_version: "current", |
| 379 | }, |
| 380 | } |
| 381 | |
| 382 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 383 | name: "mysdklibrary", |
| 384 | prefer: false, |
| 385 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 386 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 387 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 388 | public: { |
| 389 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 390 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 391 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 392 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 393 | sdk_version: "current", |
| 394 | }, |
| 395 | } |
| 396 | |
| 397 | java_sdk_library_import { |
| 398 | name: "mycoreplatform", |
| 399 | prefer: false, |
| 400 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 401 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 402 | shared_library: true, |
| 403 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 404 | public: { |
| 405 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 406 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 407 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 408 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 409 | sdk_version: "current", |
| 410 | }, |
| 411 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 412 | `), |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 413 | checkAllCopyRules(copyRules), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 414 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 415 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 416 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 417 | var rule android.TestingBuildParams |
| 418 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") |
| 419 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` |
| 420 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv |
| 421 | out/soong/hiddenapi/hiddenapi-stub-flags.txt |
| 422 | snapshot/hiddenapi/annotation-flags.csv |
| 423 | `, rule) |
| 424 | |
| 425 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") |
| 426 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` |
| 427 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv |
| 428 | snapshot/hiddenapi/metadata.csv |
| 429 | `, rule) |
| 430 | |
| 431 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") |
| 432 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` |
| 433 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv |
| 434 | snapshot/hiddenapi/index.csv |
| 435 | `, rule) |
Paul Duffin | 630b11e | 2021-07-15 13:35:26 +0100 | [diff] [blame] | 436 | |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 437 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 438 | android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " snapshot/hiddenapi/filtered-flags.csv:snapshot/hiddenapi/signature-patterns.csv ") |
Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 439 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 440 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 441 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { |
| 442 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 443 | rule := module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 444 | 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 ") |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 445 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 446 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 447 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 448 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 449 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 450 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { |
| 451 | t.Run("added-directly", func(t *testing.T) { |
| 452 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 453 | sdk { |
| 454 | name: "mysdk", |
| 455 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 456 | java_sdk_libs: [ |
| 457 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 458 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 459 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 460 | // correctly deduped. |
| 461 | "mysdklibrary", |
| 462 | ], |
| 463 | } |
| 464 | `, ` |
| 465 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 466 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 467 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 468 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 469 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 470 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 471 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 472 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 473 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 474 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt |
| 475 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 476 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 477 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 478 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 479 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 480 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
| 481 | `) |
| 482 | }) |
| 483 | |
| 484 | copyBootclasspathFragmentFromApexVariantRules := ` |
| 485 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 486 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 487 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 488 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 489 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 490 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 491 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 492 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 493 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 494 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt |
| 495 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 496 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 497 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 498 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 499 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 500 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
| 501 | ` |
| 502 | t.Run("added-via-apex", func(t *testing.T) { |
| 503 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 504 | sdk { |
| 505 | name: "mysdk", |
| 506 | apexes: ["myapex"], |
| 507 | } |
| 508 | `, copyBootclasspathFragmentFromApexVariantRules) |
| 509 | }) |
| 510 | |
| 511 | t.Run("added-directly-and-indirectly", func(t *testing.T) { |
| 512 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 513 | sdk { |
| 514 | name: "mysdk", |
| 515 | apexes: ["myapex"], |
| 516 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 517 | // a bootclasspath_fragments module because it is used in the myapex's |
| 518 | // bootclasspath_fragments property. However, it is specified here to ensure that duplicates |
| 519 | // are correctly deduped. |
| 520 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 521 | java_sdk_libs: [ |
| 522 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 523 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 524 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 525 | // correctly deduped. |
| 526 | "mysdklibrary", |
| 527 | ], |
| 528 | } |
| 529 | `, copyBootclasspathFragmentFromApexVariantRules) |
| 530 | }) |
| 531 | } |
| 532 | |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 533 | // TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a |
| 534 | // bootclasspath_fragment is correctly output to the sdk snapshot. |
| 535 | func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) { |
| 536 | result := android.GroupFixturePreparers( |
| 537 | prepareForSdkTestWithJava, |
| 538 | java.PrepareForTestWithJavaDefaultModules, |
| 539 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 540 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"), |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 541 | java.FixtureConfigureApexBootJars("someapex:mysdklibrary", "myotherapex:myotherlib"), |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 542 | prepareForSdkTestWithApex, |
| 543 | |
| 544 | // Some additional files needed for the myotherapex. |
| 545 | android.FixtureMergeMockFs(android.MockFS{ |
| 546 | "system/sepolicy/apex/myotherapex-file_contexts": nil, |
| 547 | "myotherapex/apex_manifest.json": nil, |
| 548 | "myotherapex/Test.java": nil, |
| 549 | }), |
| 550 | |
| 551 | android.FixtureAddTextFile("myotherapex/Android.bp", ` |
| 552 | apex { |
| 553 | name: "myotherapex", |
| 554 | key: "myapex.key", |
| 555 | min_sdk_version: "2", |
| 556 | bootclasspath_fragments: ["myotherbootclasspathfragment"], |
| 557 | } |
| 558 | |
| 559 | bootclasspath_fragment { |
| 560 | name: "myotherbootclasspathfragment", |
| 561 | apex_available: ["myotherapex"], |
| 562 | contents: [ |
| 563 | "myotherlib", |
| 564 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 565 | hidden_api: { |
| 566 | split_packages: ["*"], |
| 567 | }, |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | java_library { |
| 571 | name: "myotherlib", |
| 572 | apex_available: ["myotherapex"], |
| 573 | srcs: ["Test.java"], |
| 574 | min_sdk_version: "2", |
| 575 | permitted_packages: ["myothersdklibrary"], |
| 576 | compile_dex: true, |
| 577 | } |
| 578 | `), |
| 579 | |
| 580 | android.FixtureWithRootAndroidBp(` |
| 581 | sdk { |
| 582 | name: "mysdk", |
| 583 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 584 | } |
| 585 | |
| 586 | bootclasspath_fragment { |
| 587 | name: "mybootclasspathfragment", |
| 588 | contents: [ |
| 589 | "mysdklibrary", |
| 590 | ], |
| 591 | fragments: [ |
| 592 | { |
| 593 | apex: "myotherapex", |
| 594 | module: "myotherbootclasspathfragment" |
| 595 | }, |
| 596 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 597 | hidden_api: { |
| 598 | split_packages: ["*"], |
| 599 | }, |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | java_sdk_library { |
| 603 | name: "mysdklibrary", |
| 604 | srcs: ["Test.java"], |
| 605 | shared_library: false, |
| 606 | public: {enabled: true}, |
| 607 | min_sdk_version: "2", |
| 608 | } |
| 609 | `), |
| 610 | ).RunTest(t) |
| 611 | |
| 612 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 613 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 614 | |
| 615 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 616 | checkAndroidBpContents(` |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 617 | // This is auto-generated. DO NOT EDIT. |
| 618 | |
| 619 | prebuilt_bootclasspath_fragment { |
| 620 | name: "mybootclasspathfragment", |
| 621 | prefer: false, |
| 622 | visibility: ["//visibility:public"], |
| 623 | apex_available: ["//apex_available:platform"], |
| 624 | contents: ["mysdklibrary"], |
| 625 | fragments: [ |
| 626 | { |
| 627 | apex: "myotherapex", |
| 628 | module: "myotherbootclasspathfragment", |
| 629 | }, |
| 630 | ], |
| 631 | hidden_api: { |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 632 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 633 | metadata: "hiddenapi/metadata.csv", |
| 634 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 635 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 636 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 637 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 638 | }, |
| 639 | } |
| 640 | |
| 641 | java_sdk_library_import { |
| 642 | name: "mysdklibrary", |
| 643 | prefer: false, |
| 644 | visibility: ["//visibility:public"], |
| 645 | apex_available: ["//apex_available:platform"], |
| 646 | shared_library: false, |
| 647 | public: { |
| 648 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 649 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 650 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 651 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 652 | sdk_version: "current", |
| 653 | }, |
| 654 | } |
| 655 | `), |
| 656 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 657 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 658 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 659 | ) |
| 660 | } |
| 661 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 662 | // Test that bootclasspath_fragment works with sdk. |
| 663 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 664 | android.GroupFixturePreparers( |
| 665 | prepareForSdkTestWithApex, |
| 666 | prepareForSdkTestWithJava, |
Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 667 | android.FixtureMergeMockFs(android.MockFS{ |
| 668 | "java/mybootlib.jar": nil, |
| 669 | "hiddenapi/annotation-flags.csv": nil, |
| 670 | "hiddenapi/index.csv": nil, |
| 671 | "hiddenapi/metadata.csv": nil, |
| 672 | "hiddenapi/signature-patterns.csv": nil, |
| 673 | "hiddenapi/filtered-stub-flags.csv": nil, |
| 674 | "hiddenapi/filtered-flags.csv": nil, |
| 675 | }), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 676 | android.FixtureWithRootAndroidBp(` |
| 677 | sdk { |
| 678 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 679 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 680 | } |
| 681 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 682 | bootclasspath_fragment { |
| 683 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 684 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 685 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 686 | apex_available: ["myapex"], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 687 | hidden_api: { |
| 688 | split_packages: ["*"], |
| 689 | }, |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 690 | } |
| 691 | |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 692 | java_library { |
| 693 | name: "mybootlib", |
| 694 | apex_available: ["myapex"], |
| 695 | srcs: ["Test.java"], |
| 696 | system_modules: "none", |
| 697 | sdk_version: "none", |
| 698 | min_sdk_version: "1", |
| 699 | compile_dex: true, |
| 700 | } |
| 701 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 702 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 703 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 704 | prefer: false, |
| 705 | visibility: ["//visibility:public"], |
| 706 | apex_available: [ |
| 707 | "myapex", |
| 708 | ], |
| 709 | image_name: "art", |
Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 710 | contents: ["mybootlib"], |
| 711 | hidden_api: { |
| 712 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 713 | metadata: "hiddenapi/metadata.csv", |
| 714 | index: "hiddenapi/index.csv", |
| 715 | signature_patterns: "hiddenapi/signature-patterns.csv", |
| 716 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 717 | filtered_flags: "hiddenapi/filtered-flags.csv", |
| 718 | }, |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | java_import { |
Paul Duffin | 80e7f73 | 2022-11-25 12:31:31 +0000 | [diff] [blame] | 722 | name: "mybootlib", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 723 | visibility: ["//visibility:public"], |
| 724 | apex_available: ["com.android.art"], |
| 725 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 726 | } |
| 727 | `), |
| 728 | ).RunTest(t) |
| 729 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 730 | |
| 731 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 732 | result := android.GroupFixturePreparers( |
| 733 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 734 | java.PrepareForTestWithJavaDefaultModules, |
| 735 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 736 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewlibrary"), |
| 737 | java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:mynewlibrary"), |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 738 | prepareForSdkTestWithApex, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 739 | |
| 740 | // Add a platform_bootclasspath that depends on the fragment. |
| 741 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 742 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 743 | android.MockFS{ |
| 744 | "my-blocked.txt": nil, |
| 745 | "my-max-target-o-low-priority.txt": nil, |
| 746 | "my-max-target-p.txt": nil, |
| 747 | "my-max-target-q.txt": nil, |
| 748 | "my-max-target-r-low-priority.txt": nil, |
| 749 | "my-removed.txt": nil, |
| 750 | "my-unsupported-packages.txt": nil, |
| 751 | "my-unsupported.txt": nil, |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 752 | "my-new-max-target-q.txt": nil, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 753 | }.AddToFixture(), |
| 754 | android.FixtureWithRootAndroidBp(` |
| 755 | sdk { |
| 756 | name: "mysdk", |
| 757 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 758 | } |
| 759 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 760 | apex { |
| 761 | name: "myapex", |
| 762 | key: "myapex.key", |
| 763 | min_sdk_version: "1", |
| 764 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 765 | } |
| 766 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 767 | bootclasspath_fragment { |
| 768 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 769 | apex_available: ["myapex"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 770 | contents: ["mybootlib", "mynewlibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 771 | api: { |
| 772 | stub_libs: ["mysdklibrary"], |
| 773 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 774 | hidden_api: { |
| 775 | unsupported: [ |
| 776 | "my-unsupported.txt", |
| 777 | ], |
| 778 | removed: [ |
| 779 | "my-removed.txt", |
| 780 | ], |
| 781 | max_target_r_low_priority: [ |
| 782 | "my-max-target-r-low-priority.txt", |
| 783 | ], |
| 784 | max_target_q: [ |
| 785 | "my-max-target-q.txt", |
| 786 | ], |
| 787 | max_target_p: [ |
| 788 | "my-max-target-p.txt", |
| 789 | ], |
| 790 | max_target_o_low_priority: [ |
| 791 | "my-max-target-o-low-priority.txt", |
| 792 | ], |
| 793 | blocked: [ |
| 794 | "my-blocked.txt", |
| 795 | ], |
| 796 | unsupported_packages: [ |
| 797 | "my-unsupported-packages.txt", |
| 798 | ], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 799 | split_packages: ["sdklibrary"], |
| 800 | package_prefixes: ["sdklibrary.all.mine"], |
| 801 | single_packages: ["sdklibrary.mine"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 802 | }, |
| 803 | } |
| 804 | |
| 805 | java_library { |
| 806 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 807 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 808 | srcs: ["Test.java"], |
| 809 | system_modules: "none", |
| 810 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 811 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 812 | compile_dex: true, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 813 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 814 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 815 | |
| 816 | java_sdk_library { |
| 817 | name: "mysdklibrary", |
| 818 | srcs: ["Test.java"], |
| 819 | compile_dex: true, |
| 820 | public: {enabled: true}, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 821 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 822 | } |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 823 | |
| 824 | java_sdk_library { |
| 825 | name: "mynewlibrary", |
| 826 | apex_available: ["myapex"], |
| 827 | srcs: ["Test.java"], |
| 828 | min_sdk_version: "10", |
| 829 | compile_dex: true, |
| 830 | public: {enabled: true}, |
| 831 | permitted_packages: ["mysdklibrary"], |
| 832 | hidden_api: { |
| 833 | max_target_q: [ |
| 834 | "my-new-max-target-q.txt", |
| 835 | ], |
| 836 | split_packages: ["sdklibrary", "newlibrary"], |
| 837 | package_prefixes: ["newlibrary.all.mine"], |
| 838 | single_packages: ["newlibrary.mine"], |
| 839 | }, |
| 840 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 841 | `), |
| 842 | ).RunTest(t) |
| 843 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 844 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 845 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 846 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 847 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 848 | checkAndroidBpContents(` |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 849 | // This is auto-generated. DO NOT EDIT. |
| 850 | |
| 851 | prebuilt_bootclasspath_fragment { |
| 852 | name: "mybootclasspathfragment", |
| 853 | prefer: false, |
| 854 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 855 | apex_available: ["myapex"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 856 | contents: [ |
| 857 | "mybootlib", |
| 858 | "mynewlibrary", |
| 859 | ], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 860 | api: { |
| 861 | stub_libs: ["mysdklibrary"], |
| 862 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 863 | hidden_api: { |
| 864 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 865 | removed: ["hiddenapi/my-removed.txt"], |
| 866 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 867 | max_target_q: [ |
| 868 | "hiddenapi/my-max-target-q.txt", |
| 869 | "hiddenapi/my-new-max-target-q.txt", |
| 870 | ], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 871 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 872 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 873 | blocked: ["hiddenapi/my-blocked.txt"], |
| 874 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 875 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 876 | metadata: "hiddenapi/metadata.csv", |
| 877 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 878 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 879 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 880 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 881 | }, |
| 882 | } |
| 883 | |
| 884 | java_import { |
| 885 | name: "mybootlib", |
| 886 | prefer: false, |
| 887 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 888 | apex_available: ["myapex"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 889 | jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"], |
Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame] | 890 | min_sdk_version: "1", |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 891 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 892 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 893 | |
| 894 | java_sdk_library_import { |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 895 | name: "mynewlibrary", |
| 896 | prefer: false, |
| 897 | visibility: ["//visibility:public"], |
| 898 | apex_available: ["myapex"], |
| 899 | shared_library: true, |
| 900 | compile_dex: true, |
| 901 | permitted_packages: ["mysdklibrary"], |
| 902 | public: { |
| 903 | jars: ["sdk_library/public/mynewlibrary-stubs.jar"], |
| 904 | stub_srcs: ["sdk_library/public/mynewlibrary_stub_sources"], |
| 905 | current_api: "sdk_library/public/mynewlibrary.txt", |
| 906 | removed_api: "sdk_library/public/mynewlibrary-removed.txt", |
| 907 | sdk_version: "current", |
| 908 | }, |
| 909 | } |
| 910 | |
| 911 | java_sdk_library_import { |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 912 | name: "mysdklibrary", |
| 913 | prefer: false, |
| 914 | visibility: ["//visibility:public"], |
| 915 | apex_available: ["//apex_available:platform"], |
| 916 | shared_library: true, |
| 917 | compile_dex: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 918 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 919 | public: { |
| 920 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 921 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 922 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 923 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 924 | sdk_version: "current", |
| 925 | }, |
| 926 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 927 | `), |
| 928 | checkAllCopyRules(` |
| 929 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 930 | my-removed.txt -> hiddenapi/my-removed.txt |
| 931 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 932 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 933 | my-new-max-target-q.txt -> hiddenapi/my-new-max-target-q.txt |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 934 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 935 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 936 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 937 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 938 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 939 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 940 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 941 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 942 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 943 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 944 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 945 | .intermediates/mynewlibrary.stubs/android_common/javac/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar |
| 946 | .intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt |
| 947 | .intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 948 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 949 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 950 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 951 | `), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 952 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 953 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 954 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 955 | ) |
| 956 | } |
Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 957 | |
| 958 | func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBuildRelease string, |
| 959 | expectedSdkSnapshot string, |
| 960 | expectedCopyRules string, |
| 961 | expectedStubFlagsInputs []string, |
| 962 | suffix string) { |
| 963 | |
| 964 | result := android.GroupFixturePreparers( |
| 965 | prepareForSdkTestWithJava, |
| 966 | java.PrepareForTestWithJavaDefaultModules, |
| 967 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 968 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"), |
| 969 | java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"), |
| 970 | prepareForSdkTestWithApex, |
| 971 | |
| 972 | // Add a platform_bootclasspath that depends on the fragment. |
| 973 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 974 | |
| 975 | android.FixtureMergeEnv(map[string]string{ |
| 976 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease, |
| 977 | }), |
| 978 | |
| 979 | android.FixtureWithRootAndroidBp(` |
| 980 | sdk { |
| 981 | name: "mysdk", |
| 982 | apexes: ["myapex"], |
| 983 | } |
| 984 | |
| 985 | apex { |
| 986 | name: "myapex", |
| 987 | key: "myapex.key", |
| 988 | min_sdk_version: "S", |
| 989 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 990 | } |
| 991 | |
| 992 | bootclasspath_fragment { |
| 993 | name: "mybootclasspathfragment", |
| 994 | apex_available: ["myapex"], |
| 995 | contents: [ |
| 996 | "mysdklibrary", |
| 997 | "mynewsdklibrary", |
| 998 | ], |
| 999 | |
| 1000 | hidden_api: { |
| 1001 | split_packages: [], |
| 1002 | }, |
| 1003 | } |
| 1004 | |
| 1005 | java_sdk_library { |
| 1006 | name: "mysdklibrary", |
| 1007 | apex_available: ["myapex"], |
| 1008 | srcs: ["Test.java"], |
| 1009 | shared_library: false, |
| 1010 | public: {enabled: true}, |
| 1011 | min_sdk_version: "S", |
| 1012 | } |
| 1013 | |
| 1014 | java_sdk_library { |
| 1015 | name: "mynewsdklibrary", |
| 1016 | apex_available: ["myapex"], |
| 1017 | srcs: ["Test.java"], |
| 1018 | compile_dex: true, |
| 1019 | public: {enabled: true}, |
| 1020 | min_sdk_version: "Tiramisu", |
| 1021 | permitted_packages: ["mynewsdklibrary"], |
| 1022 | } |
| 1023 | `), |
| 1024 | ).RunTest(t) |
| 1025 | |
| 1026 | bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common") |
| 1027 | rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv") |
| 1028 | android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits) |
| 1029 | |
| 1030 | CheckSnapshot(t, result, "mysdk", "", |
| 1031 | checkAndroidBpContents(expectedSdkSnapshot), |
| 1032 | checkAllCopyRules(expectedCopyRules), |
| 1033 | ) |
| 1034 | } |
| 1035 | |
| 1036 | func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) { |
| 1037 | t.Run("target S build", func(t *testing.T) { |
| 1038 | expectedSnapshot := ` |
| 1039 | // This is auto-generated. DO NOT EDIT. |
| 1040 | |
| 1041 | prebuilt_bootclasspath_fragment { |
| 1042 | name: "mybootclasspathfragment", |
| 1043 | prefer: false, |
| 1044 | visibility: ["//visibility:public"], |
| 1045 | apex_available: ["myapex"], |
| 1046 | contents: ["mysdklibrary"], |
| 1047 | hidden_api: { |
| 1048 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 1049 | metadata: "hiddenapi/metadata.csv", |
| 1050 | index: "hiddenapi/index.csv", |
| 1051 | stub_flags: "hiddenapi/stub-flags.csv", |
| 1052 | all_flags: "hiddenapi/all-flags.csv", |
| 1053 | }, |
| 1054 | } |
| 1055 | |
| 1056 | java_sdk_library_import { |
| 1057 | name: "mysdklibrary", |
| 1058 | prefer: false, |
| 1059 | visibility: ["//visibility:public"], |
| 1060 | apex_available: ["myapex"], |
| 1061 | shared_library: false, |
| 1062 | public: { |
| 1063 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 1064 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 1065 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 1066 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 1067 | sdk_version: "current", |
| 1068 | }, |
| 1069 | } |
| 1070 | ` |
| 1071 | expectedCopyRules := ` |
| 1072 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 1073 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/metadata.csv -> hiddenapi/metadata.csv |
| 1074 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/index.csv -> hiddenapi/index.csv |
| 1075 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 1076 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv |
| 1077 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 1078 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 1079 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 1080 | ` |
| 1081 | |
| 1082 | // On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part |
| 1083 | // of the snapshot. |
| 1084 | expectedStubFlagsInputs := []string{ |
| 1085 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", |
| 1086 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", |
| 1087 | } |
| 1088 | |
| 1089 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S", |
| 1090 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "-for-sdk-snapshot") |
| 1091 | }) |
| 1092 | |
| 1093 | t.Run("target-Tiramisu-build", func(t *testing.T) { |
| 1094 | expectedSnapshot := ` |
| 1095 | // This is auto-generated. DO NOT EDIT. |
| 1096 | |
| 1097 | prebuilt_bootclasspath_fragment { |
| 1098 | name: "mybootclasspathfragment", |
| 1099 | prefer: false, |
| 1100 | visibility: ["//visibility:public"], |
| 1101 | apex_available: ["myapex"], |
| 1102 | contents: [ |
| 1103 | "mysdklibrary", |
| 1104 | "mynewsdklibrary", |
| 1105 | ], |
| 1106 | hidden_api: { |
| 1107 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 1108 | metadata: "hiddenapi/metadata.csv", |
| 1109 | index: "hiddenapi/index.csv", |
| 1110 | signature_patterns: "hiddenapi/signature-patterns.csv", |
| 1111 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 1112 | filtered_flags: "hiddenapi/filtered-flags.csv", |
| 1113 | }, |
| 1114 | } |
| 1115 | |
| 1116 | java_sdk_library_import { |
| 1117 | name: "mysdklibrary", |
| 1118 | prefer: false, |
| 1119 | visibility: ["//visibility:public"], |
| 1120 | apex_available: ["myapex"], |
| 1121 | shared_library: false, |
| 1122 | public: { |
| 1123 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 1124 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 1125 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 1126 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 1127 | sdk_version: "current", |
| 1128 | }, |
| 1129 | } |
| 1130 | |
| 1131 | java_sdk_library_import { |
| 1132 | name: "mynewsdklibrary", |
| 1133 | prefer: false, |
| 1134 | visibility: ["//visibility:public"], |
| 1135 | apex_available: ["myapex"], |
| 1136 | shared_library: true, |
| 1137 | compile_dex: true, |
| 1138 | permitted_packages: ["mynewsdklibrary"], |
| 1139 | public: { |
| 1140 | jars: ["sdk_library/public/mynewsdklibrary-stubs.jar"], |
| 1141 | stub_srcs: ["sdk_library/public/mynewsdklibrary_stub_sources"], |
| 1142 | current_api: "sdk_library/public/mynewsdklibrary.txt", |
| 1143 | removed_api: "sdk_library/public/mynewsdklibrary-removed.txt", |
| 1144 | sdk_version: "current", |
| 1145 | }, |
| 1146 | } |
| 1147 | ` |
| 1148 | expectedCopyRules := ` |
| 1149 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 1150 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 1151 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 1152 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 1153 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 1154 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
| 1155 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 1156 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 1157 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 1158 | .intermediates/mynewsdklibrary.stubs/android_common/javac/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar |
| 1159 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt |
| 1160 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt |
| 1161 | ` |
| 1162 | |
| 1163 | // On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as |
| 1164 | // they are both part of the snapshot. |
| 1165 | expectedStubFlagsInputs := []string{ |
| 1166 | "out/soong/.intermediates/mynewsdklibrary.stubs/android_common/dex/mynewsdklibrary.stubs.jar", |
| 1167 | "out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar", |
| 1168 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", |
| 1169 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", |
| 1170 | } |
| 1171 | |
| 1172 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu", |
| 1173 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "") |
| 1174 | }) |
| 1175 | } |