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