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, |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame^] | 427 | android.FixtureAddFile("java/mybootlib.jar", nil), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 428 | android.FixtureWithRootAndroidBp(` |
| 429 | sdk { |
| 430 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 431 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 432 | } |
| 433 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 434 | bootclasspath_fragment { |
| 435 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 436 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame^] | 437 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 438 | apex_available: ["myapex"], |
| 439 | } |
| 440 | |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame^] | 441 | java_library { |
| 442 | name: "mybootlib", |
| 443 | apex_available: ["myapex"], |
| 444 | srcs: ["Test.java"], |
| 445 | system_modules: "none", |
| 446 | sdk_version: "none", |
| 447 | min_sdk_version: "1", |
| 448 | compile_dex: true, |
| 449 | } |
| 450 | |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 451 | sdk_snapshot { |
| 452 | name: "mysdk@1", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame^] | 453 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 456 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame^] | 457 | name: "mysdk_mybootclasspathfragment@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 458 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 459 | prefer: false, |
| 460 | visibility: ["//visibility:public"], |
| 461 | apex_available: [ |
| 462 | "myapex", |
| 463 | ], |
| 464 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame^] | 465 | contents: ["mysdk_mybootlib@1"], |
| 466 | } |
| 467 | |
| 468 | java_import { |
| 469 | name: "mysdk_mybootlib@1", |
| 470 | sdk_member_name: "mybootlib", |
| 471 | visibility: ["//visibility:public"], |
| 472 | apex_available: ["com.android.art"], |
| 473 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 474 | } |
| 475 | `), |
| 476 | ).RunTest(t) |
| 477 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 478 | |
| 479 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 480 | result := android.GroupFixturePreparers( |
| 481 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 482 | java.PrepareForTestWithJavaDefaultModules, |
| 483 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 484 | java.FixtureWithLastReleaseApis("mysdklibrary"), |
| 485 | prepareForSdkTestWithApex, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 486 | android.MockFS{ |
| 487 | "my-blocked.txt": nil, |
| 488 | "my-max-target-o-low-priority.txt": nil, |
| 489 | "my-max-target-p.txt": nil, |
| 490 | "my-max-target-q.txt": nil, |
| 491 | "my-max-target-r-low-priority.txt": nil, |
| 492 | "my-removed.txt": nil, |
| 493 | "my-unsupported-packages.txt": nil, |
| 494 | "my-unsupported.txt": nil, |
| 495 | }.AddToFixture(), |
| 496 | android.FixtureWithRootAndroidBp(` |
| 497 | sdk { |
| 498 | name: "mysdk", |
| 499 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 500 | } |
| 501 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 502 | apex { |
| 503 | name: "myapex", |
| 504 | key: "myapex.key", |
| 505 | min_sdk_version: "1", |
| 506 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 507 | } |
| 508 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 509 | bootclasspath_fragment { |
| 510 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 511 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 512 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 513 | api: { |
| 514 | stub_libs: ["mysdklibrary"], |
| 515 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 516 | hidden_api: { |
| 517 | unsupported: [ |
| 518 | "my-unsupported.txt", |
| 519 | ], |
| 520 | removed: [ |
| 521 | "my-removed.txt", |
| 522 | ], |
| 523 | max_target_r_low_priority: [ |
| 524 | "my-max-target-r-low-priority.txt", |
| 525 | ], |
| 526 | max_target_q: [ |
| 527 | "my-max-target-q.txt", |
| 528 | ], |
| 529 | max_target_p: [ |
| 530 | "my-max-target-p.txt", |
| 531 | ], |
| 532 | max_target_o_low_priority: [ |
| 533 | "my-max-target-o-low-priority.txt", |
| 534 | ], |
| 535 | blocked: [ |
| 536 | "my-blocked.txt", |
| 537 | ], |
| 538 | unsupported_packages: [ |
| 539 | "my-unsupported-packages.txt", |
| 540 | ], |
| 541 | }, |
| 542 | } |
| 543 | |
| 544 | java_library { |
| 545 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 546 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 547 | srcs: ["Test.java"], |
| 548 | system_modules: "none", |
| 549 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 550 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 551 | compile_dex: true, |
| 552 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 553 | |
| 554 | java_sdk_library { |
| 555 | name: "mysdklibrary", |
| 556 | srcs: ["Test.java"], |
| 557 | compile_dex: true, |
| 558 | public: {enabled: true}, |
| 559 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 560 | `), |
| 561 | ).RunTest(t) |
| 562 | |
| 563 | CheckSnapshot(t, result, "mysdk", "", |
| 564 | checkUnversionedAndroidBpContents(` |
| 565 | // This is auto-generated. DO NOT EDIT. |
| 566 | |
| 567 | prebuilt_bootclasspath_fragment { |
| 568 | name: "mybootclasspathfragment", |
| 569 | prefer: false, |
| 570 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 571 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 572 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 573 | api: { |
| 574 | stub_libs: ["mysdklibrary"], |
| 575 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 576 | hidden_api: { |
| 577 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 578 | removed: ["hiddenapi/my-removed.txt"], |
| 579 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 580 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 581 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 582 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 583 | blocked: ["hiddenapi/my-blocked.txt"], |
| 584 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 585 | stub_flags: "hiddenapi/stub-flags.csv", |
| 586 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 587 | metadata: "hiddenapi/metadata.csv", |
| 588 | index: "hiddenapi/index.csv", |
| 589 | all_flags: "hiddenapi/all-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 590 | }, |
| 591 | } |
| 592 | |
| 593 | java_import { |
| 594 | name: "mybootlib", |
| 595 | prefer: false, |
| 596 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 597 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 598 | jars: ["java/mybootlib.jar"], |
| 599 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 600 | |
| 601 | java_sdk_library_import { |
| 602 | name: "mysdklibrary", |
| 603 | prefer: false, |
| 604 | visibility: ["//visibility:public"], |
| 605 | apex_available: ["//apex_available:platform"], |
| 606 | shared_library: true, |
| 607 | compile_dex: true, |
| 608 | public: { |
| 609 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 610 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 611 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 612 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 613 | sdk_version: "current", |
| 614 | }, |
| 615 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 616 | `), |
| 617 | checkAllCopyRules(` |
| 618 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 619 | my-removed.txt -> hiddenapi/my-removed.txt |
| 620 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 621 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 622 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 623 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 624 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 625 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 626 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 627 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 628 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 629 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 630 | .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] | 631 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 632 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 633 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 634 | .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] | 635 | `), |
| 636 | ) |
| 637 | } |