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"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 210 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 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"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 217 | shared_library: false, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 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"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 224 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 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"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 264 | shared_library: false, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 265 | public: { |
| 266 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 267 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 268 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 269 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 270 | sdk_version: "current", |
| 271 | }, |
| 272 | } |
| 273 | |
| 274 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 275 | name: "mysdklibrary", |
| 276 | prefer: false, |
| 277 | visibility: ["//visibility:public"], |
| 278 | apex_available: ["//apex_available:platform"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 279 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 280 | public: { |
| 281 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 282 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 283 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 284 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 285 | sdk_version: "current", |
| 286 | }, |
| 287 | } |
| 288 | |
| 289 | java_sdk_library_import { |
| 290 | name: "mycoreplatform", |
| 291 | prefer: false, |
| 292 | visibility: ["//visibility:public"], |
| 293 | apex_available: ["//apex_available:platform"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 294 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 295 | public: { |
| 296 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 297 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 298 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 299 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 300 | sdk_version: "current", |
| 301 | }, |
| 302 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 303 | `), |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 304 | checkVersionedAndroidBpContents(` |
| 305 | // This is auto-generated. DO NOT EDIT. |
| 306 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 307 | prebuilt_bootclasspath_fragment { |
| 308 | name: "mysdk_mybootclasspathfragment@current", |
| 309 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 310 | visibility: ["//visibility:public"], |
| 311 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 312 | contents: [ |
| 313 | "mysdk_mybootlib@current", |
| 314 | "mysdk_myothersdklibrary@current", |
| 315 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 316 | api: { |
| 317 | stub_libs: ["mysdk_mysdklibrary@current"], |
| 318 | }, |
| 319 | core_platform_api: { |
| 320 | stub_libs: ["mysdk_mycoreplatform@current"], |
| 321 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | java_import { |
| 325 | name: "mysdk_mybootlib@current", |
| 326 | sdk_member_name: "mybootlib", |
| 327 | visibility: ["//visibility:public"], |
| 328 | apex_available: ["//apex_available:platform"], |
| 329 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 330 | } |
| 331 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 332 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 333 | name: "mysdk_myothersdklibrary@current", |
| 334 | sdk_member_name: "myothersdklibrary", |
| 335 | visibility: ["//visibility:public"], |
| 336 | apex_available: ["//apex_available:platform"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 337 | shared_library: false, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 338 | public: { |
| 339 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 340 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 341 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 342 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 343 | sdk_version: "current", |
| 344 | }, |
| 345 | } |
| 346 | |
| 347 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 348 | name: "mysdk_mysdklibrary@current", |
| 349 | sdk_member_name: "mysdklibrary", |
| 350 | visibility: ["//visibility:public"], |
| 351 | apex_available: ["//apex_available:platform"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 352 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 353 | public: { |
| 354 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 355 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 356 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 357 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 358 | sdk_version: "current", |
| 359 | }, |
| 360 | } |
| 361 | |
| 362 | java_sdk_library_import { |
| 363 | name: "mysdk_mycoreplatform@current", |
| 364 | sdk_member_name: "mycoreplatform", |
| 365 | visibility: ["//visibility:public"], |
| 366 | apex_available: ["//apex_available:platform"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame^] | 367 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 368 | public: { |
| 369 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 370 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 371 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 372 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 373 | sdk_version: "current", |
| 374 | }, |
| 375 | } |
| 376 | |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 377 | sdk_snapshot { |
| 378 | name: "mysdk@current", |
| 379 | visibility: ["//visibility:public"], |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 380 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 381 | java_boot_libs: ["mysdk_mybootlib@current"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 382 | java_sdk_libs: [ |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 383 | "mysdk_myothersdklibrary@current", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 384 | "mysdk_mysdklibrary@current", |
| 385 | "mysdk_mycoreplatform@current", |
| 386 | ], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 387 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 388 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 389 | checkAllCopyRules(` |
| 390 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 391 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 392 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 393 | .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] | 394 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 395 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 396 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 397 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 398 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 399 | .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] | 400 | `)) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 401 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 402 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 403 | // Test that bootclasspath_fragment works with sdk. |
| 404 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 405 | android.GroupFixturePreparers( |
| 406 | prepareForSdkTestWithApex, |
| 407 | prepareForSdkTestWithJava, |
| 408 | android.FixtureWithRootAndroidBp(` |
| 409 | sdk { |
| 410 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 411 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 412 | } |
| 413 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 414 | bootclasspath_fragment { |
| 415 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 416 | image_name: "art", |
| 417 | apex_available: ["myapex"], |
| 418 | } |
| 419 | |
| 420 | sdk_snapshot { |
| 421 | name: "mysdk@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 422 | bootclasspath_fragments: ["mybootclasspathfragment_mysdk_1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 425 | prebuilt_bootclasspath_fragment { |
| 426 | name: "mybootclasspathfragment_mysdk_1", |
| 427 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 428 | prefer: false, |
| 429 | visibility: ["//visibility:public"], |
| 430 | apex_available: [ |
| 431 | "myapex", |
| 432 | ], |
| 433 | image_name: "art", |
| 434 | } |
| 435 | `), |
| 436 | ).RunTest(t) |
| 437 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 438 | |
| 439 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 440 | result := android.GroupFixturePreparers( |
| 441 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 442 | java.PrepareForTestWithJavaDefaultModules, |
| 443 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 444 | java.FixtureWithLastReleaseApis("mysdklibrary"), |
| 445 | prepareForSdkTestWithApex, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 446 | android.MockFS{ |
| 447 | "my-blocked.txt": nil, |
| 448 | "my-max-target-o-low-priority.txt": nil, |
| 449 | "my-max-target-p.txt": nil, |
| 450 | "my-max-target-q.txt": nil, |
| 451 | "my-max-target-r-low-priority.txt": nil, |
| 452 | "my-removed.txt": nil, |
| 453 | "my-unsupported-packages.txt": nil, |
| 454 | "my-unsupported.txt": nil, |
| 455 | }.AddToFixture(), |
| 456 | android.FixtureWithRootAndroidBp(` |
| 457 | sdk { |
| 458 | name: "mysdk", |
| 459 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 460 | } |
| 461 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 462 | apex { |
| 463 | name: "myapex", |
| 464 | key: "myapex.key", |
| 465 | min_sdk_version: "1", |
| 466 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 467 | } |
| 468 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 469 | bootclasspath_fragment { |
| 470 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 471 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 472 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 473 | api: { |
| 474 | stub_libs: ["mysdklibrary"], |
| 475 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 476 | hidden_api: { |
| 477 | unsupported: [ |
| 478 | "my-unsupported.txt", |
| 479 | ], |
| 480 | removed: [ |
| 481 | "my-removed.txt", |
| 482 | ], |
| 483 | max_target_r_low_priority: [ |
| 484 | "my-max-target-r-low-priority.txt", |
| 485 | ], |
| 486 | max_target_q: [ |
| 487 | "my-max-target-q.txt", |
| 488 | ], |
| 489 | max_target_p: [ |
| 490 | "my-max-target-p.txt", |
| 491 | ], |
| 492 | max_target_o_low_priority: [ |
| 493 | "my-max-target-o-low-priority.txt", |
| 494 | ], |
| 495 | blocked: [ |
| 496 | "my-blocked.txt", |
| 497 | ], |
| 498 | unsupported_packages: [ |
| 499 | "my-unsupported-packages.txt", |
| 500 | ], |
| 501 | }, |
| 502 | } |
| 503 | |
| 504 | java_library { |
| 505 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 506 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 507 | srcs: ["Test.java"], |
| 508 | system_modules: "none", |
| 509 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 510 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 511 | compile_dex: true, |
| 512 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 513 | |
| 514 | java_sdk_library { |
| 515 | name: "mysdklibrary", |
| 516 | srcs: ["Test.java"], |
| 517 | compile_dex: true, |
| 518 | public: {enabled: true}, |
| 519 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 520 | `), |
| 521 | ).RunTest(t) |
| 522 | |
| 523 | CheckSnapshot(t, result, "mysdk", "", |
| 524 | checkUnversionedAndroidBpContents(` |
| 525 | // This is auto-generated. DO NOT EDIT. |
| 526 | |
| 527 | prebuilt_bootclasspath_fragment { |
| 528 | name: "mybootclasspathfragment", |
| 529 | prefer: false, |
| 530 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 531 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 532 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 533 | api: { |
| 534 | stub_libs: ["mysdklibrary"], |
| 535 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 536 | hidden_api: { |
| 537 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 538 | removed: ["hiddenapi/my-removed.txt"], |
| 539 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 540 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 541 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 542 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 543 | blocked: ["hiddenapi/my-blocked.txt"], |
| 544 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
| 545 | }, |
| 546 | } |
| 547 | |
| 548 | java_import { |
| 549 | name: "mybootlib", |
| 550 | prefer: false, |
| 551 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 552 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 553 | jars: ["java/mybootlib.jar"], |
| 554 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 555 | |
| 556 | java_sdk_library_import { |
| 557 | name: "mysdklibrary", |
| 558 | prefer: false, |
| 559 | visibility: ["//visibility:public"], |
| 560 | apex_available: ["//apex_available:platform"], |
| 561 | shared_library: true, |
| 562 | compile_dex: true, |
| 563 | public: { |
| 564 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 565 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 566 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 567 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 568 | sdk_version: "current", |
| 569 | }, |
| 570 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 571 | `), |
| 572 | checkAllCopyRules(` |
| 573 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 574 | my-removed.txt -> hiddenapi/my-removed.txt |
| 575 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 576 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 577 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 578 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 579 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 580 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
| 581 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 582 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 583 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 584 | .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] | 585 | `), |
| 586 | ) |
| 587 | } |