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