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 ( |
| 18 | "testing" |
| 19 | |
| 20 | "android/soong/android" |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 21 | "android/soong/java" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 22 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 23 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 24 | func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) { |
| 25 | result := android.GroupFixturePreparers( |
| 26 | prepareForSdkTestWithJava, |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 27 | java.PrepareForTestWithJavaDefaultModules, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 28 | prepareForSdkTestWithApex, |
| 29 | |
| 30 | // Some additional files needed for the art apex. |
| 31 | android.FixtureMergeMockFs(android.MockFS{ |
| 32 | "com.android.art.avbpubkey": nil, |
| 33 | "com.android.art.pem": nil, |
| 34 | "system/sepolicy/apex/com.android.art-file_contexts": nil, |
| 35 | }), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 36 | |
| 37 | // platform_bootclasspath that depends on the fragment. |
| 38 | android.FixtureAddTextFile("frameworks/base/boot/Android.bp", ` |
| 39 | platform_bootclasspath { |
| 40 | name: "platform-bootclasspath", |
| 41 | fragments: [ |
| 42 | { |
| 43 | apex: "com.android.art", |
| 44 | module: "mybootclasspathfragment", |
| 45 | }, |
| 46 | ], |
| 47 | } |
| 48 | `), |
Paul Duffin | 2ac45f0 | 2021-04-26 17:08:38 +0100 | [diff] [blame] | 49 | // Needed for platform_bootclasspath |
| 50 | android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 51 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 52 | java.FixtureConfigureBootJars("com.android.art:mybootlib"), |
| 53 | android.FixtureWithRootAndroidBp(` |
| 54 | sdk { |
| 55 | name: "mysdk", |
| 56 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | apex { |
| 60 | name: "com.android.art", |
| 61 | key: "com.android.art.key", |
| 62 | bootclasspath_fragments: [ |
| 63 | "mybootclasspathfragment", |
| 64 | ], |
| 65 | updatable: false, |
| 66 | } |
| 67 | |
| 68 | bootclasspath_fragment { |
| 69 | name: "mybootclasspathfragment", |
| 70 | image_name: "art", |
Paul Duffin | f23bc47 | 2021-04-27 12:42:20 +0100 | [diff] [blame] | 71 | contents: ["mybootlib"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 72 | apex_available: ["com.android.art"], |
| 73 | } |
| 74 | |
| 75 | apex_key { |
| 76 | name: "com.android.art.key", |
| 77 | public_key: "com.android.art.avbpubkey", |
| 78 | private_key: "com.android.art.pem", |
| 79 | } |
| 80 | |
| 81 | java_library { |
| 82 | name: "mybootlib", |
| 83 | srcs: ["Test.java"], |
| 84 | system_modules: "none", |
| 85 | sdk_version: "none", |
| 86 | compile_dex: true, |
| 87 | apex_available: ["com.android.art"], |
| 88 | } |
| 89 | `), |
| 90 | ).RunTest(t) |
| 91 | |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 92 | // A preparer to add a prebuilt apex to the test fixture. |
| 93 | prepareWithPrebuiltApex := android.GroupFixturePreparers( |
| 94 | android.FixtureAddTextFile("prebuilts/apex/Android.bp", ` |
| 95 | prebuilt_apex { |
| 96 | name: "com.android.art", |
| 97 | src: "art.apex", |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 98 | exported_bootclasspath_fragments: [ |
| 99 | "mybootclasspathfragment", |
| 100 | ], |
| 101 | } |
| 102 | `), |
| 103 | android.FixtureAddFile("prebuilts/apex/art.apex", nil), |
| 104 | ) |
| 105 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 106 | CheckSnapshot(t, result, "mysdk", "", |
| 107 | checkUnversionedAndroidBpContents(` |
| 108 | // This is auto-generated. DO NOT EDIT. |
| 109 | |
| 110 | prebuilt_bootclasspath_fragment { |
| 111 | name: "mybootclasspathfragment", |
| 112 | prefer: false, |
| 113 | visibility: ["//visibility:public"], |
| 114 | apex_available: ["com.android.art"], |
| 115 | image_name: "art", |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 116 | contents: ["mybootlib"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | java_import { |
| 120 | name: "mybootlib", |
| 121 | prefer: false, |
| 122 | visibility: ["//visibility:public"], |
| 123 | apex_available: ["com.android.art"], |
| 124 | jars: ["java/mybootlib.jar"], |
| 125 | } |
| 126 | `), |
| 127 | checkVersionedAndroidBpContents(` |
| 128 | // This is auto-generated. DO NOT EDIT. |
| 129 | |
| 130 | prebuilt_bootclasspath_fragment { |
| 131 | name: "mysdk_mybootclasspathfragment@current", |
| 132 | sdk_member_name: "mybootclasspathfragment", |
| 133 | visibility: ["//visibility:public"], |
| 134 | apex_available: ["com.android.art"], |
| 135 | image_name: "art", |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 136 | contents: ["mysdk_mybootlib@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | java_import { |
| 140 | name: "mysdk_mybootlib@current", |
| 141 | sdk_member_name: "mybootlib", |
| 142 | visibility: ["//visibility:public"], |
| 143 | apex_available: ["com.android.art"], |
| 144 | jars: ["java/mybootlib.jar"], |
| 145 | } |
| 146 | |
| 147 | sdk_snapshot { |
| 148 | name: "mysdk@current", |
| 149 | visibility: ["//visibility:public"], |
| 150 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
| 151 | java_boot_libs: ["mysdk_mybootlib@current"], |
| 152 | } |
| 153 | `), |
| 154 | checkAllCopyRules(` |
| 155 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
| 156 | `), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 157 | snapshotTestPreparer(checkSnapshotWithoutSource, prepareWithPrebuiltApex), |
| 158 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, prepareWithPrebuiltApex), |
| 159 | snapshotTestPreparer(checkSnapshotPreferredWithSource, prepareWithPrebuiltApex), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 160 | ) |
| 161 | } |
| 162 | |
| 163 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 164 | result := android.GroupFixturePreparers( |
| 165 | prepareForSdkTestWithJava, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 166 | java.PrepareForTestWithJavaDefaultModules, |
| 167 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 168 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 169 | android.FixtureWithRootAndroidBp(` |
| 170 | sdk { |
| 171 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 172 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 173 | java_sdk_libs: [ |
| 174 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 175 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 176 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 177 | // correctly deduped. |
| 178 | "mysdklibrary", |
| 179 | ], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 180 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 181 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 182 | bootclasspath_fragment { |
| 183 | name: "mybootclasspathfragment", |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 184 | contents: [ |
| 185 | // This should be automatically added to the sdk_snapshot as a java_boot_libs module. |
| 186 | "mybootlib", |
| 187 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. |
| 188 | "myothersdklibrary", |
| 189 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 190 | api: { |
| 191 | stub_libs: ["mysdklibrary"], |
| 192 | }, |
| 193 | core_platform_api: { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 194 | // 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] | 195 | stub_libs: ["mycoreplatform"], |
| 196 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | java_library { |
| 200 | name: "mybootlib", |
| 201 | srcs: ["Test.java"], |
| 202 | system_modules: "none", |
| 203 | sdk_version: "none", |
| 204 | compile_dex: true, |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 205 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 206 | |
| 207 | java_sdk_library { |
| 208 | name: "mysdklibrary", |
| 209 | srcs: ["Test.java"], |
| 210 | compile_dex: true, |
| 211 | public: {enabled: true}, |
| 212 | } |
| 213 | |
| 214 | java_sdk_library { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 215 | name: "myothersdklibrary", |
| 216 | srcs: ["Test.java"], |
| 217 | compile_dex: true, |
| 218 | public: {enabled: true}, |
| 219 | } |
| 220 | |
| 221 | java_sdk_library { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 222 | name: "mycoreplatform", |
| 223 | srcs: ["Test.java"], |
| 224 | compile_dex: true, |
| 225 | public: {enabled: true}, |
| 226 | } |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 227 | `), |
| 228 | ).RunTest(t) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 229 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 230 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 231 | checkUnversionedAndroidBpContents(` |
| 232 | // This is auto-generated. DO NOT EDIT. |
| 233 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 234 | prebuilt_bootclasspath_fragment { |
| 235 | name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 236 | prefer: false, |
| 237 | visibility: ["//visibility:public"], |
| 238 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 239 | contents: [ |
| 240 | "mybootlib", |
| 241 | "myothersdklibrary", |
| 242 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 243 | api: { |
| 244 | stub_libs: ["mysdklibrary"], |
| 245 | }, |
| 246 | core_platform_api: { |
| 247 | stub_libs: ["mycoreplatform"], |
| 248 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | java_import { |
| 252 | name: "mybootlib", |
| 253 | prefer: false, |
| 254 | visibility: ["//visibility:public"], |
| 255 | apex_available: ["//apex_available:platform"], |
| 256 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 257 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 258 | |
| 259 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 260 | name: "myothersdklibrary", |
| 261 | prefer: false, |
| 262 | visibility: ["//visibility:public"], |
| 263 | apex_available: ["//apex_available:platform"], |
| 264 | shared_library: true, |
| 265 | compile_dex: true, |
| 266 | public: { |
| 267 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 268 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 269 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 270 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 271 | sdk_version: "current", |
| 272 | }, |
| 273 | } |
| 274 | |
| 275 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 276 | name: "mysdklibrary", |
| 277 | prefer: false, |
| 278 | visibility: ["//visibility:public"], |
| 279 | apex_available: ["//apex_available:platform"], |
| 280 | shared_library: true, |
| 281 | compile_dex: true, |
| 282 | public: { |
| 283 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 284 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 285 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 286 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 287 | sdk_version: "current", |
| 288 | }, |
| 289 | } |
| 290 | |
| 291 | java_sdk_library_import { |
| 292 | name: "mycoreplatform", |
| 293 | prefer: false, |
| 294 | visibility: ["//visibility:public"], |
| 295 | apex_available: ["//apex_available:platform"], |
| 296 | shared_library: true, |
| 297 | compile_dex: true, |
| 298 | public: { |
| 299 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 300 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 301 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 302 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 303 | sdk_version: "current", |
| 304 | }, |
| 305 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 306 | `), |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 307 | checkVersionedAndroidBpContents(` |
| 308 | // This is auto-generated. DO NOT EDIT. |
| 309 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 310 | prebuilt_bootclasspath_fragment { |
| 311 | name: "mysdk_mybootclasspathfragment@current", |
| 312 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 313 | visibility: ["//visibility:public"], |
| 314 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 315 | contents: [ |
| 316 | "mysdk_mybootlib@current", |
| 317 | "mysdk_myothersdklibrary@current", |
| 318 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 319 | api: { |
| 320 | stub_libs: ["mysdk_mysdklibrary@current"], |
| 321 | }, |
| 322 | core_platform_api: { |
| 323 | stub_libs: ["mysdk_mycoreplatform@current"], |
| 324 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | java_import { |
| 328 | name: "mysdk_mybootlib@current", |
| 329 | sdk_member_name: "mybootlib", |
| 330 | visibility: ["//visibility:public"], |
| 331 | apex_available: ["//apex_available:platform"], |
| 332 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 335 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 336 | name: "mysdk_myothersdklibrary@current", |
| 337 | sdk_member_name: "myothersdklibrary", |
| 338 | visibility: ["//visibility:public"], |
| 339 | apex_available: ["//apex_available:platform"], |
| 340 | shared_library: true, |
| 341 | compile_dex: true, |
| 342 | public: { |
| 343 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 344 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 345 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 346 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 347 | sdk_version: "current", |
| 348 | }, |
| 349 | } |
| 350 | |
| 351 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 352 | name: "mysdk_mysdklibrary@current", |
| 353 | sdk_member_name: "mysdklibrary", |
| 354 | visibility: ["//visibility:public"], |
| 355 | apex_available: ["//apex_available:platform"], |
| 356 | shared_library: true, |
| 357 | compile_dex: true, |
| 358 | public: { |
| 359 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 360 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 361 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 362 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 363 | sdk_version: "current", |
| 364 | }, |
| 365 | } |
| 366 | |
| 367 | java_sdk_library_import { |
| 368 | name: "mysdk_mycoreplatform@current", |
| 369 | sdk_member_name: "mycoreplatform", |
| 370 | visibility: ["//visibility:public"], |
| 371 | apex_available: ["//apex_available:platform"], |
| 372 | shared_library: true, |
| 373 | compile_dex: true, |
| 374 | public: { |
| 375 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 376 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 377 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 378 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 379 | sdk_version: "current", |
| 380 | }, |
| 381 | } |
| 382 | |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 383 | sdk_snapshot { |
| 384 | name: "mysdk@current", |
| 385 | visibility: ["//visibility:public"], |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 386 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 387 | java_boot_libs: ["mysdk_mybootlib@current"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 388 | java_sdk_libs: [ |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 389 | "mysdk_myothersdklibrary@current", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 390 | "mysdk_mysdklibrary@current", |
| 391 | "mysdk_mycoreplatform@current", |
| 392 | ], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 393 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 394 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 395 | checkAllCopyRules(` |
| 396 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame^] | 397 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 398 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 399 | .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] | 400 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 401 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 402 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 403 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 404 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 405 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 406 | `)) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 407 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 408 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 409 | // Test that bootclasspath_fragment works with sdk. |
| 410 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 411 | android.GroupFixturePreparers( |
| 412 | prepareForSdkTestWithApex, |
| 413 | prepareForSdkTestWithJava, |
| 414 | android.FixtureWithRootAndroidBp(` |
| 415 | sdk { |
| 416 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 417 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 418 | } |
| 419 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 420 | bootclasspath_fragment { |
| 421 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 422 | image_name: "art", |
| 423 | apex_available: ["myapex"], |
| 424 | } |
| 425 | |
| 426 | sdk_snapshot { |
| 427 | name: "mysdk@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 428 | bootclasspath_fragments: ["mybootclasspathfragment_mysdk_1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 429 | } |
| 430 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 431 | prebuilt_bootclasspath_fragment { |
| 432 | name: "mybootclasspathfragment_mysdk_1", |
| 433 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 434 | prefer: false, |
| 435 | visibility: ["//visibility:public"], |
| 436 | apex_available: [ |
| 437 | "myapex", |
| 438 | ], |
| 439 | image_name: "art", |
| 440 | } |
| 441 | `), |
| 442 | ).RunTest(t) |
| 443 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 444 | |
| 445 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 446 | result := android.GroupFixturePreparers( |
| 447 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 448 | java.PrepareForTestWithJavaDefaultModules, |
| 449 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 450 | java.FixtureWithLastReleaseApis("mysdklibrary"), |
| 451 | prepareForSdkTestWithApex, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 452 | android.MockFS{ |
| 453 | "my-blocked.txt": nil, |
| 454 | "my-max-target-o-low-priority.txt": nil, |
| 455 | "my-max-target-p.txt": nil, |
| 456 | "my-max-target-q.txt": nil, |
| 457 | "my-max-target-r-low-priority.txt": nil, |
| 458 | "my-removed.txt": nil, |
| 459 | "my-unsupported-packages.txt": nil, |
| 460 | "my-unsupported.txt": nil, |
| 461 | }.AddToFixture(), |
| 462 | android.FixtureWithRootAndroidBp(` |
| 463 | sdk { |
| 464 | name: "mysdk", |
| 465 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 466 | } |
| 467 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 468 | apex { |
| 469 | name: "myapex", |
| 470 | key: "myapex.key", |
| 471 | min_sdk_version: "1", |
| 472 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 473 | } |
| 474 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 475 | bootclasspath_fragment { |
| 476 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 477 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 478 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 479 | api: { |
| 480 | stub_libs: ["mysdklibrary"], |
| 481 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 482 | hidden_api: { |
| 483 | unsupported: [ |
| 484 | "my-unsupported.txt", |
| 485 | ], |
| 486 | removed: [ |
| 487 | "my-removed.txt", |
| 488 | ], |
| 489 | max_target_r_low_priority: [ |
| 490 | "my-max-target-r-low-priority.txt", |
| 491 | ], |
| 492 | max_target_q: [ |
| 493 | "my-max-target-q.txt", |
| 494 | ], |
| 495 | max_target_p: [ |
| 496 | "my-max-target-p.txt", |
| 497 | ], |
| 498 | max_target_o_low_priority: [ |
| 499 | "my-max-target-o-low-priority.txt", |
| 500 | ], |
| 501 | blocked: [ |
| 502 | "my-blocked.txt", |
| 503 | ], |
| 504 | unsupported_packages: [ |
| 505 | "my-unsupported-packages.txt", |
| 506 | ], |
| 507 | }, |
| 508 | } |
| 509 | |
| 510 | java_library { |
| 511 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 512 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 513 | srcs: ["Test.java"], |
| 514 | system_modules: "none", |
| 515 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 516 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 517 | compile_dex: true, |
| 518 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 519 | |
| 520 | java_sdk_library { |
| 521 | name: "mysdklibrary", |
| 522 | srcs: ["Test.java"], |
| 523 | compile_dex: true, |
| 524 | public: {enabled: true}, |
| 525 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 526 | `), |
| 527 | ).RunTest(t) |
| 528 | |
| 529 | CheckSnapshot(t, result, "mysdk", "", |
| 530 | checkUnversionedAndroidBpContents(` |
| 531 | // This is auto-generated. DO NOT EDIT. |
| 532 | |
| 533 | prebuilt_bootclasspath_fragment { |
| 534 | name: "mybootclasspathfragment", |
| 535 | prefer: false, |
| 536 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 537 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 538 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 539 | api: { |
| 540 | stub_libs: ["mysdklibrary"], |
| 541 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 542 | hidden_api: { |
| 543 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 544 | removed: ["hiddenapi/my-removed.txt"], |
| 545 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 546 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 547 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 548 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 549 | blocked: ["hiddenapi/my-blocked.txt"], |
| 550 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
| 551 | }, |
| 552 | } |
| 553 | |
| 554 | java_import { |
| 555 | name: "mybootlib", |
| 556 | prefer: false, |
| 557 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 558 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 559 | jars: ["java/mybootlib.jar"], |
| 560 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 561 | |
| 562 | java_sdk_library_import { |
| 563 | name: "mysdklibrary", |
| 564 | prefer: false, |
| 565 | visibility: ["//visibility:public"], |
| 566 | apex_available: ["//apex_available:platform"], |
| 567 | shared_library: true, |
| 568 | compile_dex: true, |
| 569 | public: { |
| 570 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 571 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 572 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 573 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 574 | sdk_version: "current", |
| 575 | }, |
| 576 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 577 | `), |
| 578 | checkAllCopyRules(` |
| 579 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 580 | my-removed.txt -> hiddenapi/my-removed.txt |
| 581 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 582 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 583 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 584 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 585 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 586 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
| 587 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 588 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 589 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 590 | .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] | 591 | `), |
| 592 | ) |
| 593 | } |