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 | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 18 | "fmt" |
| 19 | "path/filepath" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 20 | "testing" |
| 21 | |
| 22 | "android/soong/android" |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 23 | "android/soong/java" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 24 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 25 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 26 | // fixtureAddPlatformBootclasspathForBootclasspathFragment adds a platform_bootclasspath module that |
| 27 | // references the bootclasspath fragment. |
| 28 | func fixtureAddPlatformBootclasspathForBootclasspathFragment(apex, fragment string) android.FixturePreparer { |
| 29 | return android.GroupFixturePreparers( |
| 30 | // Add a platform_bootclasspath module. |
| 31 | android.FixtureAddTextFile("frameworks/base/boot/Android.bp", fmt.Sprintf(` |
| 32 | platform_bootclasspath { |
| 33 | name: "platform-bootclasspath", |
| 34 | fragments: [ |
| 35 | { |
| 36 | apex: "%s", |
| 37 | module: "%s", |
| 38 | }, |
| 39 | ], |
| 40 | } |
| 41 | `, apex, fragment)), |
| 42 | android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil), |
Paul Duffin | e112547 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 43 | android.FixtureAddFile("build/soong/scripts/check_boot_jars/package_allowed_list.txt", nil), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 44 | ) |
| 45 | } |
| 46 | |
| 47 | // fixtureAddPrebuiltApexForBootclasspathFragment adds a prebuilt_apex that exports the fragment. |
| 48 | func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) android.FixturePreparer { |
| 49 | apexFile := fmt.Sprintf("%s.apex", apex) |
| 50 | dir := "prebuilts/apex" |
| 51 | return android.GroupFixturePreparers( |
| 52 | // A preparer to add a prebuilt apex to the test fixture. |
| 53 | android.FixtureAddTextFile(filepath.Join(dir, "Android.bp"), fmt.Sprintf(` |
| 54 | prebuilt_apex { |
| 55 | name: "%s", |
| 56 | src: "%s", |
| 57 | exported_bootclasspath_fragments: [ |
| 58 | "%s", |
| 59 | ], |
| 60 | } |
| 61 | `, apex, apexFile, fragment)), |
| 62 | android.FixtureAddFile(filepath.Join(dir, apexFile), nil), |
| 63 | ) |
| 64 | } |
| 65 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 66 | func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) { |
| 67 | result := android.GroupFixturePreparers( |
| 68 | prepareForSdkTestWithJava, |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 69 | java.PrepareForTestWithJavaDefaultModules, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 70 | prepareForSdkTestWithApex, |
| 71 | |
| 72 | // Some additional files needed for the art apex. |
| 73 | android.FixtureMergeMockFs(android.MockFS{ |
| 74 | "com.android.art.avbpubkey": nil, |
| 75 | "com.android.art.pem": nil, |
| 76 | "system/sepolicy/apex/com.android.art-file_contexts": nil, |
| 77 | }), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 78 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 79 | // Add a platform_bootclasspath that depends on the fragment. |
| 80 | fixtureAddPlatformBootclasspathForBootclasspathFragment("com.android.art", "mybootclasspathfragment"), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 81 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 82 | java.FixtureConfigureBootJars("com.android.art:mybootlib"), |
| 83 | android.FixtureWithRootAndroidBp(` |
| 84 | sdk { |
| 85 | name: "mysdk", |
| 86 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | apex { |
| 90 | name: "com.android.art", |
| 91 | key: "com.android.art.key", |
| 92 | bootclasspath_fragments: [ |
| 93 | "mybootclasspathfragment", |
| 94 | ], |
| 95 | updatable: false, |
| 96 | } |
| 97 | |
| 98 | bootclasspath_fragment { |
| 99 | name: "mybootclasspathfragment", |
| 100 | image_name: "art", |
Paul Duffin | f23bc47 | 2021-04-27 12:42:20 +0100 | [diff] [blame] | 101 | contents: ["mybootlib"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 102 | apex_available: ["com.android.art"], |
| 103 | } |
| 104 | |
| 105 | apex_key { |
| 106 | name: "com.android.art.key", |
| 107 | public_key: "com.android.art.avbpubkey", |
| 108 | private_key: "com.android.art.pem", |
| 109 | } |
| 110 | |
| 111 | java_library { |
| 112 | name: "mybootlib", |
| 113 | srcs: ["Test.java"], |
| 114 | system_modules: "none", |
| 115 | sdk_version: "none", |
| 116 | compile_dex: true, |
| 117 | apex_available: ["com.android.art"], |
| 118 | } |
| 119 | `), |
| 120 | ).RunTest(t) |
| 121 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 122 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 123 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment") |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 124 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 125 | CheckSnapshot(t, result, "mysdk", "", |
| 126 | checkUnversionedAndroidBpContents(` |
| 127 | // This is auto-generated. DO NOT EDIT. |
| 128 | |
| 129 | prebuilt_bootclasspath_fragment { |
| 130 | name: "mybootclasspathfragment", |
| 131 | prefer: false, |
| 132 | visibility: ["//visibility:public"], |
| 133 | apex_available: ["com.android.art"], |
| 134 | image_name: "art", |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 135 | contents: ["mybootlib"], |
Paul Duffin | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 136 | hidden_api: { |
| 137 | stub_flags: "hiddenapi/stub-flags.csv", |
| 138 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 139 | metadata: "hiddenapi/metadata.csv", |
| 140 | index: "hiddenapi/index.csv", |
| 141 | all_flags: "hiddenapi/all-flags.csv", |
| 142 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | java_import { |
| 146 | name: "mybootlib", |
| 147 | prefer: false, |
| 148 | visibility: ["//visibility:public"], |
| 149 | apex_available: ["com.android.art"], |
| 150 | jars: ["java/mybootlib.jar"], |
| 151 | } |
| 152 | `), |
| 153 | checkVersionedAndroidBpContents(` |
| 154 | // This is auto-generated. DO NOT EDIT. |
| 155 | |
| 156 | prebuilt_bootclasspath_fragment { |
| 157 | name: "mysdk_mybootclasspathfragment@current", |
| 158 | sdk_member_name: "mybootclasspathfragment", |
| 159 | visibility: ["//visibility:public"], |
| 160 | apex_available: ["com.android.art"], |
| 161 | image_name: "art", |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 162 | contents: ["mysdk_mybootlib@current"], |
Paul Duffin | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 163 | hidden_api: { |
| 164 | stub_flags: "hiddenapi/stub-flags.csv", |
| 165 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 166 | metadata: "hiddenapi/metadata.csv", |
| 167 | index: "hiddenapi/index.csv", |
| 168 | all_flags: "hiddenapi/all-flags.csv", |
| 169 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | java_import { |
| 173 | name: "mysdk_mybootlib@current", |
| 174 | sdk_member_name: "mybootlib", |
| 175 | visibility: ["//visibility:public"], |
| 176 | apex_available: ["com.android.art"], |
| 177 | jars: ["java/mybootlib.jar"], |
| 178 | } |
| 179 | |
| 180 | sdk_snapshot { |
| 181 | name: "mysdk@current", |
| 182 | visibility: ["//visibility:public"], |
| 183 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
| 184 | java_boot_libs: ["mysdk_mybootlib@current"], |
| 185 | } |
| 186 | `), |
| 187 | checkAllCopyRules(` |
Paul Duffin | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 188 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 189 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 190 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 191 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 192 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 193 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 194 | `), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 195 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | e112547 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 196 | |
| 197 | // Check the behavior of the snapshot without the source. |
| 198 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 199 | // Make sure that the boot jars package check rule includes the dex jar retrieved from the prebuilt apex. |
| 200 | checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/mybootlib.jar") |
| 201 | }), |
| 202 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 203 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 204 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 205 | ) |
Paul Duffin | e112547 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 206 | |
| 207 | // Make sure that the boot jars package check rule includes the dex jar created from the source. |
| 208 | checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/mybootlib/android_common_apex10000/aligned/mybootlib.jar") |
| 209 | } |
| 210 | |
| 211 | // checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars |
| 212 | // package check rule. |
| 213 | func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModule string) { |
| 214 | platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 215 | bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check") |
| 216 | command := bootJarsCheckRule.RuleParams.Command |
| 217 | expectedCommandArgs := " out/soong/host/linux-x86/bin/dexdump build/soong/scripts/check_boot_jars/package_allowed_list.txt " + expectedModule + " &&" |
| 218 | android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs) |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 222 | result := android.GroupFixturePreparers( |
| 223 | prepareForSdkTestWithJava, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 224 | java.PrepareForTestWithJavaDefaultModules, |
| 225 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 226 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 227 | java.FixtureConfigureUpdatableBootJars("myapex:mybootlib", "myapex:myothersdklibrary"), |
| 228 | prepareForSdkTestWithApex, |
| 229 | |
| 230 | // Add a platform_bootclasspath that depends on the fragment. |
| 231 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 232 | |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 233 | android.FixtureWithRootAndroidBp(` |
| 234 | sdk { |
| 235 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 236 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 237 | java_sdk_libs: [ |
| 238 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 239 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 240 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 241 | // correctly deduped. |
| 242 | "mysdklibrary", |
| 243 | ], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 244 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 245 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 246 | apex { |
| 247 | name: "myapex", |
| 248 | key: "myapex.key", |
| 249 | min_sdk_version: "2", |
| 250 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 251 | } |
| 252 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 253 | bootclasspath_fragment { |
| 254 | name: "mybootclasspathfragment", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 255 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 256 | contents: [ |
| 257 | // This should be automatically added to the sdk_snapshot as a java_boot_libs module. |
| 258 | "mybootlib", |
| 259 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. |
| 260 | "myothersdklibrary", |
| 261 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 262 | api: { |
| 263 | stub_libs: ["mysdklibrary"], |
| 264 | }, |
| 265 | core_platform_api: { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 266 | // 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] | 267 | stub_libs: ["mycoreplatform"], |
| 268 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | java_library { |
| 272 | name: "mybootlib", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 273 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 274 | srcs: ["Test.java"], |
| 275 | system_modules: "none", |
| 276 | sdk_version: "none", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 277 | min_sdk_version: "2", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 278 | compile_dex: true, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 279 | permitted_packages: ["mybootlib"], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 280 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 281 | |
| 282 | java_sdk_library { |
| 283 | name: "mysdklibrary", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 284 | apex_available: ["myapex"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 285 | srcs: ["Test.java"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 286 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 287 | public: {enabled: true}, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 288 | min_sdk_version: "2", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | java_sdk_library { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 292 | name: "myothersdklibrary", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 293 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 294 | srcs: ["Test.java"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 295 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 296 | public: {enabled: true}, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 297 | min_sdk_version: "2", |
| 298 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | java_sdk_library { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 302 | name: "mycoreplatform", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 303 | apex_available: ["myapex"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 304 | srcs: ["Test.java"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 305 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 306 | public: {enabled: true}, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 307 | min_sdk_version: "2", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 308 | } |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 309 | `), |
| 310 | ).RunTest(t) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 311 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 312 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 313 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 314 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 315 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 316 | checkUnversionedAndroidBpContents(` |
| 317 | // This is auto-generated. DO NOT EDIT. |
| 318 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 319 | prebuilt_bootclasspath_fragment { |
| 320 | name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 321 | prefer: false, |
| 322 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 323 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 324 | contents: [ |
| 325 | "mybootlib", |
| 326 | "myothersdklibrary", |
| 327 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 328 | api: { |
| 329 | stub_libs: ["mysdklibrary"], |
| 330 | }, |
| 331 | core_platform_api: { |
| 332 | stub_libs: ["mycoreplatform"], |
| 333 | }, |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 334 | hidden_api: { |
| 335 | stub_flags: "hiddenapi/stub-flags.csv", |
| 336 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 337 | metadata: "hiddenapi/metadata.csv", |
| 338 | index: "hiddenapi/index.csv", |
| 339 | all_flags: "hiddenapi/all-flags.csv", |
| 340 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | java_import { |
| 344 | name: "mybootlib", |
| 345 | prefer: false, |
| 346 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 347 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 348 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 7b3e10a | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 349 | permitted_packages: ["mybootlib"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 350 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 351 | |
| 352 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 353 | name: "myothersdklibrary", |
| 354 | prefer: false, |
| 355 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 356 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 357 | shared_library: true, |
| 358 | compile_dex: true, |
Paul Duffin | 7b3e10a | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 359 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 360 | public: { |
| 361 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 362 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 363 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 364 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 365 | sdk_version: "current", |
| 366 | }, |
| 367 | } |
| 368 | |
| 369 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 370 | name: "mysdklibrary", |
| 371 | prefer: false, |
| 372 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 373 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 374 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 375 | public: { |
| 376 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 377 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 378 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 379 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 380 | sdk_version: "current", |
| 381 | }, |
| 382 | } |
| 383 | |
| 384 | java_sdk_library_import { |
| 385 | name: "mycoreplatform", |
| 386 | prefer: false, |
| 387 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 388 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 389 | shared_library: true, |
| 390 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 391 | public: { |
| 392 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 393 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 394 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 395 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 396 | sdk_version: "current", |
| 397 | }, |
| 398 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 399 | `), |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 400 | checkVersionedAndroidBpContents(` |
| 401 | // This is auto-generated. DO NOT EDIT. |
| 402 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 403 | prebuilt_bootclasspath_fragment { |
| 404 | name: "mysdk_mybootclasspathfragment@current", |
| 405 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 406 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 407 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 408 | contents: [ |
| 409 | "mysdk_mybootlib@current", |
| 410 | "mysdk_myothersdklibrary@current", |
| 411 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 412 | api: { |
| 413 | stub_libs: ["mysdk_mysdklibrary@current"], |
| 414 | }, |
| 415 | core_platform_api: { |
| 416 | stub_libs: ["mysdk_mycoreplatform@current"], |
| 417 | }, |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 418 | hidden_api: { |
| 419 | stub_flags: "hiddenapi/stub-flags.csv", |
| 420 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 421 | metadata: "hiddenapi/metadata.csv", |
| 422 | index: "hiddenapi/index.csv", |
| 423 | all_flags: "hiddenapi/all-flags.csv", |
| 424 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | java_import { |
| 428 | name: "mysdk_mybootlib@current", |
| 429 | sdk_member_name: "mybootlib", |
| 430 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 431 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 432 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 7b3e10a | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 433 | permitted_packages: ["mybootlib"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 434 | } |
| 435 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 436 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 437 | name: "mysdk_myothersdklibrary@current", |
| 438 | sdk_member_name: "myothersdklibrary", |
| 439 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 440 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 441 | shared_library: true, |
| 442 | compile_dex: true, |
Paul Duffin | 7b3e10a | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 443 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 444 | public: { |
| 445 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 446 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 447 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 448 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 449 | sdk_version: "current", |
| 450 | }, |
| 451 | } |
| 452 | |
| 453 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 454 | name: "mysdk_mysdklibrary@current", |
| 455 | sdk_member_name: "mysdklibrary", |
| 456 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 457 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 458 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 459 | public: { |
| 460 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 461 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 462 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 463 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 464 | sdk_version: "current", |
| 465 | }, |
| 466 | } |
| 467 | |
| 468 | java_sdk_library_import { |
| 469 | name: "mysdk_mycoreplatform@current", |
| 470 | sdk_member_name: "mycoreplatform", |
| 471 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 472 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 473 | shared_library: true, |
| 474 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 475 | public: { |
| 476 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 477 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 478 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 479 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 480 | sdk_version: "current", |
| 481 | }, |
| 482 | } |
| 483 | |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 484 | sdk_snapshot { |
| 485 | name: "mysdk@current", |
| 486 | visibility: ["//visibility:public"], |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 487 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 488 | java_boot_libs: ["mysdk_mybootlib@current"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 489 | java_sdk_libs: [ |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 490 | "mysdk_myothersdklibrary@current", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 491 | "mysdk_mysdklibrary@current", |
| 492 | "mysdk_mycoreplatform@current", |
| 493 | ], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 494 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 495 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 496 | checkAllCopyRules(` |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 497 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 498 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 499 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 500 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 501 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 502 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 503 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 504 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 505 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 506 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 507 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 508 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 509 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 510 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 511 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 512 | `), |
| 513 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | 2a99933 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 514 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 515 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 516 | var rule android.TestingBuildParams |
| 517 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") |
| 518 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` |
| 519 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv |
| 520 | out/soong/hiddenapi/hiddenapi-stub-flags.txt |
| 521 | snapshot/hiddenapi/annotation-flags.csv |
| 522 | `, rule) |
| 523 | |
| 524 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") |
| 525 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` |
| 526 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv |
| 527 | snapshot/hiddenapi/metadata.csv |
| 528 | `, rule) |
| 529 | |
| 530 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") |
| 531 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` |
| 532 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv |
| 533 | snapshot/hiddenapi/index.csv |
| 534 | `, rule) |
Paul Duffin | dbcc296 | 2021-07-15 13:35:26 +0100 | [diff] [blame^] | 535 | |
| 536 | // Make sure that the permitted packages from the prebuilts end up in the |
| 537 | // updatable-bcp-packages.txt file. |
| 538 | rule = module.Output("updatable-bcp-packages.txt") |
| 539 | expectedContents := `'mybootlib\nmyothersdklibrary\n'` |
| 540 | android.AssertStringEquals(t, "updatable-bcp-packages.txt", expectedContents, rule.Args["content"]) |
Paul Duffin | 2a99933 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 541 | }), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 542 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 543 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 544 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 545 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 546 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 547 | // Test that bootclasspath_fragment works with sdk. |
| 548 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 549 | android.GroupFixturePreparers( |
| 550 | prepareForSdkTestWithApex, |
| 551 | prepareForSdkTestWithJava, |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 552 | android.FixtureAddFile("java/mybootlib.jar", nil), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 553 | android.FixtureWithRootAndroidBp(` |
| 554 | sdk { |
| 555 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 556 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 557 | } |
| 558 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 559 | bootclasspath_fragment { |
| 560 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 561 | image_name: "art", |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 562 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 563 | apex_available: ["myapex"], |
| 564 | } |
| 565 | |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 566 | java_library { |
| 567 | name: "mybootlib", |
| 568 | apex_available: ["myapex"], |
| 569 | srcs: ["Test.java"], |
| 570 | system_modules: "none", |
| 571 | sdk_version: "none", |
| 572 | min_sdk_version: "1", |
| 573 | compile_dex: true, |
| 574 | } |
| 575 | |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 576 | sdk_snapshot { |
| 577 | name: "mysdk@1", |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 578 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 579 | } |
| 580 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 581 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 582 | name: "mysdk_mybootclasspathfragment@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 583 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 584 | prefer: false, |
| 585 | visibility: ["//visibility:public"], |
| 586 | apex_available: [ |
| 587 | "myapex", |
| 588 | ], |
| 589 | image_name: "art", |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 590 | contents: ["mysdk_mybootlib@1"], |
| 591 | } |
| 592 | |
| 593 | java_import { |
| 594 | name: "mysdk_mybootlib@1", |
| 595 | sdk_member_name: "mybootlib", |
| 596 | visibility: ["//visibility:public"], |
| 597 | apex_available: ["com.android.art"], |
| 598 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 599 | } |
| 600 | `), |
| 601 | ).RunTest(t) |
| 602 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 603 | |
| 604 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 605 | result := android.GroupFixturePreparers( |
| 606 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 607 | java.PrepareForTestWithJavaDefaultModules, |
| 608 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 609 | java.FixtureWithLastReleaseApis("mysdklibrary"), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 610 | java.FixtureConfigureUpdatableBootJars("myapex:mybootlib"), |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 611 | prepareForSdkTestWithApex, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 612 | |
| 613 | // Add a platform_bootclasspath that depends on the fragment. |
| 614 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 615 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 616 | android.MockFS{ |
| 617 | "my-blocked.txt": nil, |
| 618 | "my-max-target-o-low-priority.txt": nil, |
| 619 | "my-max-target-p.txt": nil, |
| 620 | "my-max-target-q.txt": nil, |
| 621 | "my-max-target-r-low-priority.txt": nil, |
| 622 | "my-removed.txt": nil, |
| 623 | "my-unsupported-packages.txt": nil, |
| 624 | "my-unsupported.txt": nil, |
| 625 | }.AddToFixture(), |
| 626 | android.FixtureWithRootAndroidBp(` |
| 627 | sdk { |
| 628 | name: "mysdk", |
| 629 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 630 | } |
| 631 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 632 | apex { |
| 633 | name: "myapex", |
| 634 | key: "myapex.key", |
| 635 | min_sdk_version: "1", |
| 636 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 637 | } |
| 638 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 639 | bootclasspath_fragment { |
| 640 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 641 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 642 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 643 | api: { |
| 644 | stub_libs: ["mysdklibrary"], |
| 645 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 646 | hidden_api: { |
| 647 | unsupported: [ |
| 648 | "my-unsupported.txt", |
| 649 | ], |
| 650 | removed: [ |
| 651 | "my-removed.txt", |
| 652 | ], |
| 653 | max_target_r_low_priority: [ |
| 654 | "my-max-target-r-low-priority.txt", |
| 655 | ], |
| 656 | max_target_q: [ |
| 657 | "my-max-target-q.txt", |
| 658 | ], |
| 659 | max_target_p: [ |
| 660 | "my-max-target-p.txt", |
| 661 | ], |
| 662 | max_target_o_low_priority: [ |
| 663 | "my-max-target-o-low-priority.txt", |
| 664 | ], |
| 665 | blocked: [ |
| 666 | "my-blocked.txt", |
| 667 | ], |
| 668 | unsupported_packages: [ |
| 669 | "my-unsupported-packages.txt", |
| 670 | ], |
| 671 | }, |
| 672 | } |
| 673 | |
| 674 | java_library { |
| 675 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 676 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 677 | srcs: ["Test.java"], |
| 678 | system_modules: "none", |
| 679 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 680 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 681 | compile_dex: true, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 682 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 683 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 684 | |
| 685 | java_sdk_library { |
| 686 | name: "mysdklibrary", |
| 687 | srcs: ["Test.java"], |
| 688 | compile_dex: true, |
| 689 | public: {enabled: true}, |
Paul Duffin | 7b3e10a | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 690 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 691 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 692 | `), |
| 693 | ).RunTest(t) |
| 694 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 695 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 696 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 697 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 698 | CheckSnapshot(t, result, "mysdk", "", |
| 699 | checkUnversionedAndroidBpContents(` |
| 700 | // This is auto-generated. DO NOT EDIT. |
| 701 | |
| 702 | prebuilt_bootclasspath_fragment { |
| 703 | name: "mybootclasspathfragment", |
| 704 | prefer: false, |
| 705 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 706 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 707 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 708 | api: { |
| 709 | stub_libs: ["mysdklibrary"], |
| 710 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 711 | hidden_api: { |
| 712 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 713 | removed: ["hiddenapi/my-removed.txt"], |
| 714 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 715 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 716 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 717 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 718 | blocked: ["hiddenapi/my-blocked.txt"], |
| 719 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 720 | stub_flags: "hiddenapi/stub-flags.csv", |
| 721 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 722 | metadata: "hiddenapi/metadata.csv", |
| 723 | index: "hiddenapi/index.csv", |
| 724 | all_flags: "hiddenapi/all-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 725 | }, |
| 726 | } |
| 727 | |
| 728 | java_import { |
| 729 | name: "mybootlib", |
| 730 | prefer: false, |
| 731 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 732 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 733 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 7b3e10a | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 734 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 735 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 736 | |
| 737 | java_sdk_library_import { |
| 738 | name: "mysdklibrary", |
| 739 | prefer: false, |
| 740 | visibility: ["//visibility:public"], |
| 741 | apex_available: ["//apex_available:platform"], |
| 742 | shared_library: true, |
| 743 | compile_dex: true, |
Paul Duffin | 7b3e10a | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 744 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 745 | public: { |
| 746 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 747 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 748 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 749 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 750 | sdk_version: "current", |
| 751 | }, |
| 752 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 753 | `), |
| 754 | checkAllCopyRules(` |
| 755 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 756 | my-removed.txt -> hiddenapi/my-removed.txt |
| 757 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 758 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 759 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 760 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 761 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 762 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 763 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 764 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 765 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 766 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 767 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 768 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 769 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 770 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 771 | .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] | 772 | `), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 773 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 774 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 775 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 776 | ) |
| 777 | } |