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 | } |
| 42 | `, apex, fragment)), |
| 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. |
| 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, |
| 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") |
| 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, |
| 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 | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 361 | permitted_packages: ["mybootlib"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 362 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 363 | |
| 364 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 365 | name: "myothersdklibrary", |
| 366 | prefer: false, |
| 367 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 368 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 369 | shared_library: true, |
| 370 | compile_dex: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 371 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 372 | public: { |
| 373 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 374 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 375 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 376 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 377 | sdk_version: "current", |
| 378 | }, |
| 379 | } |
| 380 | |
| 381 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 382 | name: "mysdklibrary", |
| 383 | prefer: false, |
| 384 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 385 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 386 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 387 | public: { |
| 388 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 389 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 390 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 391 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 392 | sdk_version: "current", |
| 393 | }, |
| 394 | } |
| 395 | |
| 396 | java_sdk_library_import { |
| 397 | name: "mycoreplatform", |
| 398 | prefer: false, |
| 399 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 400 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 401 | shared_library: true, |
| 402 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 403 | public: { |
| 404 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 405 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 406 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 407 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 408 | sdk_version: "current", |
| 409 | }, |
| 410 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 411 | `), |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 412 | checkAllCopyRules(copyRules), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 413 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 414 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 415 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 416 | var rule android.TestingBuildParams |
| 417 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") |
| 418 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` |
| 419 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv |
| 420 | out/soong/hiddenapi/hiddenapi-stub-flags.txt |
| 421 | snapshot/hiddenapi/annotation-flags.csv |
| 422 | `, rule) |
| 423 | |
| 424 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") |
| 425 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` |
| 426 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv |
| 427 | snapshot/hiddenapi/metadata.csv |
| 428 | `, rule) |
| 429 | |
| 430 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") |
| 431 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` |
| 432 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv |
| 433 | snapshot/hiddenapi/index.csv |
| 434 | `, rule) |
Paul Duffin | 630b11e | 2021-07-15 13:35:26 +0100 | [diff] [blame] | 435 | |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 436 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 437 | 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] | 438 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 439 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 440 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { |
| 441 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 442 | rule := module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 443 | 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] | 444 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 445 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 446 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 447 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 448 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 449 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { |
| 450 | t.Run("added-directly", func(t *testing.T) { |
| 451 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 452 | sdk { |
| 453 | name: "mysdk", |
| 454 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 455 | java_sdk_libs: [ |
| 456 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 457 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 458 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 459 | // correctly deduped. |
| 460 | "mysdklibrary", |
| 461 | ], |
| 462 | } |
| 463 | `, ` |
| 464 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 465 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 466 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 467 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 468 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 469 | .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] | 470 | .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] | 471 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 472 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 473 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt |
| 474 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 475 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 476 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 477 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 478 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 479 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
| 480 | `) |
| 481 | }) |
| 482 | |
| 483 | copyBootclasspathFragmentFromApexVariantRules := ` |
| 484 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 485 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 486 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 487 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 488 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 489 | .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] | 490 | .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] | 491 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 492 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 493 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt |
| 494 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 495 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 496 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 497 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 498 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 499 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
| 500 | ` |
| 501 | t.Run("added-via-apex", func(t *testing.T) { |
| 502 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 503 | sdk { |
| 504 | name: "mysdk", |
| 505 | apexes: ["myapex"], |
| 506 | } |
| 507 | `, copyBootclasspathFragmentFromApexVariantRules) |
| 508 | }) |
| 509 | |
| 510 | t.Run("added-directly-and-indirectly", func(t *testing.T) { |
| 511 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 512 | sdk { |
| 513 | name: "mysdk", |
| 514 | apexes: ["myapex"], |
| 515 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 516 | // a bootclasspath_fragments module because it is used in the myapex's |
| 517 | // bootclasspath_fragments property. However, it is specified here to ensure that duplicates |
| 518 | // are correctly deduped. |
| 519 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 520 | java_sdk_libs: [ |
| 521 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 522 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 523 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 524 | // correctly deduped. |
| 525 | "mysdklibrary", |
| 526 | ], |
| 527 | } |
| 528 | `, copyBootclasspathFragmentFromApexVariantRules) |
| 529 | }) |
| 530 | } |
| 531 | |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 532 | // TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a |
| 533 | // bootclasspath_fragment is correctly output to the sdk snapshot. |
| 534 | func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) { |
| 535 | result := android.GroupFixturePreparers( |
| 536 | prepareForSdkTestWithJava, |
| 537 | java.PrepareForTestWithJavaDefaultModules, |
| 538 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 539 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"), |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 540 | java.FixtureConfigureApexBootJars("someapex:mysdklibrary", "myotherapex:myotherlib"), |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 541 | prepareForSdkTestWithApex, |
| 542 | |
| 543 | // Some additional files needed for the myotherapex. |
| 544 | android.FixtureMergeMockFs(android.MockFS{ |
| 545 | "system/sepolicy/apex/myotherapex-file_contexts": nil, |
| 546 | "myotherapex/apex_manifest.json": nil, |
| 547 | "myotherapex/Test.java": nil, |
| 548 | }), |
| 549 | |
| 550 | android.FixtureAddTextFile("myotherapex/Android.bp", ` |
| 551 | apex { |
| 552 | name: "myotherapex", |
| 553 | key: "myapex.key", |
| 554 | min_sdk_version: "2", |
| 555 | bootclasspath_fragments: ["myotherbootclasspathfragment"], |
| 556 | } |
| 557 | |
| 558 | bootclasspath_fragment { |
| 559 | name: "myotherbootclasspathfragment", |
| 560 | apex_available: ["myotherapex"], |
| 561 | contents: [ |
| 562 | "myotherlib", |
| 563 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 564 | hidden_api: { |
| 565 | split_packages: ["*"], |
| 566 | }, |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | java_library { |
| 570 | name: "myotherlib", |
| 571 | apex_available: ["myotherapex"], |
| 572 | srcs: ["Test.java"], |
| 573 | min_sdk_version: "2", |
| 574 | permitted_packages: ["myothersdklibrary"], |
| 575 | compile_dex: true, |
| 576 | } |
| 577 | `), |
| 578 | |
| 579 | android.FixtureWithRootAndroidBp(` |
| 580 | sdk { |
| 581 | name: "mysdk", |
| 582 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 583 | } |
| 584 | |
| 585 | bootclasspath_fragment { |
| 586 | name: "mybootclasspathfragment", |
| 587 | contents: [ |
| 588 | "mysdklibrary", |
| 589 | ], |
| 590 | fragments: [ |
| 591 | { |
| 592 | apex: "myotherapex", |
| 593 | module: "myotherbootclasspathfragment" |
| 594 | }, |
| 595 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 596 | hidden_api: { |
| 597 | split_packages: ["*"], |
| 598 | }, |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | java_sdk_library { |
| 602 | name: "mysdklibrary", |
| 603 | srcs: ["Test.java"], |
| 604 | shared_library: false, |
| 605 | public: {enabled: true}, |
| 606 | min_sdk_version: "2", |
| 607 | } |
| 608 | `), |
| 609 | ).RunTest(t) |
| 610 | |
| 611 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 612 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 613 | |
| 614 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 615 | checkAndroidBpContents(` |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 616 | // This is auto-generated. DO NOT EDIT. |
| 617 | |
| 618 | prebuilt_bootclasspath_fragment { |
| 619 | name: "mybootclasspathfragment", |
| 620 | prefer: false, |
| 621 | visibility: ["//visibility:public"], |
| 622 | apex_available: ["//apex_available:platform"], |
| 623 | contents: ["mysdklibrary"], |
| 624 | fragments: [ |
| 625 | { |
| 626 | apex: "myotherapex", |
| 627 | module: "myotherbootclasspathfragment", |
| 628 | }, |
| 629 | ], |
| 630 | hidden_api: { |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 631 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 632 | metadata: "hiddenapi/metadata.csv", |
| 633 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 634 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 635 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 636 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 637 | }, |
| 638 | } |
| 639 | |
| 640 | java_sdk_library_import { |
| 641 | name: "mysdklibrary", |
| 642 | prefer: false, |
| 643 | visibility: ["//visibility:public"], |
| 644 | apex_available: ["//apex_available:platform"], |
| 645 | shared_library: false, |
| 646 | public: { |
| 647 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 648 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 649 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 650 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 651 | sdk_version: "current", |
| 652 | }, |
| 653 | } |
| 654 | `), |
| 655 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 656 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 657 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 658 | ) |
| 659 | } |
| 660 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 661 | // Test that bootclasspath_fragment works with sdk. |
| 662 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 663 | android.GroupFixturePreparers( |
| 664 | prepareForSdkTestWithApex, |
| 665 | prepareForSdkTestWithJava, |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 666 | android.FixtureAddFile("java/mybootlib.jar", nil), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 667 | android.FixtureWithRootAndroidBp(` |
| 668 | sdk { |
| 669 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 670 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 671 | } |
| 672 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 673 | bootclasspath_fragment { |
| 674 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 675 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 676 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 677 | apex_available: ["myapex"], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 678 | hidden_api: { |
| 679 | split_packages: ["*"], |
| 680 | }, |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 681 | } |
| 682 | |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 683 | java_library { |
| 684 | name: "mybootlib", |
| 685 | apex_available: ["myapex"], |
| 686 | srcs: ["Test.java"], |
| 687 | system_modules: "none", |
| 688 | sdk_version: "none", |
| 689 | min_sdk_version: "1", |
| 690 | compile_dex: true, |
| 691 | } |
| 692 | |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 693 | sdk_snapshot { |
| 694 | name: "mysdk@1", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 695 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 696 | } |
| 697 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 698 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 699 | name: "mysdk_mybootclasspathfragment@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 700 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 701 | prefer: false, |
| 702 | visibility: ["//visibility:public"], |
| 703 | apex_available: [ |
| 704 | "myapex", |
| 705 | ], |
| 706 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 707 | contents: ["mysdk_mybootlib@1"], |
| 708 | } |
| 709 | |
| 710 | java_import { |
| 711 | name: "mysdk_mybootlib@1", |
| 712 | sdk_member_name: "mybootlib", |
| 713 | visibility: ["//visibility:public"], |
| 714 | apex_available: ["com.android.art"], |
| 715 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 716 | } |
| 717 | `), |
| 718 | ).RunTest(t) |
| 719 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 720 | |
| 721 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 722 | result := android.GroupFixturePreparers( |
| 723 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 724 | java.PrepareForTestWithJavaDefaultModules, |
| 725 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 726 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewlibrary"), |
| 727 | java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:mynewlibrary"), |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 728 | prepareForSdkTestWithApex, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 729 | |
| 730 | // Add a platform_bootclasspath that depends on the fragment. |
| 731 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 732 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 733 | android.MockFS{ |
| 734 | "my-blocked.txt": nil, |
| 735 | "my-max-target-o-low-priority.txt": nil, |
| 736 | "my-max-target-p.txt": nil, |
| 737 | "my-max-target-q.txt": nil, |
| 738 | "my-max-target-r-low-priority.txt": nil, |
| 739 | "my-removed.txt": nil, |
| 740 | "my-unsupported-packages.txt": nil, |
| 741 | "my-unsupported.txt": nil, |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 742 | "my-new-max-target-q.txt": nil, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 743 | }.AddToFixture(), |
| 744 | android.FixtureWithRootAndroidBp(` |
| 745 | sdk { |
| 746 | name: "mysdk", |
| 747 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 748 | } |
| 749 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 750 | apex { |
| 751 | name: "myapex", |
| 752 | key: "myapex.key", |
| 753 | min_sdk_version: "1", |
| 754 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 755 | } |
| 756 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 757 | bootclasspath_fragment { |
| 758 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 759 | apex_available: ["myapex"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 760 | contents: ["mybootlib", "mynewlibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 761 | api: { |
| 762 | stub_libs: ["mysdklibrary"], |
| 763 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 764 | hidden_api: { |
| 765 | unsupported: [ |
| 766 | "my-unsupported.txt", |
| 767 | ], |
| 768 | removed: [ |
| 769 | "my-removed.txt", |
| 770 | ], |
| 771 | max_target_r_low_priority: [ |
| 772 | "my-max-target-r-low-priority.txt", |
| 773 | ], |
| 774 | max_target_q: [ |
| 775 | "my-max-target-q.txt", |
| 776 | ], |
| 777 | max_target_p: [ |
| 778 | "my-max-target-p.txt", |
| 779 | ], |
| 780 | max_target_o_low_priority: [ |
| 781 | "my-max-target-o-low-priority.txt", |
| 782 | ], |
| 783 | blocked: [ |
| 784 | "my-blocked.txt", |
| 785 | ], |
| 786 | unsupported_packages: [ |
| 787 | "my-unsupported-packages.txt", |
| 788 | ], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 789 | split_packages: ["sdklibrary"], |
| 790 | package_prefixes: ["sdklibrary.all.mine"], |
| 791 | single_packages: ["sdklibrary.mine"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 792 | }, |
| 793 | } |
| 794 | |
| 795 | java_library { |
| 796 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 797 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 798 | srcs: ["Test.java"], |
| 799 | system_modules: "none", |
| 800 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 801 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 802 | compile_dex: true, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 803 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 804 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 805 | |
| 806 | java_sdk_library { |
| 807 | name: "mysdklibrary", |
| 808 | srcs: ["Test.java"], |
| 809 | compile_dex: true, |
| 810 | public: {enabled: true}, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 811 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 812 | } |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 813 | |
| 814 | java_sdk_library { |
| 815 | name: "mynewlibrary", |
| 816 | apex_available: ["myapex"], |
| 817 | srcs: ["Test.java"], |
| 818 | min_sdk_version: "10", |
| 819 | compile_dex: true, |
| 820 | public: {enabled: true}, |
| 821 | permitted_packages: ["mysdklibrary"], |
| 822 | hidden_api: { |
| 823 | max_target_q: [ |
| 824 | "my-new-max-target-q.txt", |
| 825 | ], |
| 826 | split_packages: ["sdklibrary", "newlibrary"], |
| 827 | package_prefixes: ["newlibrary.all.mine"], |
| 828 | single_packages: ["newlibrary.mine"], |
| 829 | }, |
| 830 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 831 | `), |
| 832 | ).RunTest(t) |
| 833 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 834 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 835 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 836 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 837 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 838 | checkAndroidBpContents(` |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 839 | // This is auto-generated. DO NOT EDIT. |
| 840 | |
| 841 | prebuilt_bootclasspath_fragment { |
| 842 | name: "mybootclasspathfragment", |
| 843 | prefer: false, |
| 844 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 845 | apex_available: ["myapex"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 846 | contents: [ |
| 847 | "mybootlib", |
| 848 | "mynewlibrary", |
| 849 | ], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 850 | api: { |
| 851 | stub_libs: ["mysdklibrary"], |
| 852 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 853 | hidden_api: { |
| 854 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 855 | removed: ["hiddenapi/my-removed.txt"], |
| 856 | 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] | 857 | max_target_q: [ |
| 858 | "hiddenapi/my-max-target-q.txt", |
| 859 | "hiddenapi/my-new-max-target-q.txt", |
| 860 | ], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 861 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 862 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 863 | blocked: ["hiddenapi/my-blocked.txt"], |
| 864 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 865 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 866 | metadata: "hiddenapi/metadata.csv", |
| 867 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 868 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 869 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 870 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 871 | }, |
| 872 | } |
| 873 | |
| 874 | java_import { |
| 875 | name: "mybootlib", |
| 876 | prefer: false, |
| 877 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 878 | apex_available: ["myapex"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 879 | jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"], |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 880 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 881 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 882 | |
| 883 | java_sdk_library_import { |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 884 | name: "mynewlibrary", |
| 885 | prefer: false, |
| 886 | visibility: ["//visibility:public"], |
| 887 | apex_available: ["myapex"], |
| 888 | shared_library: true, |
| 889 | compile_dex: true, |
| 890 | permitted_packages: ["mysdklibrary"], |
| 891 | public: { |
| 892 | jars: ["sdk_library/public/mynewlibrary-stubs.jar"], |
| 893 | stub_srcs: ["sdk_library/public/mynewlibrary_stub_sources"], |
| 894 | current_api: "sdk_library/public/mynewlibrary.txt", |
| 895 | removed_api: "sdk_library/public/mynewlibrary-removed.txt", |
| 896 | sdk_version: "current", |
| 897 | }, |
| 898 | } |
| 899 | |
| 900 | java_sdk_library_import { |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 901 | name: "mysdklibrary", |
| 902 | prefer: false, |
| 903 | visibility: ["//visibility:public"], |
| 904 | apex_available: ["//apex_available:platform"], |
| 905 | shared_library: true, |
| 906 | compile_dex: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 907 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 908 | public: { |
| 909 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 910 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 911 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 912 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 913 | sdk_version: "current", |
| 914 | }, |
| 915 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 916 | `), |
| 917 | checkAllCopyRules(` |
| 918 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 919 | my-removed.txt -> hiddenapi/my-removed.txt |
| 920 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 921 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 922 | 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] | 923 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 924 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 925 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 926 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 927 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 928 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 929 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 930 | .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] | 931 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 932 | .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] | 933 | .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] | 934 | .intermediates/mynewlibrary.stubs/android_common/javac/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar |
| 935 | .intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt |
| 936 | .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] | 937 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 938 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 939 | .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] | 940 | `), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 941 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 942 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 943 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 944 | ) |
| 945 | } |
Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 946 | |
| 947 | func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBuildRelease string, |
| 948 | expectedSdkSnapshot string, |
| 949 | expectedCopyRules string, |
| 950 | expectedStubFlagsInputs []string, |
| 951 | suffix string) { |
| 952 | |
| 953 | result := android.GroupFixturePreparers( |
| 954 | prepareForSdkTestWithJava, |
| 955 | java.PrepareForTestWithJavaDefaultModules, |
| 956 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 957 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"), |
| 958 | java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"), |
| 959 | prepareForSdkTestWithApex, |
| 960 | |
| 961 | // Add a platform_bootclasspath that depends on the fragment. |
| 962 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 963 | |
| 964 | android.FixtureMergeEnv(map[string]string{ |
| 965 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease, |
| 966 | }), |
| 967 | |
| 968 | android.FixtureWithRootAndroidBp(` |
| 969 | sdk { |
| 970 | name: "mysdk", |
| 971 | apexes: ["myapex"], |
| 972 | } |
| 973 | |
| 974 | apex { |
| 975 | name: "myapex", |
| 976 | key: "myapex.key", |
| 977 | min_sdk_version: "S", |
| 978 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 979 | } |
| 980 | |
| 981 | bootclasspath_fragment { |
| 982 | name: "mybootclasspathfragment", |
| 983 | apex_available: ["myapex"], |
| 984 | contents: [ |
| 985 | "mysdklibrary", |
| 986 | "mynewsdklibrary", |
| 987 | ], |
| 988 | |
| 989 | hidden_api: { |
| 990 | split_packages: [], |
| 991 | }, |
| 992 | } |
| 993 | |
| 994 | java_sdk_library { |
| 995 | name: "mysdklibrary", |
| 996 | apex_available: ["myapex"], |
| 997 | srcs: ["Test.java"], |
| 998 | shared_library: false, |
| 999 | public: {enabled: true}, |
| 1000 | min_sdk_version: "S", |
| 1001 | } |
| 1002 | |
| 1003 | java_sdk_library { |
| 1004 | name: "mynewsdklibrary", |
| 1005 | apex_available: ["myapex"], |
| 1006 | srcs: ["Test.java"], |
| 1007 | compile_dex: true, |
| 1008 | public: {enabled: true}, |
| 1009 | min_sdk_version: "Tiramisu", |
| 1010 | permitted_packages: ["mynewsdklibrary"], |
| 1011 | } |
| 1012 | `), |
| 1013 | ).RunTest(t) |
| 1014 | |
| 1015 | bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common") |
| 1016 | rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv") |
| 1017 | android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits) |
| 1018 | |
| 1019 | CheckSnapshot(t, result, "mysdk", "", |
| 1020 | checkAndroidBpContents(expectedSdkSnapshot), |
| 1021 | checkAllCopyRules(expectedCopyRules), |
| 1022 | ) |
| 1023 | } |
| 1024 | |
| 1025 | func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) { |
| 1026 | t.Run("target S build", func(t *testing.T) { |
| 1027 | expectedSnapshot := ` |
| 1028 | // This is auto-generated. DO NOT EDIT. |
| 1029 | |
| 1030 | prebuilt_bootclasspath_fragment { |
| 1031 | name: "mybootclasspathfragment", |
| 1032 | prefer: false, |
| 1033 | visibility: ["//visibility:public"], |
| 1034 | apex_available: ["myapex"], |
| 1035 | contents: ["mysdklibrary"], |
| 1036 | hidden_api: { |
| 1037 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 1038 | metadata: "hiddenapi/metadata.csv", |
| 1039 | index: "hiddenapi/index.csv", |
| 1040 | stub_flags: "hiddenapi/stub-flags.csv", |
| 1041 | all_flags: "hiddenapi/all-flags.csv", |
| 1042 | }, |
| 1043 | } |
| 1044 | |
| 1045 | java_sdk_library_import { |
| 1046 | name: "mysdklibrary", |
| 1047 | prefer: false, |
| 1048 | visibility: ["//visibility:public"], |
| 1049 | apex_available: ["myapex"], |
| 1050 | shared_library: false, |
| 1051 | public: { |
| 1052 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 1053 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 1054 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 1055 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 1056 | sdk_version: "current", |
| 1057 | }, |
| 1058 | } |
| 1059 | ` |
| 1060 | expectedCopyRules := ` |
| 1061 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 1062 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/metadata.csv -> hiddenapi/metadata.csv |
| 1063 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/index.csv -> hiddenapi/index.csv |
| 1064 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 1065 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv |
| 1066 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 1067 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 1068 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 1069 | ` |
| 1070 | |
| 1071 | // On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part |
| 1072 | // of the snapshot. |
| 1073 | expectedStubFlagsInputs := []string{ |
| 1074 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", |
| 1075 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", |
| 1076 | } |
| 1077 | |
| 1078 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S", |
| 1079 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "-for-sdk-snapshot") |
| 1080 | }) |
| 1081 | |
| 1082 | t.Run("target-Tiramisu-build", func(t *testing.T) { |
| 1083 | expectedSnapshot := ` |
| 1084 | // This is auto-generated. DO NOT EDIT. |
| 1085 | |
| 1086 | prebuilt_bootclasspath_fragment { |
| 1087 | name: "mybootclasspathfragment", |
| 1088 | prefer: false, |
| 1089 | visibility: ["//visibility:public"], |
| 1090 | apex_available: ["myapex"], |
| 1091 | contents: [ |
| 1092 | "mysdklibrary", |
| 1093 | "mynewsdklibrary", |
| 1094 | ], |
| 1095 | hidden_api: { |
| 1096 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 1097 | metadata: "hiddenapi/metadata.csv", |
| 1098 | index: "hiddenapi/index.csv", |
| 1099 | signature_patterns: "hiddenapi/signature-patterns.csv", |
| 1100 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 1101 | filtered_flags: "hiddenapi/filtered-flags.csv", |
| 1102 | }, |
| 1103 | } |
| 1104 | |
| 1105 | java_sdk_library_import { |
| 1106 | name: "mysdklibrary", |
| 1107 | prefer: false, |
| 1108 | visibility: ["//visibility:public"], |
| 1109 | apex_available: ["myapex"], |
| 1110 | shared_library: false, |
| 1111 | public: { |
| 1112 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 1113 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 1114 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 1115 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 1116 | sdk_version: "current", |
| 1117 | }, |
| 1118 | } |
| 1119 | |
| 1120 | java_sdk_library_import { |
| 1121 | name: "mynewsdklibrary", |
| 1122 | prefer: false, |
| 1123 | visibility: ["//visibility:public"], |
| 1124 | apex_available: ["myapex"], |
| 1125 | shared_library: true, |
| 1126 | compile_dex: true, |
| 1127 | permitted_packages: ["mynewsdklibrary"], |
| 1128 | public: { |
| 1129 | jars: ["sdk_library/public/mynewsdklibrary-stubs.jar"], |
| 1130 | stub_srcs: ["sdk_library/public/mynewsdklibrary_stub_sources"], |
| 1131 | current_api: "sdk_library/public/mynewsdklibrary.txt", |
| 1132 | removed_api: "sdk_library/public/mynewsdklibrary-removed.txt", |
| 1133 | sdk_version: "current", |
| 1134 | }, |
| 1135 | } |
| 1136 | ` |
| 1137 | expectedCopyRules := ` |
| 1138 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 1139 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 1140 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 1141 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 1142 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 1143 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
| 1144 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 1145 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 1146 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 1147 | .intermediates/mynewsdklibrary.stubs/android_common/javac/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar |
| 1148 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt |
| 1149 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt |
| 1150 | ` |
| 1151 | |
| 1152 | // On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as |
| 1153 | // they are both part of the snapshot. |
| 1154 | expectedStubFlagsInputs := []string{ |
| 1155 | "out/soong/.intermediates/mynewsdklibrary.stubs/android_common/dex/mynewsdklibrary.stubs.jar", |
| 1156 | "out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar", |
| 1157 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", |
| 1158 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", |
| 1159 | } |
| 1160 | |
| 1161 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu", |
| 1162 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "") |
| 1163 | }) |
| 1164 | } |