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 | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 20 | "strings" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 21 | "testing" |
| 22 | |
| 23 | "android/soong/android" |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 24 | "android/soong/java" |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 25 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 26 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 27 | // fixtureAddPlatformBootclasspathForBootclasspathFragment adds a platform_bootclasspath module that |
| 28 | // references the bootclasspath fragment. |
| 29 | func fixtureAddPlatformBootclasspathForBootclasspathFragment(apex, fragment string) android.FixturePreparer { |
| 30 | return android.GroupFixturePreparers( |
| 31 | // Add a platform_bootclasspath module. |
| 32 | android.FixtureAddTextFile("frameworks/base/boot/Android.bp", fmt.Sprintf(` |
| 33 | platform_bootclasspath { |
| 34 | name: "platform-bootclasspath", |
| 35 | fragments: [ |
| 36 | { |
| 37 | apex: "%s", |
| 38 | module: "%s", |
| 39 | }, |
| 40 | ], |
| 41 | } |
| 42 | `, apex, fragment)), |
| 43 | android.FixtureAddFile("frameworks/base/config/boot-profile.txt", nil), |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 44 | android.FixtureAddFile("frameworks/base/config/boot-image-profile.txt", nil), |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 45 | 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] | 46 | ) |
| 47 | } |
| 48 | |
| 49 | // fixtureAddPrebuiltApexForBootclasspathFragment adds a prebuilt_apex that exports the fragment. |
| 50 | func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) android.FixturePreparer { |
| 51 | apexFile := fmt.Sprintf("%s.apex", apex) |
| 52 | dir := "prebuilts/apex" |
| 53 | return android.GroupFixturePreparers( |
| 54 | // A preparer to add a prebuilt apex to the test fixture. |
| 55 | android.FixtureAddTextFile(filepath.Join(dir, "Android.bp"), fmt.Sprintf(` |
| 56 | prebuilt_apex { |
| 57 | name: "%s", |
| 58 | src: "%s", |
| 59 | exported_bootclasspath_fragments: [ |
| 60 | "%s", |
| 61 | ], |
| 62 | } |
| 63 | `, apex, apexFile, fragment)), |
| 64 | android.FixtureAddFile(filepath.Join(dir, apexFile), nil), |
| 65 | ) |
| 66 | } |
| 67 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 68 | func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) { |
| 69 | result := android.GroupFixturePreparers( |
| 70 | prepareForSdkTestWithJava, |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 71 | java.PrepareForTestWithJavaDefaultModules, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 72 | prepareForSdkTestWithApex, |
| 73 | |
| 74 | // Some additional files needed for the art apex. |
| 75 | android.FixtureMergeMockFs(android.MockFS{ |
| 76 | "com.android.art.avbpubkey": nil, |
| 77 | "com.android.art.pem": nil, |
| 78 | "system/sepolicy/apex/com.android.art-file_contexts": nil, |
| 79 | }), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 80 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 81 | // Add a platform_bootclasspath that depends on the fragment. |
| 82 | fixtureAddPlatformBootclasspathForBootclasspathFragment("com.android.art", "mybootclasspathfragment"), |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 83 | |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 84 | java.PrepareForBootImageConfigTest, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 85 | android.FixtureWithRootAndroidBp(` |
| 86 | sdk { |
| 87 | name: "mysdk", |
| 88 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | apex { |
| 92 | name: "com.android.art", |
| 93 | key: "com.android.art.key", |
| 94 | bootclasspath_fragments: [ |
| 95 | "mybootclasspathfragment", |
| 96 | ], |
| 97 | updatable: false, |
| 98 | } |
| 99 | |
| 100 | bootclasspath_fragment { |
| 101 | name: "mybootclasspathfragment", |
| 102 | image_name: "art", |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 103 | contents: ["core1", "core2"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 104 | apex_available: ["com.android.art"], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 105 | hidden_api: { |
| 106 | split_packages: ["*"], |
| 107 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | apex_key { |
| 111 | name: "com.android.art.key", |
| 112 | public_key: "com.android.art.avbpubkey", |
| 113 | private_key: "com.android.art.pem", |
| 114 | } |
| 115 | |
| 116 | java_library { |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 117 | name: "core1", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 118 | srcs: ["Test.java"], |
| 119 | system_modules: "none", |
| 120 | sdk_version: "none", |
| 121 | compile_dex: true, |
| 122 | apex_available: ["com.android.art"], |
| 123 | } |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 124 | |
| 125 | java_library { |
| 126 | name: "core2", |
| 127 | srcs: ["Test.java"], |
| 128 | system_modules: "none", |
| 129 | sdk_version: "none", |
| 130 | compile_dex: true, |
| 131 | apex_available: ["com.android.art"], |
| 132 | } |
| 133 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 134 | ).RunTest(t) |
| 135 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 136 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 137 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment") |
Paul Duffin | 023dba0 | 2021-04-22 01:45:29 +0100 | [diff] [blame] | 138 | |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 139 | // Check that source on its own configures the bootImageConfig correctly. |
| 140 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic") |
| 141 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
| 142 | |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 143 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 144 | checkAndroidBpContents(` |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 145 | // This is auto-generated. DO NOT EDIT. |
| 146 | |
| 147 | prebuilt_bootclasspath_fragment { |
| 148 | name: "mybootclasspathfragment", |
| 149 | prefer: false, |
| 150 | visibility: ["//visibility:public"], |
| 151 | apex_available: ["com.android.art"], |
| 152 | image_name: "art", |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 153 | contents: [ |
| 154 | "core1", |
| 155 | "core2", |
| 156 | ], |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 157 | hidden_api: { |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 158 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 159 | metadata: "hiddenapi/metadata.csv", |
| 160 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 161 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 162 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 163 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 164 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | java_import { |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 168 | name: "core1", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 169 | prefer: false, |
| 170 | visibility: ["//visibility:public"], |
| 171 | apex_available: ["com.android.art"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 172 | jars: ["java_boot_libs/snapshot/jars/are/invalid/core1.jar"], |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | java_import { |
| 176 | name: "core2", |
| 177 | prefer: false, |
| 178 | visibility: ["//visibility:public"], |
| 179 | apex_available: ["com.android.art"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 180 | jars: ["java_boot_libs/snapshot/jars/are/invalid/core2.jar"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 181 | } |
| 182 | `), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 183 | checkAllCopyRules(` |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 184 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 185 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 186 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 187 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 188 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 189 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 190 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar |
| 191 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar |
Paul Duffin | da286f4 | 2021-06-29 11:59:23 +0100 | [diff] [blame] | 192 | `), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 193 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 194 | |
| 195 | // Check the behavior of the snapshot without the source. |
| 196 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 197 | // Make sure that the boot jars package check rule includes the dex jars retrieved from the prebuilt apex. |
| 198 | checkBootJarsPackageCheckRule(t, result, |
| 199 | "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core1.jar", |
| 200 | "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core2.jar", |
| 201 | "out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar") |
| 202 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/mybootclasspathfragment/android_common_com.android.art/meta_lic") |
| 203 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 204 | }), |
| 205 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 206 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 207 | |
| 208 | // Check the behavior of the snapshot when the source is preferred. |
| 209 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { |
| 210 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic") |
| 211 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
| 212 | }), |
| 213 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 214 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 215 | |
| 216 | // Check the behavior of the snapshot when it is preferred. |
| 217 | snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) { |
Paul Duffin | 20d90e3 | 2022-10-04 20:01:04 +0100 | [diff] [blame] | 218 | java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/prebuilt_mybootclasspathfragment/android_common_com.android.art/meta_lic") |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 219 | java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic") |
| 220 | }), |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 221 | ) |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 222 | |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 223 | // Make sure that the boot jars package check rule includes the dex jars created from the source. |
| 224 | checkBootJarsPackageCheckRule(t, result, |
| 225 | "out/soong/.intermediates/core1/android_common_apex10000/aligned/core1.jar", |
| 226 | "out/soong/.intermediates/core2/android_common_apex10000/aligned/core2.jar", |
| 227 | "out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar") |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | // checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars |
| 231 | // package check rule. |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 232 | func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModules ...string) { |
| 233 | t.Helper() |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 234 | platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 235 | bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check") |
| 236 | command := bootJarsCheckRule.RuleParams.Command |
Paul Duffin | 8eb4573 | 2022-10-04 19:03:31 +0100 | [diff] [blame] | 237 | expectedCommandArgs := " build/soong/scripts/check_boot_jars/package_allowed_list.txt " + strings.Join(expectedModules, " ") + " &&" |
Paul Duffin | c8ead41 | 2021-06-07 19:28:15 +0100 | [diff] [blame] | 238 | android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs) |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 239 | } |
| 240 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 241 | func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, copyRules string) { |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 242 | result := android.GroupFixturePreparers( |
| 243 | prepareForSdkTestWithJava, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 244 | java.PrepareForTestWithJavaDefaultModules, |
| 245 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 246 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), |
satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 247 | java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:myothersdklibrary"), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 248 | prepareForSdkTestWithApex, |
| 249 | |
| 250 | // Add a platform_bootclasspath that depends on the fragment. |
| 251 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 252 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 253 | android.FixtureWithRootAndroidBp(sdk+` |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 254 | apex { |
| 255 | name: "myapex", |
| 256 | key: "myapex.key", |
| 257 | min_sdk_version: "2", |
| 258 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 259 | } |
| 260 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 261 | bootclasspath_fragment { |
| 262 | name: "mybootclasspathfragment", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 263 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 264 | contents: [ |
| 265 | // This should be automatically added to the sdk_snapshot as a java_boot_libs module. |
| 266 | "mybootlib", |
| 267 | // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. |
| 268 | "myothersdklibrary", |
| 269 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 270 | api: { |
| 271 | stub_libs: ["mysdklibrary"], |
| 272 | }, |
| 273 | core_platform_api: { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 274 | // 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] | 275 | stub_libs: ["mycoreplatform"], |
| 276 | }, |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 277 | hidden_api: { |
| 278 | split_packages: ["*"], |
| 279 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | java_library { |
| 283 | name: "mybootlib", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 284 | apex_available: ["myapex"], |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 285 | srcs: ["Test.java"], |
| 286 | system_modules: "none", |
| 287 | sdk_version: "none", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 288 | min_sdk_version: "2", |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 289 | compile_dex: true, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 290 | permitted_packages: ["mybootlib"], |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 291 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 292 | |
| 293 | java_sdk_library { |
| 294 | name: "mysdklibrary", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 295 | apex_available: ["myapex"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 296 | srcs: ["Test.java"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 297 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 298 | public: {enabled: true}, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 299 | min_sdk_version: "2", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | java_sdk_library { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 303 | name: "myothersdklibrary", |
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 | srcs: ["Test.java"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 306 | compile_dex: true, |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 307 | public: {enabled: true}, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 308 | min_sdk_version: "2", |
| 309 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | java_sdk_library { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 313 | name: "mycoreplatform", |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 314 | apex_available: ["myapex"], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 315 | srcs: ["Test.java"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 316 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 317 | public: {enabled: true}, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 318 | min_sdk_version: "2", |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 319 | } |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 320 | `), |
| 321 | ).RunTest(t) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 322 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 323 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 324 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 325 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 326 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 327 | checkAndroidBpContents(` |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 328 | // This is auto-generated. DO NOT EDIT. |
| 329 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 330 | prebuilt_bootclasspath_fragment { |
| 331 | name: "mybootclasspathfragment", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 332 | prefer: false, |
| 333 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 334 | apex_available: ["myapex"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 335 | contents: [ |
| 336 | "mybootlib", |
| 337 | "myothersdklibrary", |
| 338 | ], |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 339 | api: { |
| 340 | stub_libs: ["mysdklibrary"], |
| 341 | }, |
| 342 | core_platform_api: { |
| 343 | stub_libs: ["mycoreplatform"], |
| 344 | }, |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 345 | hidden_api: { |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 346 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 347 | metadata: "hiddenapi/metadata.csv", |
| 348 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 349 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 350 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 351 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 352 | }, |
Paul Duffin | a57835e | 2021-04-19 13:23:06 +0100 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | java_import { |
| 356 | name: "mybootlib", |
| 357 | prefer: false, |
| 358 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 359 | apex_available: ["myapex"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 360 | jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"], |
Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame^] | 361 | min_sdk_version: "2", |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 362 | permitted_packages: ["mybootlib"], |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 363 | } |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 364 | |
| 365 | java_sdk_library_import { |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 366 | name: "myothersdklibrary", |
| 367 | prefer: false, |
| 368 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 369 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 370 | shared_library: true, |
| 371 | compile_dex: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 372 | permitted_packages: ["myothersdklibrary"], |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 373 | public: { |
| 374 | jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], |
| 375 | stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], |
| 376 | current_api: "sdk_library/public/myothersdklibrary.txt", |
| 377 | removed_api: "sdk_library/public/myothersdklibrary-removed.txt", |
| 378 | sdk_version: "current", |
| 379 | }, |
| 380 | } |
| 381 | |
| 382 | java_sdk_library_import { |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 383 | name: "mysdklibrary", |
| 384 | prefer: false, |
| 385 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 386 | apex_available: ["myapex"], |
Paul Duffin | f4600f6 | 2021-05-13 22:34:45 +0100 | [diff] [blame] | 387 | shared_library: false, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 388 | public: { |
| 389 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 390 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 391 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 392 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 393 | sdk_version: "current", |
| 394 | }, |
| 395 | } |
| 396 | |
| 397 | java_sdk_library_import { |
| 398 | name: "mycoreplatform", |
| 399 | prefer: false, |
| 400 | visibility: ["//visibility:public"], |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 401 | apex_available: ["myapex"], |
Paul Duffin | ea8f808 | 2021-06-24 13:25:57 +0100 | [diff] [blame] | 402 | shared_library: true, |
| 403 | compile_dex: true, |
Paul Duffin | 895c714 | 2021-04-25 13:40:15 +0100 | [diff] [blame] | 404 | public: { |
| 405 | jars: ["sdk_library/public/mycoreplatform-stubs.jar"], |
| 406 | stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"], |
| 407 | current_api: "sdk_library/public/mycoreplatform.txt", |
| 408 | removed_api: "sdk_library/public/mycoreplatform-removed.txt", |
| 409 | sdk_version: "current", |
| 410 | }, |
| 411 | } |
Paul Duffin | a10bd3c | 2021-05-12 13:46:54 +0100 | [diff] [blame] | 412 | `), |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 413 | checkAllCopyRules(copyRules), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 414 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 415 | snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) { |
| 416 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 417 | var rule android.TestingBuildParams |
| 418 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv") |
| 419 | java.CheckHiddenAPIRuleInputs(t, "monolithic flags", ` |
| 420 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/annotation-flags-from-classes.csv |
| 421 | out/soong/hiddenapi/hiddenapi-stub-flags.txt |
| 422 | snapshot/hiddenapi/annotation-flags.csv |
| 423 | `, rule) |
| 424 | |
| 425 | rule = module.Output("out/soong/hiddenapi/hiddenapi-unsupported.csv") |
| 426 | java.CheckHiddenAPIRuleInputs(t, "monolithic metadata", ` |
| 427 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/metadata-from-classes.csv |
| 428 | snapshot/hiddenapi/metadata.csv |
| 429 | `, rule) |
| 430 | |
| 431 | rule = module.Output("out/soong/hiddenapi/hiddenapi-index.csv") |
| 432 | java.CheckHiddenAPIRuleInputs(t, "monolithic index", ` |
| 433 | out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv |
| 434 | snapshot/hiddenapi/index.csv |
| 435 | `, rule) |
Paul Duffin | 630b11e | 2021-07-15 13:35:26 +0100 | [diff] [blame] | 436 | |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 437 | rule = module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 438 | android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " snapshot/hiddenapi/filtered-flags.csv:snapshot/hiddenapi/signature-patterns.csv ") |
Paul Duffin | d061d40 | 2021-06-07 21:36:01 +0100 | [diff] [blame] | 439 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 440 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 441 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { |
| 442 | module := result.ModuleForTests("platform-bootclasspath", "android_common") |
| 443 | rule := module.Output("out/soong/hiddenapi/hiddenapi-flags.csv.valid") |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 444 | android.AssertStringDoesContain(t, "verify-overlaps", rule.RuleParams.Command, " out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv ") |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 445 | }), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 446 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 447 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 448 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 449 | |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 450 | func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { |
| 451 | t.Run("added-directly", func(t *testing.T) { |
| 452 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 453 | sdk { |
| 454 | name: "mysdk", |
| 455 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 456 | java_sdk_libs: [ |
| 457 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 458 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 459 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 460 | // correctly deduped. |
| 461 | "mysdklibrary", |
| 462 | ], |
| 463 | } |
| 464 | `, ` |
| 465 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 466 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 467 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 468 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 469 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 470 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 471 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 472 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 473 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 474 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt |
| 475 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 476 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 477 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 478 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 479 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 480 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
| 481 | `) |
| 482 | }) |
| 483 | |
| 484 | copyBootclasspathFragmentFromApexVariantRules := ` |
| 485 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 486 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 487 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 488 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 489 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 490 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 491 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar |
Paul Duffin | 4e7d1c4 | 2022-05-13 13:12:19 +0000 | [diff] [blame] | 492 | .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar |
| 493 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt |
| 494 | .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt |
| 495 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 496 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 497 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 498 | .intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar |
| 499 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt |
| 500 | .intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt |
| 501 | ` |
| 502 | t.Run("added-via-apex", func(t *testing.T) { |
| 503 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 504 | sdk { |
| 505 | name: "mysdk", |
| 506 | apexes: ["myapex"], |
| 507 | } |
| 508 | `, copyBootclasspathFragmentFromApexVariantRules) |
| 509 | }) |
| 510 | |
| 511 | t.Run("added-directly-and-indirectly", func(t *testing.T) { |
| 512 | testSnapshotWithBootClasspathFragment_Contents(t, ` |
| 513 | sdk { |
| 514 | name: "mysdk", |
| 515 | apexes: ["myapex"], |
| 516 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 517 | // a bootclasspath_fragments module because it is used in the myapex's |
| 518 | // bootclasspath_fragments property. However, it is specified here to ensure that duplicates |
| 519 | // are correctly deduped. |
| 520 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 521 | java_sdk_libs: [ |
| 522 | // This is not strictly needed as it should be automatically added to the sdk_snapshot as |
| 523 | // a java_sdk_libs module because it is used in the mybootclasspathfragment's |
| 524 | // api.stub_libs property. However, it is specified here to ensure that duplicates are |
| 525 | // correctly deduped. |
| 526 | "mysdklibrary", |
| 527 | ], |
| 528 | } |
| 529 | `, copyBootclasspathFragmentFromApexVariantRules) |
| 530 | }) |
| 531 | } |
| 532 | |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 533 | // TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a |
| 534 | // bootclasspath_fragment is correctly output to the sdk snapshot. |
| 535 | func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) { |
| 536 | result := android.GroupFixturePreparers( |
| 537 | prepareForSdkTestWithJava, |
| 538 | java.PrepareForTestWithJavaDefaultModules, |
| 539 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 540 | java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary"), |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 541 | java.FixtureConfigureApexBootJars("someapex:mysdklibrary", "myotherapex:myotherlib"), |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 542 | prepareForSdkTestWithApex, |
| 543 | |
| 544 | // Some additional files needed for the myotherapex. |
| 545 | android.FixtureMergeMockFs(android.MockFS{ |
| 546 | "system/sepolicy/apex/myotherapex-file_contexts": nil, |
| 547 | "myotherapex/apex_manifest.json": nil, |
| 548 | "myotherapex/Test.java": nil, |
| 549 | }), |
| 550 | |
| 551 | android.FixtureAddTextFile("myotherapex/Android.bp", ` |
| 552 | apex { |
| 553 | name: "myotherapex", |
| 554 | key: "myapex.key", |
| 555 | min_sdk_version: "2", |
| 556 | bootclasspath_fragments: ["myotherbootclasspathfragment"], |
| 557 | } |
| 558 | |
| 559 | bootclasspath_fragment { |
| 560 | name: "myotherbootclasspathfragment", |
| 561 | apex_available: ["myotherapex"], |
| 562 | contents: [ |
| 563 | "myotherlib", |
| 564 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 565 | hidden_api: { |
| 566 | split_packages: ["*"], |
| 567 | }, |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | java_library { |
| 571 | name: "myotherlib", |
| 572 | apex_available: ["myotherapex"], |
| 573 | srcs: ["Test.java"], |
| 574 | min_sdk_version: "2", |
| 575 | permitted_packages: ["myothersdklibrary"], |
| 576 | compile_dex: true, |
| 577 | } |
| 578 | `), |
| 579 | |
| 580 | android.FixtureWithRootAndroidBp(` |
| 581 | sdk { |
| 582 | name: "mysdk", |
| 583 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 584 | } |
| 585 | |
| 586 | bootclasspath_fragment { |
| 587 | name: "mybootclasspathfragment", |
| 588 | contents: [ |
| 589 | "mysdklibrary", |
| 590 | ], |
| 591 | fragments: [ |
| 592 | { |
| 593 | apex: "myotherapex", |
| 594 | module: "myotherbootclasspathfragment" |
| 595 | }, |
| 596 | ], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 597 | hidden_api: { |
| 598 | split_packages: ["*"], |
| 599 | }, |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | java_sdk_library { |
| 603 | name: "mysdklibrary", |
| 604 | srcs: ["Test.java"], |
| 605 | shared_library: false, |
| 606 | public: {enabled: true}, |
| 607 | min_sdk_version: "2", |
| 608 | } |
| 609 | `), |
| 610 | ).RunTest(t) |
| 611 | |
| 612 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 613 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 614 | |
| 615 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 616 | checkAndroidBpContents(` |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 617 | // This is auto-generated. DO NOT EDIT. |
| 618 | |
| 619 | prebuilt_bootclasspath_fragment { |
| 620 | name: "mybootclasspathfragment", |
| 621 | prefer: false, |
| 622 | visibility: ["//visibility:public"], |
| 623 | apex_available: ["//apex_available:platform"], |
| 624 | contents: ["mysdklibrary"], |
| 625 | fragments: [ |
| 626 | { |
| 627 | apex: "myotherapex", |
| 628 | module: "myotherbootclasspathfragment", |
| 629 | }, |
| 630 | ], |
| 631 | hidden_api: { |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 632 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 633 | metadata: "hiddenapi/metadata.csv", |
| 634 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 635 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 636 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 637 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 51227d8 | 2021-05-18 12:54:27 +0100 | [diff] [blame] | 638 | }, |
| 639 | } |
| 640 | |
| 641 | java_sdk_library_import { |
| 642 | name: "mysdklibrary", |
| 643 | prefer: false, |
| 644 | visibility: ["//visibility:public"], |
| 645 | apex_available: ["//apex_available:platform"], |
| 646 | shared_library: false, |
| 647 | public: { |
| 648 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 649 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 650 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 651 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 652 | sdk_version: "current", |
| 653 | }, |
| 654 | } |
| 655 | `), |
| 656 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 657 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 658 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
| 659 | ) |
| 660 | } |
| 661 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 662 | // Test that bootclasspath_fragment works with sdk. |
| 663 | func TestBasicSdkWithBootclasspathFragment(t *testing.T) { |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 664 | android.GroupFixturePreparers( |
| 665 | prepareForSdkTestWithApex, |
| 666 | prepareForSdkTestWithJava, |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 667 | android.FixtureAddFile("java/mybootlib.jar", nil), |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 668 | android.FixtureWithRootAndroidBp(` |
| 669 | sdk { |
| 670 | name: "mysdk", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 671 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 674 | bootclasspath_fragment { |
| 675 | name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 676 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 677 | contents: ["mybootlib"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 678 | apex_available: ["myapex"], |
Paul Duffin | 9fd5647 | 2022-03-31 15:42:30 +0100 | [diff] [blame] | 679 | hidden_api: { |
| 680 | split_packages: ["*"], |
| 681 | }, |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 682 | } |
| 683 | |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 684 | java_library { |
| 685 | name: "mybootlib", |
| 686 | apex_available: ["myapex"], |
| 687 | srcs: ["Test.java"], |
| 688 | system_modules: "none", |
| 689 | sdk_version: "none", |
| 690 | min_sdk_version: "1", |
| 691 | compile_dex: true, |
| 692 | } |
| 693 | |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 694 | sdk_snapshot { |
| 695 | name: "mysdk@1", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 696 | bootclasspath_fragments: ["mysdk_mybootclasspathfragment@1"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 697 | } |
| 698 | |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 699 | prebuilt_bootclasspath_fragment { |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 700 | name: "mysdk_mybootclasspathfragment@1", |
Paul Duffin | 0b28a8d | 2021-04-21 23:38:34 +0100 | [diff] [blame] | 701 | sdk_member_name: "mybootclasspathfragment", |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 702 | prefer: false, |
| 703 | visibility: ["//visibility:public"], |
| 704 | apex_available: [ |
| 705 | "myapex", |
| 706 | ], |
| 707 | image_name: "art", |
Paul Duffin | 8018e50 | 2021-05-21 19:28:09 +0100 | [diff] [blame] | 708 | contents: ["mysdk_mybootlib@1"], |
| 709 | } |
| 710 | |
| 711 | java_import { |
| 712 | name: "mysdk_mybootlib@1", |
| 713 | sdk_member_name: "mybootlib", |
| 714 | visibility: ["//visibility:public"], |
| 715 | apex_available: ["com.android.art"], |
| 716 | jars: ["java/mybootlib.jar"], |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame] | 717 | } |
| 718 | `), |
| 719 | ).RunTest(t) |
| 720 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 721 | |
| 722 | func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { |
| 723 | result := android.GroupFixturePreparers( |
| 724 | prepareForSdkTestWithJava, |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 725 | java.PrepareForTestWithJavaDefaultModules, |
| 726 | java.PrepareForTestWithJavaSdkLibraryFiles, |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 727 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewlibrary"), |
| 728 | java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:mynewlibrary"), |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 729 | prepareForSdkTestWithApex, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 730 | |
| 731 | // Add a platform_bootclasspath that depends on the fragment. |
| 732 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 733 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 734 | android.MockFS{ |
| 735 | "my-blocked.txt": nil, |
| 736 | "my-max-target-o-low-priority.txt": nil, |
| 737 | "my-max-target-p.txt": nil, |
| 738 | "my-max-target-q.txt": nil, |
| 739 | "my-max-target-r-low-priority.txt": nil, |
| 740 | "my-removed.txt": nil, |
| 741 | "my-unsupported-packages.txt": nil, |
| 742 | "my-unsupported.txt": nil, |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 743 | "my-new-max-target-q.txt": nil, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 744 | }.AddToFixture(), |
| 745 | android.FixtureWithRootAndroidBp(` |
| 746 | sdk { |
| 747 | name: "mysdk", |
| 748 | bootclasspath_fragments: ["mybootclasspathfragment"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 749 | } |
| 750 | |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 751 | apex { |
| 752 | name: "myapex", |
| 753 | key: "myapex.key", |
| 754 | min_sdk_version: "1", |
| 755 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 756 | } |
| 757 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 758 | bootclasspath_fragment { |
| 759 | name: "mybootclasspathfragment", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 760 | apex_available: ["myapex"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 761 | contents: ["mybootlib", "mynewlibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 762 | api: { |
| 763 | stub_libs: ["mysdklibrary"], |
| 764 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 765 | hidden_api: { |
| 766 | unsupported: [ |
| 767 | "my-unsupported.txt", |
| 768 | ], |
| 769 | removed: [ |
| 770 | "my-removed.txt", |
| 771 | ], |
| 772 | max_target_r_low_priority: [ |
| 773 | "my-max-target-r-low-priority.txt", |
| 774 | ], |
| 775 | max_target_q: [ |
| 776 | "my-max-target-q.txt", |
| 777 | ], |
| 778 | max_target_p: [ |
| 779 | "my-max-target-p.txt", |
| 780 | ], |
| 781 | max_target_o_low_priority: [ |
| 782 | "my-max-target-o-low-priority.txt", |
| 783 | ], |
| 784 | blocked: [ |
| 785 | "my-blocked.txt", |
| 786 | ], |
| 787 | unsupported_packages: [ |
| 788 | "my-unsupported-packages.txt", |
| 789 | ], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 790 | split_packages: ["sdklibrary"], |
| 791 | package_prefixes: ["sdklibrary.all.mine"], |
| 792 | single_packages: ["sdklibrary.mine"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 793 | }, |
| 794 | } |
| 795 | |
| 796 | java_library { |
| 797 | name: "mybootlib", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 798 | apex_available: ["myapex"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 799 | srcs: ["Test.java"], |
| 800 | system_modules: "none", |
| 801 | sdk_version: "none", |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 802 | min_sdk_version: "1", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 803 | compile_dex: true, |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 804 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 805 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 806 | |
| 807 | java_sdk_library { |
| 808 | name: "mysdklibrary", |
| 809 | srcs: ["Test.java"], |
| 810 | compile_dex: true, |
| 811 | public: {enabled: true}, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 812 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 813 | } |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 814 | |
| 815 | java_sdk_library { |
| 816 | name: "mynewlibrary", |
| 817 | apex_available: ["myapex"], |
| 818 | srcs: ["Test.java"], |
| 819 | min_sdk_version: "10", |
| 820 | compile_dex: true, |
| 821 | public: {enabled: true}, |
| 822 | permitted_packages: ["mysdklibrary"], |
| 823 | hidden_api: { |
| 824 | max_target_q: [ |
| 825 | "my-new-max-target-q.txt", |
| 826 | ], |
| 827 | split_packages: ["sdklibrary", "newlibrary"], |
| 828 | package_prefixes: ["newlibrary.all.mine"], |
| 829 | single_packages: ["newlibrary.mine"], |
| 830 | }, |
| 831 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 832 | `), |
| 833 | ).RunTest(t) |
| 834 | |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 835 | // A preparer to update the test fixture used when processing an unpackage snapshot. |
| 836 | preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment") |
| 837 | |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 838 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 839 | checkAndroidBpContents(` |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 840 | // This is auto-generated. DO NOT EDIT. |
| 841 | |
| 842 | prebuilt_bootclasspath_fragment { |
| 843 | name: "mybootclasspathfragment", |
| 844 | prefer: false, |
| 845 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 846 | apex_available: ["myapex"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 847 | contents: [ |
| 848 | "mybootlib", |
| 849 | "mynewlibrary", |
| 850 | ], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 851 | api: { |
| 852 | stub_libs: ["mysdklibrary"], |
| 853 | }, |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 854 | hidden_api: { |
| 855 | unsupported: ["hiddenapi/my-unsupported.txt"], |
| 856 | removed: ["hiddenapi/my-removed.txt"], |
| 857 | max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"], |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 858 | max_target_q: [ |
| 859 | "hiddenapi/my-max-target-q.txt", |
| 860 | "hiddenapi/my-new-max-target-q.txt", |
| 861 | ], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 862 | max_target_p: ["hiddenapi/my-max-target-p.txt"], |
| 863 | max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"], |
| 864 | blocked: ["hiddenapi/my-blocked.txt"], |
| 865 | unsupported_packages: ["hiddenapi/my-unsupported-packages.txt"], |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 866 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 867 | metadata: "hiddenapi/metadata.csv", |
| 868 | index: "hiddenapi/index.csv", |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 869 | signature_patterns: "hiddenapi/signature-patterns.csv", |
Paul Duffin | 191be3a | 2021-08-10 16:14:16 +0100 | [diff] [blame] | 870 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 871 | filtered_flags: "hiddenapi/filtered-flags.csv", |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 872 | }, |
| 873 | } |
| 874 | |
| 875 | java_import { |
| 876 | name: "mybootlib", |
| 877 | prefer: false, |
| 878 | visibility: ["//visibility:public"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 879 | apex_available: ["myapex"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 880 | jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"], |
Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame^] | 881 | min_sdk_version: "1", |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 882 | permitted_packages: ["mybootlib"], |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 883 | } |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 884 | |
| 885 | java_sdk_library_import { |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 886 | name: "mynewlibrary", |
| 887 | prefer: false, |
| 888 | visibility: ["//visibility:public"], |
| 889 | apex_available: ["myapex"], |
| 890 | shared_library: true, |
| 891 | compile_dex: true, |
| 892 | permitted_packages: ["mysdklibrary"], |
| 893 | public: { |
| 894 | jars: ["sdk_library/public/mynewlibrary-stubs.jar"], |
| 895 | stub_srcs: ["sdk_library/public/mynewlibrary_stub_sources"], |
| 896 | current_api: "sdk_library/public/mynewlibrary.txt", |
| 897 | removed_api: "sdk_library/public/mynewlibrary-removed.txt", |
| 898 | sdk_version: "current", |
| 899 | }, |
| 900 | } |
| 901 | |
| 902 | java_sdk_library_import { |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 903 | name: "mysdklibrary", |
| 904 | prefer: false, |
| 905 | visibility: ["//visibility:public"], |
| 906 | apex_available: ["//apex_available:platform"], |
| 907 | shared_library: true, |
| 908 | compile_dex: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 909 | permitted_packages: ["mysdklibrary"], |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 910 | public: { |
| 911 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 912 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 913 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 914 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 915 | sdk_version: "current", |
| 916 | }, |
| 917 | } |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 918 | `), |
| 919 | checkAllCopyRules(` |
| 920 | my-unsupported.txt -> hiddenapi/my-unsupported.txt |
| 921 | my-removed.txt -> hiddenapi/my-removed.txt |
| 922 | my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt |
| 923 | my-max-target-q.txt -> hiddenapi/my-max-target-q.txt |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 924 | my-new-max-target-q.txt -> hiddenapi/my-new-max-target-q.txt |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 925 | my-max-target-p.txt -> hiddenapi/my-max-target-p.txt |
| 926 | my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt |
| 927 | my-blocked.txt -> hiddenapi/my-blocked.txt |
| 928 | my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt |
Paul Duffin | 2fef136 | 2021-04-15 13:32:00 +0100 | [diff] [blame] | 929 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 930 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 931 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
Paul Duffin | 8d007e9 | 2021-07-22 12:00:49 +0100 | [diff] [blame] | 932 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
Paul Duffin | 280bae6 | 2021-07-20 18:03:53 +0100 | [diff] [blame] | 933 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 934 | .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 935 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar |
Paul Duffin | 3f1ae0b | 2022-07-27 16:27:42 +0000 | [diff] [blame] | 936 | .intermediates/mynewlibrary.stubs/android_common/javac/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar |
| 937 | .intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt |
| 938 | .intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt |
Paul Duffin | 475daaf | 2021-05-13 00:57:55 +0100 | [diff] [blame] | 939 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 940 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 941 | .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] | 942 | `), |
Paul Duffin | 7c47515 | 2021-06-09 16:17:58 +0100 | [diff] [blame] | 943 | snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot), |
| 944 | snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), |
| 945 | snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot), |
Paul Duffin | 7c95555 | 2021-04-19 13:23:53 +0100 | [diff] [blame] | 946 | ) |
| 947 | } |
Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 948 | |
| 949 | func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBuildRelease string, |
| 950 | expectedSdkSnapshot string, |
| 951 | expectedCopyRules string, |
| 952 | expectedStubFlagsInputs []string, |
| 953 | suffix string) { |
| 954 | |
| 955 | result := android.GroupFixturePreparers( |
| 956 | prepareForSdkTestWithJava, |
| 957 | java.PrepareForTestWithJavaDefaultModules, |
| 958 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 959 | java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"), |
| 960 | java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"), |
| 961 | prepareForSdkTestWithApex, |
| 962 | |
| 963 | // Add a platform_bootclasspath that depends on the fragment. |
| 964 | fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"), |
| 965 | |
| 966 | android.FixtureMergeEnv(map[string]string{ |
| 967 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease, |
| 968 | }), |
| 969 | |
| 970 | android.FixtureWithRootAndroidBp(` |
| 971 | sdk { |
| 972 | name: "mysdk", |
| 973 | apexes: ["myapex"], |
| 974 | } |
| 975 | |
| 976 | apex { |
| 977 | name: "myapex", |
| 978 | key: "myapex.key", |
| 979 | min_sdk_version: "S", |
| 980 | bootclasspath_fragments: ["mybootclasspathfragment"], |
| 981 | } |
| 982 | |
| 983 | bootclasspath_fragment { |
| 984 | name: "mybootclasspathfragment", |
| 985 | apex_available: ["myapex"], |
| 986 | contents: [ |
| 987 | "mysdklibrary", |
| 988 | "mynewsdklibrary", |
| 989 | ], |
| 990 | |
| 991 | hidden_api: { |
| 992 | split_packages: [], |
| 993 | }, |
| 994 | } |
| 995 | |
| 996 | java_sdk_library { |
| 997 | name: "mysdklibrary", |
| 998 | apex_available: ["myapex"], |
| 999 | srcs: ["Test.java"], |
| 1000 | shared_library: false, |
| 1001 | public: {enabled: true}, |
| 1002 | min_sdk_version: "S", |
| 1003 | } |
| 1004 | |
| 1005 | java_sdk_library { |
| 1006 | name: "mynewsdklibrary", |
| 1007 | apex_available: ["myapex"], |
| 1008 | srcs: ["Test.java"], |
| 1009 | compile_dex: true, |
| 1010 | public: {enabled: true}, |
| 1011 | min_sdk_version: "Tiramisu", |
| 1012 | permitted_packages: ["mynewsdklibrary"], |
| 1013 | } |
| 1014 | `), |
| 1015 | ).RunTest(t) |
| 1016 | |
| 1017 | bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common") |
| 1018 | rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv") |
| 1019 | android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits) |
| 1020 | |
| 1021 | CheckSnapshot(t, result, "mysdk", "", |
| 1022 | checkAndroidBpContents(expectedSdkSnapshot), |
| 1023 | checkAllCopyRules(expectedCopyRules), |
| 1024 | ) |
| 1025 | } |
| 1026 | |
| 1027 | func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) { |
| 1028 | t.Run("target S build", func(t *testing.T) { |
| 1029 | expectedSnapshot := ` |
| 1030 | // This is auto-generated. DO NOT EDIT. |
| 1031 | |
| 1032 | prebuilt_bootclasspath_fragment { |
| 1033 | name: "mybootclasspathfragment", |
| 1034 | prefer: false, |
| 1035 | visibility: ["//visibility:public"], |
| 1036 | apex_available: ["myapex"], |
| 1037 | contents: ["mysdklibrary"], |
| 1038 | hidden_api: { |
| 1039 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 1040 | metadata: "hiddenapi/metadata.csv", |
| 1041 | index: "hiddenapi/index.csv", |
| 1042 | stub_flags: "hiddenapi/stub-flags.csv", |
| 1043 | all_flags: "hiddenapi/all-flags.csv", |
| 1044 | }, |
| 1045 | } |
| 1046 | |
| 1047 | java_sdk_library_import { |
| 1048 | name: "mysdklibrary", |
| 1049 | prefer: false, |
| 1050 | visibility: ["//visibility:public"], |
| 1051 | apex_available: ["myapex"], |
| 1052 | shared_library: false, |
| 1053 | public: { |
| 1054 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 1055 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 1056 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 1057 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 1058 | sdk_version: "current", |
| 1059 | }, |
| 1060 | } |
| 1061 | ` |
| 1062 | expectedCopyRules := ` |
| 1063 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 1064 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/metadata.csv -> hiddenapi/metadata.csv |
| 1065 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/index.csv -> hiddenapi/index.csv |
| 1066 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv |
| 1067 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv |
| 1068 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 1069 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 1070 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 1071 | ` |
| 1072 | |
| 1073 | // On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part |
| 1074 | // of the snapshot. |
| 1075 | expectedStubFlagsInputs := []string{ |
| 1076 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", |
| 1077 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", |
| 1078 | } |
| 1079 | |
| 1080 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S", |
| 1081 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "-for-sdk-snapshot") |
| 1082 | }) |
| 1083 | |
| 1084 | t.Run("target-Tiramisu-build", func(t *testing.T) { |
| 1085 | expectedSnapshot := ` |
| 1086 | // This is auto-generated. DO NOT EDIT. |
| 1087 | |
| 1088 | prebuilt_bootclasspath_fragment { |
| 1089 | name: "mybootclasspathfragment", |
| 1090 | prefer: false, |
| 1091 | visibility: ["//visibility:public"], |
| 1092 | apex_available: ["myapex"], |
| 1093 | contents: [ |
| 1094 | "mysdklibrary", |
| 1095 | "mynewsdklibrary", |
| 1096 | ], |
| 1097 | hidden_api: { |
| 1098 | annotation_flags: "hiddenapi/annotation-flags.csv", |
| 1099 | metadata: "hiddenapi/metadata.csv", |
| 1100 | index: "hiddenapi/index.csv", |
| 1101 | signature_patterns: "hiddenapi/signature-patterns.csv", |
| 1102 | filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv", |
| 1103 | filtered_flags: "hiddenapi/filtered-flags.csv", |
| 1104 | }, |
| 1105 | } |
| 1106 | |
| 1107 | java_sdk_library_import { |
| 1108 | name: "mysdklibrary", |
| 1109 | prefer: false, |
| 1110 | visibility: ["//visibility:public"], |
| 1111 | apex_available: ["myapex"], |
| 1112 | shared_library: false, |
| 1113 | public: { |
| 1114 | jars: ["sdk_library/public/mysdklibrary-stubs.jar"], |
| 1115 | stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], |
| 1116 | current_api: "sdk_library/public/mysdklibrary.txt", |
| 1117 | removed_api: "sdk_library/public/mysdklibrary-removed.txt", |
| 1118 | sdk_version: "current", |
| 1119 | }, |
| 1120 | } |
| 1121 | |
| 1122 | java_sdk_library_import { |
| 1123 | name: "mynewsdklibrary", |
| 1124 | prefer: false, |
| 1125 | visibility: ["//visibility:public"], |
| 1126 | apex_available: ["myapex"], |
| 1127 | shared_library: true, |
| 1128 | compile_dex: true, |
| 1129 | permitted_packages: ["mynewsdklibrary"], |
| 1130 | public: { |
| 1131 | jars: ["sdk_library/public/mynewsdklibrary-stubs.jar"], |
| 1132 | stub_srcs: ["sdk_library/public/mynewsdklibrary_stub_sources"], |
| 1133 | current_api: "sdk_library/public/mynewsdklibrary.txt", |
| 1134 | removed_api: "sdk_library/public/mynewsdklibrary-removed.txt", |
| 1135 | sdk_version: "current", |
| 1136 | }, |
| 1137 | } |
| 1138 | ` |
| 1139 | expectedCopyRules := ` |
| 1140 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv |
| 1141 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv |
| 1142 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/index.csv -> hiddenapi/index.csv |
| 1143 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv |
| 1144 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv |
| 1145 | .intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv |
| 1146 | .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar |
| 1147 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt |
| 1148 | .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |
| 1149 | .intermediates/mynewsdklibrary.stubs/android_common/javac/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar |
| 1150 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt |
| 1151 | .intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt |
| 1152 | ` |
| 1153 | |
| 1154 | // On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as |
| 1155 | // they are both part of the snapshot. |
| 1156 | expectedStubFlagsInputs := []string{ |
| 1157 | "out/soong/.intermediates/mynewsdklibrary.stubs/android_common/dex/mynewsdklibrary.stubs.jar", |
| 1158 | "out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar", |
| 1159 | "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar", |
| 1160 | "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar", |
| 1161 | } |
| 1162 | |
| 1163 | testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu", |
| 1164 | expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "") |
| 1165 | }) |
| 1166 | } |