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