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