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 | bfeb714 | 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 | bfeb714 | 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 | e112547 | 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 | bfeb714 | 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 | bfeb714 | 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 | bfeb714 | 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 | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 136 | hidden_api: { |
| 137 | stub_flags: "hiddenapi/stub-flags.csv", |
| 138 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 139 | metadata: "hiddenapi/metadata.csv", |
| 140 | index: "hiddenapi/index.csv", |
| 141 | all_flags: "hiddenapi/all-flags.csv", |
| 142 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | java_import { |
| 146 | name: "mybootlib", |
| 147 | prefer: false, |
| 148 | visibility: ["//visibility:public"], |
| 149 | apex_available: ["com.android.art"], |
| 150 | jars: ["java/mybootlib.jar"], |
| 151 | } |
| 152 | `), |
| 153 | checkVersionedAndroidBpContents(` |
| 154 | // This is auto-generated. DO NOT EDIT. |
| 155 | |
| 156 | prebuilt_bootclasspath_fragment { |
| 157 | name: "mysdk_mybootclasspathfragment@current", |
| 158 | sdk_member_name: "mybootclasspathfragment", |
| 159 | visibility: ["//visibility:public"], |
| 160 | apex_available: ["com.android.art"], |
| 161 | image_name: "art", |
Paul Duffin | 2dc665b | 2021-04-23 16:58:51 +0100 | [diff] [blame] | 162 | contents: ["mysdk_mybootlib@current"], |
Paul Duffin | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 163 | hidden_api: { |
| 164 | stub_flags: "hiddenapi/stub-flags.csv", |
| 165 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 166 | metadata: "hiddenapi/metadata.csv", |
| 167 | index: "hiddenapi/index.csv", |
| 168 | all_flags: "hiddenapi/all-flags.csv", |
| 169 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | java_import { |
| 173 | name: "mysdk_mybootlib@current", |
| 174 | sdk_member_name: "mybootlib", |
| 175 | visibility: ["//visibility:public"], |
| 176 | apex_available: ["com.android.art"], |
| 177 | jars: ["java/mybootlib.jar"], |
| 178 | } |
| 179 | |
| 180 | sdk_snapshot { |
| 181 | name: "mysdk@current", |
| 182 | visibility: ["//visibility:public"], |
| 183 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
| 184 | java_boot_libs: ["mysdk_mybootlib@current"], |
| 185 | } |
| 186 | `), |
| 187 | checkAllCopyRules(` |
Paul Duffin | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 188 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 189 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 190 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 191 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 192 | .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] | 193 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | dad8880 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 194 | `), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 195 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | e112547 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 196 | |
| 197 | // Check the behavior of the snapshot without the source. |
| 198 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 199 | // Make sure that the boot jars package check rule includes the dex jar retrieved from the prebuilt apex. |
| 200 | checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/mybootlib.jar") |
| 201 | }), |
| 202 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 203 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 204 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 205 | ) |
Paul Duffin | e112547 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 206 | |
| 207 | // Make sure that the boot jars package check rule includes the dex jar created from the source. |
| 208 | checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/mybootlib/android_common_apex10000/aligned/mybootlib.jar") |
| 209 | } |
| 210 | |
| 211 | // checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars |
| 212 | // package check rule. |
| 213 | func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModule string) { |
| 214 | platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 215 | bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check") |
| 216 | command := bootJarsCheckRule.RuleParams.Command |
| 217 | expectedCommandArgs := " out/soong/host/linux-x86/bin/dexdump build/soong/scripts/check_boot_jars/package_allowed_list.txt " + expectedModule + " &&" |
| 218 | android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs) |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 222 | result := android.GroupFixturePreparers( |
| 223 | prepareForSdkTestWithJava, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 224 | java.PrepareForTestWithJavaDefaultModules, |
| 225 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 226 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 227 | java.FixtureConfigureUpdatableBootJars("myapex:mybootlib", "myapex:myothersdklibrary"), |
| 228 | prepareForSdkTestWithApex, |
| 229 | |
| 230 | // Add a platform_bootclasspath that depends on the fragment. |
| 231 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 232 | |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 233 | android.FixtureWithRootAndroidBp(` |
| 234 | sdk { |
| 235 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 236 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 237 | java_sdk_libs: [ |
| 238 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 239 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 240 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 241 | // correctly deduped. |
| 242 | "mysdklibrary", |
| 243 | ], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 244 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 245 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 246 | apex { |
| 247 | name: "myapex", |
| 248 | key: "myapex.key", |
| 249 | min_sdk_version: "2", |
| 250 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 251 | } |
| 252 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 253 | bootclasspath_fragment { |
| 254 | name: "mybootclasspathfragment", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 255 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 256 | contents: [ |
| 257 | // This should be automatically added to the sdk_snapshot as a java_boot_libs module. |
| 258 | "mybootlib", |
| 259 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. |
| 260 | "myothersdklibrary", |
| 261 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 262 | api: { |
| 263 | stub_libs: ["mysdklibrary"], |
| 264 | }, |
| 265 | core_platform_api: { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 266 | // 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] | 267 | stub_libs: ["mycoreplatform"], |
| 268 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | java_library { |
| 272 | name: "mybootlib", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 273 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 274 | srcs: ["Test.java"], |
| 275 | system_modules: "none", |
| 276 | sdk_version: "none", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 277 | min_sdk_version: "2", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 278 | compile_dex: true, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 279 | permitted_packages: ["mybootlib"], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 280 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 281 | |
| 282 | java_sdk_library { |
| 283 | name: "mysdklibrary", |
Paul Duffin | bfeb714 | 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 | bfeb714 | 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 | } |
| 290 | |
| 291 | java_sdk_library { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 292 | name: "myothersdklibrary", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 293 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 294 | srcs: ["Test.java"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 295 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 296 | public: {enabled: true}, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 297 | min_sdk_version: "2", |
| 298 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | java_sdk_library { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 302 | name: "mycoreplatform", |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 303 | apex_available: ["myapex"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 304 | srcs: ["Test.java"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 305 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 306 | public: {enabled: true}, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 307 | min_sdk_version: "2", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 308 | } |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 309 | `), |
| 310 | ).RunTest(t) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 311 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 312 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 313 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 314 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 315 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 316 | checkUnversionedAndroidBpContents(` |
| 317 | // This is auto-generated. DO NOT EDIT. |
| 318 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 319 | prebuilt_bootclasspath_fragment { |
| 320 | name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 321 | prefer: false, |
| 322 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 323 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 324 | contents: [ |
| 325 | "mybootlib", |
| 326 | "myothersdklibrary", |
| 327 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 328 | api: { |
| 329 | stub_libs: ["mysdklibrary"], |
| 330 | }, |
| 331 | core_platform_api: { |
| 332 | stub_libs: ["mycoreplatform"], |
| 333 | }, |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 334 | hidden_api: { |
| 335 | stub_flags: "hiddenapi/stub-flags.csv", |
| 336 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 337 | metadata: "hiddenapi/metadata.csv", |
| 338 | index: "hiddenapi/index.csv", |
| 339 | all_flags: "hiddenapi/all-flags.csv", |
| 340 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | java_import { |
| 344 | name: "mybootlib", |
| 345 | prefer: false, |
| 346 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 347 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 348 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 349 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 350 | |
| 351 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 352 | name: "myothersdklibrary", |
| 353 | prefer: false, |
| 354 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 355 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 356 | shared_library: true, |
| 357 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 358 | public: { |
| 359 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 360 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 361 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 362 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 363 | sdk_version: "current", |
| 364 | }, |
| 365 | } |
| 366 | |
| 367 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 368 | name: "mysdklibrary", |
| 369 | prefer: false, |
| 370 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 371 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 372 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 373 | public: { |
| 374 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 375 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 376 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 377 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 378 | sdk_version: "current", |
| 379 | }, |
| 380 | } |
| 381 | |
| 382 | java_sdk_library_import { |
| 383 | name: "mycoreplatform", |
| 384 | prefer: false, |
| 385 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 386 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 387 | shared_library: true, |
| 388 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 389 | public: { |
| 390 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 391 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 392 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 393 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 394 | sdk_version: "current", |
| 395 | }, |
| 396 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 397 | `), |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 398 | checkVersionedAndroidBpContents(` |
| 399 | // This is auto-generated. DO NOT EDIT. |
| 400 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 401 | prebuilt_bootclasspath_fragment { |
| 402 | name: "mysdk_mybootclasspathfragment@current", |
| 403 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 404 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 405 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 406 | contents: [ |
| 407 | "mysdk_mybootlib@current", |
| 408 | "mysdk_myothersdklibrary@current", |
| 409 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 410 | api: { |
| 411 | stub_libs: ["mysdk_mysdklibrary@current"], |
| 412 | }, |
| 413 | core_platform_api: { |
| 414 | stub_libs: ["mysdk_mycoreplatform@current"], |
| 415 | }, |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 416 | hidden_api: { |
| 417 | stub_flags: "hiddenapi/stub-flags.csv", |
| 418 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 419 | metadata: "hiddenapi/metadata.csv", |
| 420 | index: "hiddenapi/index.csv", |
| 421 | all_flags: "hiddenapi/all-flags.csv", |
| 422 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | java_import { |
| 426 | name: "mysdk_mybootlib@current", |
| 427 | sdk_member_name: "mybootlib", |
| 428 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 429 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 430 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 431 | } |
| 432 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 433 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 434 | name: "mysdk_myothersdklibrary@current", |
| 435 | sdk_member_name: "myothersdklibrary", |
| 436 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 437 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 438 | shared_library: true, |
| 439 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 440 | public: { |
| 441 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 442 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 443 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 444 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 445 | sdk_version: "current", |
| 446 | }, |
| 447 | } |
| 448 | |
| 449 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 450 | name: "mysdk_mysdklibrary@current", |
| 451 | sdk_member_name: "mysdklibrary", |
| 452 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 453 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 454 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 455 | public: { |
| 456 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 457 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 458 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 459 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 460 | sdk_version: "current", |
| 461 | }, |
| 462 | } |
| 463 | |
| 464 | java_sdk_library_import { |
| 465 | name: "mysdk_mycoreplatform@current", |
| 466 | sdk_member_name: "mycoreplatform", |
| 467 | visibility: ["//visibility:public"], |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 468 | apex_available: ["myapex"], |
Paul Duffin | 2f7ccd5 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 469 | shared_library: true, |
| 470 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 471 | public: { |
| 472 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 473 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 474 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 475 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 476 | sdk_version: "current", |
| 477 | }, |
| 478 | } |
| 479 | |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 480 | sdk_snapshot { |
| 481 | name: "mysdk@current", |
| 482 | visibility: ["//visibility:public"], |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 483 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 484 | java_boot_libs: ["mysdk_mybootlib@current"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 485 | java_sdk_libs: [ |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 486 | "mysdk_myothersdklibrary@current", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 487 | "mysdk_mysdklibrary@current", |
| 488 | "mysdk_mycoreplatform@current", |
| 489 | ], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 490 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 491 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 492 | checkAllCopyRules(` |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 493 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 494 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 495 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 496 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 497 | .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] | 498 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 499 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 500 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 501 | .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] | 502 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 503 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 504 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 505 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 506 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 507 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 508 | `), |
| 509 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | 2a99933 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 510 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 511 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 512 | var rule android.TestingBuildParams |
| 513 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") |
| 514 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` |
| 515 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv |
| 516 | out/soong/hiddenapi/hiddenapi-stub-flags.txt |
| 517 | snapshot/hiddenapi/annotation-flags.csv |
| 518 | `, rule) |
| 519 | |
| 520 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") |
| 521 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` |
| 522 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv |
| 523 | snapshot/hiddenapi/metadata.csv |
| 524 | `, rule) |
| 525 | |
| 526 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") |
| 527 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` |
| 528 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv |
| 529 | snapshot/hiddenapi/index.csv |
| 530 | `, rule) |
| 531 | }), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 532 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 533 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 534 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 535 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 536 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 537 | // Test that bootclasspath_fragment works with sdk. |
| 538 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 539 | android.GroupFixturePreparers( |
| 540 | prepareForSdkTestWithApex, |
| 541 | prepareForSdkTestWithJava, |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 542 | android.FixtureAddFile("java/mybootlib.jar", nil), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 543 | android.FixtureWithRootAndroidBp(` |
| 544 | sdk { |
| 545 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 546 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 547 | } |
| 548 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 549 | bootclasspath_fragment { |
| 550 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 551 | image_name: "art", |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 552 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 553 | apex_available: ["myapex"], |
| 554 | } |
| 555 | |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 556 | java_library { |
| 557 | name: "mybootlib", |
| 558 | apex_available: ["myapex"], |
| 559 | srcs: ["Test.java"], |
| 560 | system_modules: "none", |
| 561 | sdk_version: "none", |
| 562 | min_sdk_version: "1", |
| 563 | compile_dex: true, |
| 564 | } |
| 565 | |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 566 | sdk_snapshot { |
| 567 | name: "mysdk@1", |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 568 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 571 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 572 | name: "mysdk_mybootclasspathfragment@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 573 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 574 | prefer: false, |
| 575 | visibility: ["//visibility:public"], |
| 576 | apex_available: [ |
| 577 | "myapex", |
| 578 | ], |
| 579 | image_name: "art", |
Paul Duffin | 588e22a | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 580 | contents: ["mysdk_mybootlib@1"], |
| 581 | } |
| 582 | |
| 583 | java_import { |
| 584 | name: "mysdk_mybootlib@1", |
| 585 | sdk_member_name: "mybootlib", |
| 586 | visibility: ["//visibility:public"], |
| 587 | apex_available: ["com.android.art"], |
| 588 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 589 | } |
| 590 | `), |
| 591 | ).RunTest(t) |
| 592 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 593 | |
| 594 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 595 | result := android.GroupFixturePreparers( |
| 596 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 597 | java.PrepareForTestWithJavaDefaultModules, |
| 598 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 599 | java.FixtureWithLastReleaseApis("mysdklibrary"), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 600 | java.FixtureConfigureUpdatableBootJars("myapex:mybootlib"), |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 601 | prepareForSdkTestWithApex, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 602 | |
| 603 | // Add a platform_bootclasspath that depends on the fragment. |
| 604 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 605 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 606 | android.MockFS{ |
| 607 | "my-blocked.txt": nil, |
| 608 | "my-max-target-o-low-priority.txt": nil, |
| 609 | "my-max-target-p.txt": nil, |
| 610 | "my-max-target-q.txt": nil, |
| 611 | "my-max-target-r-low-priority.txt": nil, |
| 612 | "my-removed.txt": nil, |
| 613 | "my-unsupported-packages.txt": nil, |
| 614 | "my-unsupported.txt": nil, |
| 615 | }.AddToFixture(), |
| 616 | android.FixtureWithRootAndroidBp(` |
| 617 | sdk { |
| 618 | name: "mysdk", |
| 619 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 620 | } |
| 621 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 622 | apex { |
| 623 | name: "myapex", |
| 624 | key: "myapex.key", |
| 625 | min_sdk_version: "1", |
| 626 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 627 | } |
| 628 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 629 | bootclasspath_fragment { |
| 630 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 631 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 632 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 633 | api: { |
| 634 | stub_libs: ["mysdklibrary"], |
| 635 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 636 | hidden_api: { |
| 637 | unsupported: [ |
| 638 | "my-unsupported.txt", |
| 639 | ], |
| 640 | removed: [ |
| 641 | "my-removed.txt", |
| 642 | ], |
| 643 | max_target_r_low_priority: [ |
| 644 | "my-max-target-r-low-priority.txt", |
| 645 | ], |
| 646 | max_target_q: [ |
| 647 | "my-max-target-q.txt", |
| 648 | ], |
| 649 | max_target_p: [ |
| 650 | "my-max-target-p.txt", |
| 651 | ], |
| 652 | max_target_o_low_priority: [ |
| 653 | "my-max-target-o-low-priority.txt", |
| 654 | ], |
| 655 | blocked: [ |
| 656 | "my-blocked.txt", |
| 657 | ], |
| 658 | unsupported_packages: [ |
| 659 | "my-unsupported-packages.txt", |
| 660 | ], |
| 661 | }, |
| 662 | } |
| 663 | |
| 664 | java_library { |
| 665 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 666 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 667 | srcs: ["Test.java"], |
| 668 | system_modules: "none", |
| 669 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 670 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 671 | compile_dex: true, |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 672 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 673 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 674 | |
| 675 | java_sdk_library { |
| 676 | name: "mysdklibrary", |
| 677 | srcs: ["Test.java"], |
| 678 | compile_dex: true, |
| 679 | public: {enabled: true}, |
| 680 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 681 | `), |
| 682 | ).RunTest(t) |
| 683 | |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 684 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 685 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 686 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 687 | CheckSnapshot(t, result, "mysdk", "", |
| 688 | checkUnversionedAndroidBpContents(` |
| 689 | // This is auto-generated. DO NOT EDIT. |
| 690 | |
| 691 | prebuilt_bootclasspath_fragment { |
| 692 | name: "mybootclasspathfragment", |
| 693 | prefer: false, |
| 694 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 695 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 696 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 697 | api: { |
| 698 | stub_libs: ["mysdklibrary"], |
| 699 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 700 | hidden_api: { |
| 701 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 702 | removed: ["hiddenapi/my-removed.txt"], |
| 703 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 704 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 705 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 706 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 707 | blocked: ["hiddenapi/my-blocked.txt"], |
| 708 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 709 | stub_flags: "hiddenapi/stub-flags.csv", |
| 710 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 711 | metadata: "hiddenapi/metadata.csv", |
| 712 | index: "hiddenapi/index.csv", |
| 713 | all_flags: "hiddenapi/all-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 714 | }, |
| 715 | } |
| 716 | |
| 717 | java_import { |
| 718 | name: "mybootlib", |
| 719 | prefer: false, |
| 720 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 721 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 722 | jars: ["java/mybootlib.jar"], |
| 723 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 724 | |
| 725 | java_sdk_library_import { |
| 726 | name: "mysdklibrary", |
| 727 | prefer: false, |
| 728 | visibility: ["//visibility:public"], |
| 729 | apex_available: ["//apex_available:platform"], |
| 730 | shared_library: true, |
| 731 | compile_dex: true, |
| 732 | public: { |
| 733 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 734 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 735 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 736 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 737 | sdk_version: "current", |
| 738 | }, |
| 739 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 740 | `), |
| 741 | checkAllCopyRules(` |
| 742 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 743 | my-removed.txt -> hiddenapi/my-removed.txt |
| 744 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 745 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 746 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 747 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 748 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 749 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 750 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 751 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 752 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 753 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 754 | .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] | 755 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 756 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 757 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 758 | .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] | 759 | `), |
Paul Duffin | bfeb714 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 760 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 761 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 762 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 763 | ) |
| 764 | } |