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