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), |
Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 487 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 488 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 489 | var rule android.TestingBuildParams |
| 490 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") |
| 491 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` |
| 492 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv |
| 493 | out/soong/hiddenapi/hiddenapi-stub-flags.txt |
| 494 | snapshot/hiddenapi/annotation-flags.csv |
| 495 | `, rule) |
| 496 | |
| 497 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") |
| 498 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` |
| 499 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv |
| 500 | snapshot/hiddenapi/metadata.csv |
| 501 | `, rule) |
| 502 | |
| 503 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") |
| 504 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` |
| 505 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv |
| 506 | snapshot/hiddenapi/index.csv |
| 507 | `, rule) |
| 508 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 509 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 510 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 511 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 512 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 513 | |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame^] | 514 | // TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a |
| 515 | // bootclasspath_fragment is correctly output to the sdk snapshot. |
| 516 | func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) { |
| 517 | result := android.GroupFixturePreparers( |
| 518 | prepareForSdkTestWithJava, |
| 519 | java.PrepareForTestWithJavaDefaultModules, |
| 520 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 521 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"), |
| 522 | prepareForSdkTestWithApex, |
| 523 | |
| 524 | // Some additional files needed for the myotherapex. |
| 525 | android.FixtureMergeMockFs(android.MockFS{ |
| 526 | "system/sepolicy/apex/myotherapex-file_contexts": nil, |
| 527 | "myotherapex/apex_manifest.json": nil, |
| 528 | "myotherapex/Test.java": nil, |
| 529 | }), |
| 530 | |
| 531 | android.FixtureAddTextFile("myotherapex/Android.bp", ` |
| 532 | apex { |
| 533 | name: "myotherapex", |
| 534 | key: "myapex.key", |
| 535 | min_sdk_version: "2", |
| 536 | bootclasspath_fragments: ["myotherbootclasspathfragment"], |
| 537 | } |
| 538 | |
| 539 | bootclasspath_fragment { |
| 540 | name: "myotherbootclasspathfragment", |
| 541 | apex_available: ["myotherapex"], |
| 542 | contents: [ |
| 543 | "myotherlib", |
| 544 | ], |
| 545 | } |
| 546 | |
| 547 | java_library { |
| 548 | name: "myotherlib", |
| 549 | apex_available: ["myotherapex"], |
| 550 | srcs: ["Test.java"], |
| 551 | min_sdk_version: "2", |
| 552 | permitted_packages: ["myothersdklibrary"], |
| 553 | compile_dex: true, |
| 554 | } |
| 555 | `), |
| 556 | |
| 557 | android.FixtureWithRootAndroidBp(` |
| 558 | sdk { |
| 559 | name: "mysdk", |
| 560 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 561 | } |
| 562 | |
| 563 | bootclasspath_fragment { |
| 564 | name: "mybootclasspathfragment", |
| 565 | contents: [ |
| 566 | "mysdklibrary", |
| 567 | ], |
| 568 | fragments: [ |
| 569 | { |
| 570 | apex: "myotherapex", |
| 571 | module: "myotherbootclasspathfragment" |
| 572 | }, |
| 573 | ], |
| 574 | } |
| 575 | |
| 576 | java_sdk_library { |
| 577 | name: "mysdklibrary", |
| 578 | srcs: ["Test.java"], |
| 579 | shared_library: false, |
| 580 | public: {enabled: true}, |
| 581 | min_sdk_version: "2", |
| 582 | } |
| 583 | `), |
| 584 | ).RunTest(t) |
| 585 | |
| 586 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 587 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 588 | |
| 589 | CheckSnapshot(t, result, "mysdk", "", |
| 590 | checkUnversionedAndroidBpContents(` |
| 591 | // This is auto-generated. DO NOT EDIT. |
| 592 | |
| 593 | prebuilt_bootclasspath_fragment { |
| 594 | name: "mybootclasspathfragment", |
| 595 | prefer: false, |
| 596 | visibility: ["//visibility:public"], |
| 597 | apex_available: ["//apex_available:platform"], |
| 598 | contents: ["mysdklibrary"], |
| 599 | fragments: [ |
| 600 | { |
| 601 | apex: "myotherapex", |
| 602 | module: "myotherbootclasspathfragment", |
| 603 | }, |
| 604 | ], |
| 605 | hidden_api: { |
| 606 | stub_flags: "hiddenapi/stub-flags.csv", |
| 607 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 608 | metadata: "hiddenapi/metadata.csv", |
| 609 | index: "hiddenapi/index.csv", |
| 610 | all_flags: "hiddenapi/all-flags.csv", |
| 611 | }, |
| 612 | } |
| 613 | |
| 614 | java_sdk_library_import { |
| 615 | name: "mysdklibrary", |
| 616 | prefer: false, |
| 617 | visibility: ["//visibility:public"], |
| 618 | apex_available: ["//apex_available:platform"], |
| 619 | shared_library: false, |
| 620 | public: { |
| 621 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 622 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 623 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 624 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 625 | sdk_version: "current", |
| 626 | }, |
| 627 | } |
| 628 | `), |
| 629 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 630 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 631 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 632 | ) |
| 633 | } |
| 634 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 635 | // Test that bootclasspath_fragment works with sdk. |
| 636 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 637 | android.GroupFixturePreparers( |
| 638 | prepareForSdkTestWithApex, |
| 639 | prepareForSdkTestWithJava, |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 640 | android.FixtureAddFile("java/mybootlib.jar", nil), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 641 | android.FixtureWithRootAndroidBp(` |
| 642 | sdk { |
| 643 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 644 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 645 | } |
| 646 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 647 | bootclasspath_fragment { |
| 648 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 649 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 650 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 651 | apex_available: ["myapex"], |
| 652 | } |
| 653 | |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 654 | java_library { |
| 655 | name: "mybootlib", |
| 656 | apex_available: ["myapex"], |
| 657 | srcs: ["Test.java"], |
| 658 | system_modules: "none", |
| 659 | sdk_version: "none", |
| 660 | min_sdk_version: "1", |
| 661 | compile_dex: true, |
| 662 | } |
| 663 | |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 664 | sdk_snapshot { |
| 665 | name: "mysdk@1", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 666 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 667 | } |
| 668 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 669 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 670 | name: "mysdk_mybootclasspathfragment@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 671 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 672 | prefer: false, |
| 673 | visibility: ["//visibility:public"], |
| 674 | apex_available: [ |
| 675 | "myapex", |
| 676 | ], |
| 677 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 678 | contents: ["mysdk_mybootlib@1"], |
| 679 | } |
| 680 | |
| 681 | java_import { |
| 682 | name: "mysdk_mybootlib@1", |
| 683 | sdk_member_name: "mybootlib", |
| 684 | visibility: ["//visibility:public"], |
| 685 | apex_available: ["com.android.art"], |
| 686 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 687 | } |
| 688 | `), |
| 689 | ).RunTest(t) |
| 690 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 691 | |
| 692 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 693 | result := android.GroupFixturePreparers( |
| 694 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 695 | java.PrepareForTestWithJavaDefaultModules, |
| 696 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 697 | java.FixtureWithLastReleaseApis("mysdklibrary"), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 698 | java.FixtureConfigureUpdatableBootJars("myapex:mybootlib"), |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 699 | prepareForSdkTestWithApex, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 700 | |
| 701 | // Add a platform_bootclasspath that depends on the fragment. |
| 702 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 703 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 704 | android.MockFS{ |
| 705 | "my-blocked.txt": nil, |
| 706 | "my-max-target-o-low-priority.txt": nil, |
| 707 | "my-max-target-p.txt": nil, |
| 708 | "my-max-target-q.txt": nil, |
| 709 | "my-max-target-r-low-priority.txt": nil, |
| 710 | "my-removed.txt": nil, |
| 711 | "my-unsupported-packages.txt": nil, |
| 712 | "my-unsupported.txt": nil, |
| 713 | }.AddToFixture(), |
| 714 | android.FixtureWithRootAndroidBp(` |
| 715 | sdk { |
| 716 | name: "mysdk", |
| 717 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 718 | } |
| 719 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 720 | apex { |
| 721 | name: "myapex", |
| 722 | key: "myapex.key", |
| 723 | min_sdk_version: "1", |
| 724 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 725 | } |
| 726 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 727 | bootclasspath_fragment { |
| 728 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 729 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 730 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 731 | api: { |
| 732 | stub_libs: ["mysdklibrary"], |
| 733 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 734 | hidden_api: { |
| 735 | unsupported: [ |
| 736 | "my-unsupported.txt", |
| 737 | ], |
| 738 | removed: [ |
| 739 | "my-removed.txt", |
| 740 | ], |
| 741 | max_target_r_low_priority: [ |
| 742 | "my-max-target-r-low-priority.txt", |
| 743 | ], |
| 744 | max_target_q: [ |
| 745 | "my-max-target-q.txt", |
| 746 | ], |
| 747 | max_target_p: [ |
| 748 | "my-max-target-p.txt", |
| 749 | ], |
| 750 | max_target_o_low_priority: [ |
| 751 | "my-max-target-o-low-priority.txt", |
| 752 | ], |
| 753 | blocked: [ |
| 754 | "my-blocked.txt", |
| 755 | ], |
| 756 | unsupported_packages: [ |
| 757 | "my-unsupported-packages.txt", |
| 758 | ], |
| 759 | }, |
| 760 | } |
| 761 | |
| 762 | java_library { |
| 763 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 764 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 765 | srcs: ["Test.java"], |
| 766 | system_modules: "none", |
| 767 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 768 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 769 | compile_dex: true, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 770 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 771 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 772 | |
| 773 | java_sdk_library { |
| 774 | name: "mysdklibrary", |
| 775 | srcs: ["Test.java"], |
| 776 | compile_dex: true, |
| 777 | public: {enabled: true}, |
| 778 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 779 | `), |
| 780 | ).RunTest(t) |
| 781 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 782 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 783 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 784 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 785 | CheckSnapshot(t, result, "mysdk", "", |
| 786 | checkUnversionedAndroidBpContents(` |
| 787 | // This is auto-generated. DO NOT EDIT. |
| 788 | |
| 789 | prebuilt_bootclasspath_fragment { |
| 790 | name: "mybootclasspathfragment", |
| 791 | prefer: false, |
| 792 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 793 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 794 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 795 | api: { |
| 796 | stub_libs: ["mysdklibrary"], |
| 797 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 798 | hidden_api: { |
| 799 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 800 | removed: ["hiddenapi/my-removed.txt"], |
| 801 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 802 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 803 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 804 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 805 | blocked: ["hiddenapi/my-blocked.txt"], |
| 806 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 807 | stub_flags: "hiddenapi/stub-flags.csv", |
| 808 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 809 | metadata: "hiddenapi/metadata.csv", |
| 810 | index: "hiddenapi/index.csv", |
| 811 | all_flags: "hiddenapi/all-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 812 | }, |
| 813 | } |
| 814 | |
| 815 | java_import { |
| 816 | name: "mybootlib", |
| 817 | prefer: false, |
| 818 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 819 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 820 | jars: ["java/mybootlib.jar"], |
| 821 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 822 | |
| 823 | java_sdk_library_import { |
| 824 | name: "mysdklibrary", |
| 825 | prefer: false, |
| 826 | visibility: ["//visibility:public"], |
| 827 | apex_available: ["//apex_available:platform"], |
| 828 | shared_library: true, |
| 829 | compile_dex: true, |
| 830 | public: { |
| 831 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 832 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 833 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 834 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 835 | sdk_version: "current", |
| 836 | }, |
| 837 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 838 | `), |
| 839 | checkAllCopyRules(` |
| 840 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 841 | my-removed.txt -> hiddenapi/my-removed.txt |
| 842 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 843 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 844 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 845 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 846 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 847 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 848 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 849 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 850 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 851 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 852 | .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] | 853 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 854 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 855 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 856 | .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] | 857 | `), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 858 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 859 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 860 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 861 | ) |
| 862 | } |