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