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 | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 276 | compile_dex: true, |
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 | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 286 | compile_dex: true, |
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 | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 337 | shared_library: true, |
| 338 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 339 | public: { |
| 340 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 341 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 342 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 343 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 344 | sdk_version: "current", |
| 345 | }, |
| 346 | } |
| 347 | |
| 348 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 349 | name: "mysdklibrary", |
| 350 | prefer: false, |
| 351 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 352 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 353 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 354 | public: { |
| 355 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 356 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 357 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 358 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 359 | sdk_version: "current", |
| 360 | }, |
| 361 | } |
| 362 | |
| 363 | java_sdk_library_import { |
| 364 | name: "mycoreplatform", |
| 365 | prefer: false, |
| 366 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 367 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 368 | shared_library: true, |
| 369 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 370 | public: { |
| 371 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 372 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 373 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 374 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 375 | sdk_version: "current", |
| 376 | }, |
| 377 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 378 | `), |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 379 | checkVersionedAndroidBpContents(` |
| 380 | // This is auto-generated. DO NOT EDIT. |
| 381 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 382 | prebuilt_bootclasspath_fragment { |
| 383 | name: "mysdk_mybootclasspathfragment@current", |
| 384 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 385 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 386 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 387 | contents: [ |
| 388 | "mysdk_mybootlib@current", |
| 389 | "mysdk_myothersdklibrary@current", |
| 390 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 391 | api: { |
| 392 | stub_libs: ["mysdk_mysdklibrary@current"], |
| 393 | }, |
| 394 | core_platform_api: { |
| 395 | stub_libs: ["mysdk_mycoreplatform@current"], |
| 396 | }, |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 397 | hidden_api: { |
| 398 | stub_flags: "hiddenapi/stub-flags.csv", |
| 399 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 400 | metadata: "hiddenapi/metadata.csv", |
| 401 | index: "hiddenapi/index.csv", |
| 402 | all_flags: "hiddenapi/all-flags.csv", |
| 403 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | java_import { |
| 407 | name: "mysdk_mybootlib@current", |
| 408 | sdk_member_name: "mybootlib", |
| 409 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 410 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 411 | jars: ["java/mybootlib.jar"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 412 | } |
| 413 | |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 414 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 415 | name: "mysdk_myothersdklibrary@current", |
| 416 | sdk_member_name: "myothersdklibrary", |
| 417 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 418 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 419 | shared_library: true, |
| 420 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 421 | public: { |
| 422 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 423 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 424 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 425 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 426 | sdk_version: "current", |
| 427 | }, |
| 428 | } |
| 429 | |
| 430 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 431 | name: "mysdk_mysdklibrary@current", |
| 432 | sdk_member_name: "mysdklibrary", |
| 433 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 434 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 435 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 436 | public: { |
| 437 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 438 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 439 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 440 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 441 | sdk_version: "current", |
| 442 | }, |
| 443 | } |
| 444 | |
| 445 | java_sdk_library_import { |
| 446 | name: "mysdk_mycoreplatform@current", |
| 447 | sdk_member_name: "mycoreplatform", |
| 448 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 449 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 450 | shared_library: true, |
| 451 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 452 | public: { |
| 453 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 454 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 455 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 456 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 457 | sdk_version: "current", |
| 458 | }, |
| 459 | } |
| 460 | |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 461 | sdk_snapshot { |
| 462 | name: "mysdk@current", |
| 463 | visibility: ["//visibility:public"], |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 464 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 465 | java_boot_libs: ["mysdk_mybootlib@current"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 466 | java_sdk_libs: [ |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 467 | "mysdk_myothersdklibrary@current", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 468 | "mysdk_mysdklibrary@current", |
| 469 | "mysdk_mycoreplatform@current", |
| 470 | ], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 471 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 472 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 473 | checkAllCopyRules(` |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 474 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 475 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 476 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 477 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 478 | .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] | 479 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 480 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 481 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 482 | .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] | 483 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 484 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 485 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 486 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 487 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 488 | .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] | 489 | `), |
| 490 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 491 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 492 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 493 | var rule android.TestingBuildParams |
| 494 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") |
| 495 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` |
| 496 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv |
| 497 | out/soong/hiddenapi/hiddenapi-stub-flags.txt |
| 498 | snapshot/hiddenapi/annotation-flags.csv |
| 499 | `, rule) |
| 500 | |
| 501 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") |
| 502 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` |
| 503 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv |
| 504 | snapshot/hiddenapi/metadata.csv |
| 505 | `, rule) |
| 506 | |
| 507 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") |
| 508 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` |
| 509 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv |
| 510 | snapshot/hiddenapi/index.csv |
| 511 | `, rule) |
| 512 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 513 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 514 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 515 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 516 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 517 | |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 518 | // TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a |
| 519 | // bootclasspath_fragment is correctly output to the sdk snapshot. |
| 520 | func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) { |
| 521 | result := android.GroupFixturePreparers( |
| 522 | prepareForSdkTestWithJava, |
| 523 | java.PrepareForTestWithJavaDefaultModules, |
| 524 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 525 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"), |
| 526 | prepareForSdkTestWithApex, |
| 527 | |
| 528 | // Some additional files needed for the myotherapex. |
| 529 | android.FixtureMergeMockFs(android.MockFS{ |
| 530 | "system/sepolicy/apex/myotherapex-file_contexts": nil, |
| 531 | "myotherapex/apex_manifest.json": nil, |
| 532 | "myotherapex/Test.java": nil, |
| 533 | }), |
| 534 | |
| 535 | android.FixtureAddTextFile("myotherapex/Android.bp", ` |
| 536 | apex { |
| 537 | name: "myotherapex", |
| 538 | key: "myapex.key", |
| 539 | min_sdk_version: "2", |
| 540 | bootclasspath_fragments: ["myotherbootclasspathfragment"], |
| 541 | } |
| 542 | |
| 543 | bootclasspath_fragment { |
| 544 | name: "myotherbootclasspathfragment", |
| 545 | apex_available: ["myotherapex"], |
| 546 | contents: [ |
| 547 | "myotherlib", |
| 548 | ], |
| 549 | } |
| 550 | |
| 551 | java_library { |
| 552 | name: "myotherlib", |
| 553 | apex_available: ["myotherapex"], |
| 554 | srcs: ["Test.java"], |
| 555 | min_sdk_version: "2", |
| 556 | permitted_packages: ["myothersdklibrary"], |
| 557 | compile_dex: true, |
| 558 | } |
| 559 | `), |
| 560 | |
| 561 | android.FixtureWithRootAndroidBp(` |
| 562 | sdk { |
| 563 | name: "mysdk", |
| 564 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 565 | } |
| 566 | |
| 567 | bootclasspath_fragment { |
| 568 | name: "mybootclasspathfragment", |
| 569 | contents: [ |
| 570 | "mysdklibrary", |
| 571 | ], |
| 572 | fragments: [ |
| 573 | { |
| 574 | apex: "myotherapex", |
| 575 | module: "myotherbootclasspathfragment" |
| 576 | }, |
| 577 | ], |
| 578 | } |
| 579 | |
| 580 | java_sdk_library { |
| 581 | name: "mysdklibrary", |
| 582 | srcs: ["Test.java"], |
| 583 | shared_library: false, |
| 584 | public: {enabled: true}, |
| 585 | min_sdk_version: "2", |
| 586 | } |
| 587 | `), |
| 588 | ).RunTest(t) |
| 589 | |
| 590 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 591 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 592 | |
| 593 | CheckSnapshot(t, result, "mysdk", "", |
| 594 | checkUnversionedAndroidBpContents(` |
| 595 | // This is auto-generated. DO NOT EDIT. |
| 596 | |
| 597 | prebuilt_bootclasspath_fragment { |
| 598 | name: "mybootclasspathfragment", |
| 599 | prefer: false, |
| 600 | visibility: ["//visibility:public"], |
| 601 | apex_available: ["//apex_available:platform"], |
| 602 | contents: ["mysdklibrary"], |
| 603 | fragments: [ |
| 604 | { |
| 605 | apex: "myotherapex", |
| 606 | module: "myotherbootclasspathfragment", |
| 607 | }, |
| 608 | ], |
| 609 | hidden_api: { |
| 610 | stub_flags: "hiddenapi/stub-flags.csv", |
| 611 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 612 | metadata: "hiddenapi/metadata.csv", |
| 613 | index: "hiddenapi/index.csv", |
| 614 | all_flags: "hiddenapi/all-flags.csv", |
| 615 | }, |
| 616 | } |
| 617 | |
| 618 | java_sdk_library_import { |
| 619 | name: "mysdklibrary", |
| 620 | prefer: false, |
| 621 | visibility: ["//visibility:public"], |
| 622 | apex_available: ["//apex_available:platform"], |
| 623 | shared_library: false, |
| 624 | public: { |
| 625 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 626 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 627 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 628 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 629 | sdk_version: "current", |
| 630 | }, |
| 631 | } |
| 632 | `), |
| 633 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 634 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 635 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 636 | ) |
| 637 | } |
| 638 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 639 | // Test that bootclasspath_fragment works with sdk. |
| 640 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 641 | android.GroupFixturePreparers( |
| 642 | prepareForSdkTestWithApex, |
| 643 | prepareForSdkTestWithJava, |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 644 | android.FixtureAddFile("java/mybootlib.jar", nil), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 645 | android.FixtureWithRootAndroidBp(` |
| 646 | sdk { |
| 647 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 648 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 649 | } |
| 650 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 651 | bootclasspath_fragment { |
| 652 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 653 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 654 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 655 | apex_available: ["myapex"], |
| 656 | } |
| 657 | |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 658 | java_library { |
| 659 | name: "mybootlib", |
| 660 | apex_available: ["myapex"], |
| 661 | srcs: ["Test.java"], |
| 662 | system_modules: "none", |
| 663 | sdk_version: "none", |
| 664 | min_sdk_version: "1", |
| 665 | compile_dex: true, |
| 666 | } |
| 667 | |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 668 | sdk_snapshot { |
| 669 | name: "mysdk@1", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 670 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 671 | } |
| 672 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 673 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 674 | name: "mysdk_mybootclasspathfragment@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 675 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 676 | prefer: false, |
| 677 | visibility: ["//visibility:public"], |
| 678 | apex_available: [ |
| 679 | "myapex", |
| 680 | ], |
| 681 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 682 | contents: ["mysdk_mybootlib@1"], |
| 683 | } |
| 684 | |
| 685 | java_import { |
| 686 | name: "mysdk_mybootlib@1", |
| 687 | sdk_member_name: "mybootlib", |
| 688 | visibility: ["//visibility:public"], |
| 689 | apex_available: ["com.android.art"], |
| 690 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 691 | } |
| 692 | `), |
| 693 | ).RunTest(t) |
| 694 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 695 | |
| 696 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 697 | result := android.GroupFixturePreparers( |
| 698 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 699 | java.PrepareForTestWithJavaDefaultModules, |
| 700 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 701 | java.FixtureWithLastReleaseApis("mysdklibrary"), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 702 | java.FixtureConfigureUpdatableBootJars("myapex:mybootlib"), |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 703 | prepareForSdkTestWithApex, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 704 | |
| 705 | // Add a platform_bootclasspath that depends on the fragment. |
| 706 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 707 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 708 | android.MockFS{ |
| 709 | "my-blocked.txt": nil, |
| 710 | "my-max-target-o-low-priority.txt": nil, |
| 711 | "my-max-target-p.txt": nil, |
| 712 | "my-max-target-q.txt": nil, |
| 713 | "my-max-target-r-low-priority.txt": nil, |
| 714 | "my-removed.txt": nil, |
| 715 | "my-unsupported-packages.txt": nil, |
| 716 | "my-unsupported.txt": nil, |
| 717 | }.AddToFixture(), |
| 718 | android.FixtureWithRootAndroidBp(` |
| 719 | sdk { |
| 720 | name: "mysdk", |
| 721 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 722 | } |
| 723 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 724 | apex { |
| 725 | name: "myapex", |
| 726 | key: "myapex.key", |
| 727 | min_sdk_version: "1", |
| 728 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 729 | } |
| 730 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 731 | bootclasspath_fragment { |
| 732 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 733 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 734 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 735 | api: { |
| 736 | stub_libs: ["mysdklibrary"], |
| 737 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 738 | hidden_api: { |
| 739 | unsupported: [ |
| 740 | "my-unsupported.txt", |
| 741 | ], |
| 742 | removed: [ |
| 743 | "my-removed.txt", |
| 744 | ], |
| 745 | max_target_r_low_priority: [ |
| 746 | "my-max-target-r-low-priority.txt", |
| 747 | ], |
| 748 | max_target_q: [ |
| 749 | "my-max-target-q.txt", |
| 750 | ], |
| 751 | max_target_p: [ |
| 752 | "my-max-target-p.txt", |
| 753 | ], |
| 754 | max_target_o_low_priority: [ |
| 755 | "my-max-target-o-low-priority.txt", |
| 756 | ], |
| 757 | blocked: [ |
| 758 | "my-blocked.txt", |
| 759 | ], |
| 760 | unsupported_packages: [ |
| 761 | "my-unsupported-packages.txt", |
| 762 | ], |
| 763 | }, |
| 764 | } |
| 765 | |
| 766 | java_library { |
| 767 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 768 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 769 | srcs: ["Test.java"], |
| 770 | system_modules: "none", |
| 771 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 772 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 773 | compile_dex: true, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 774 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 775 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 776 | |
| 777 | java_sdk_library { |
| 778 | name: "mysdklibrary", |
| 779 | srcs: ["Test.java"], |
| 780 | compile_dex: true, |
| 781 | public: {enabled: true}, |
| 782 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 783 | `), |
| 784 | ).RunTest(t) |
| 785 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 786 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 787 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 788 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 789 | CheckSnapshot(t, result, "mysdk", "", |
| 790 | checkUnversionedAndroidBpContents(` |
| 791 | // This is auto-generated. DO NOT EDIT. |
| 792 | |
| 793 | prebuilt_bootclasspath_fragment { |
| 794 | name: "mybootclasspathfragment", |
| 795 | prefer: false, |
| 796 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 797 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 798 | contents: ["mybootlib"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 799 | api: { |
| 800 | stub_libs: ["mysdklibrary"], |
| 801 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 802 | hidden_api: { |
| 803 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 804 | removed: ["hiddenapi/my-removed.txt"], |
| 805 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
| 806 | max_target_q: ["hiddenapi/my-max-target-q.txt"], |
| 807 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 808 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 809 | blocked: ["hiddenapi/my-blocked.txt"], |
| 810 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 811 | stub_flags: "hiddenapi/stub-flags.csv", |
| 812 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 813 | metadata: "hiddenapi/metadata.csv", |
| 814 | index: "hiddenapi/index.csv", |
| 815 | all_flags: "hiddenapi/all-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 816 | }, |
| 817 | } |
| 818 | |
| 819 | java_import { |
| 820 | name: "mybootlib", |
| 821 | prefer: false, |
| 822 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 823 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 824 | jars: ["java/mybootlib.jar"], |
| 825 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 826 | |
| 827 | java_sdk_library_import { |
| 828 | name: "mysdklibrary", |
| 829 | prefer: false, |
| 830 | visibility: ["//visibility:public"], |
| 831 | apex_available: ["//apex_available:platform"], |
| 832 | shared_library: true, |
| 833 | compile_dex: true, |
| 834 | public: { |
| 835 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 836 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 837 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 838 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 839 | sdk_version: "current", |
| 840 | }, |
| 841 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 842 | `), |
| 843 | checkAllCopyRules(` |
| 844 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 845 | my-removed.txt -> hiddenapi/my-removed.txt |
| 846 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 847 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
| 848 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 849 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 850 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 851 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 852 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 853 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 854 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 855 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 856 | .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] | 857 | .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 858 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 859 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 860 | .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] | 861 | `), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 862 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 863 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 864 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 865 | ) |
| 866 | } |