Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1 | // Copyright 2021 Google Inc. All rights reserved. |
| 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 cc |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "fmt" |
| 20 | "path/filepath" |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 21 | "reflect" |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 22 | "strings" |
| 23 | "testing" |
| 24 | ) |
| 25 | |
| 26 | func TestVendorSnapshotCapture(t *testing.T) { |
| 27 | bp := ` |
| 28 | cc_library { |
| 29 | name: "libvndk", |
| 30 | vendor_available: true, |
| 31 | product_available: true, |
| 32 | vndk: { |
| 33 | enabled: true, |
| 34 | }, |
| 35 | nocrt: true, |
| 36 | } |
| 37 | |
| 38 | cc_library { |
| 39 | name: "libvendor", |
| 40 | vendor: true, |
| 41 | nocrt: true, |
| 42 | } |
| 43 | |
| 44 | cc_library { |
| 45 | name: "libvendor_available", |
| 46 | vendor_available: true, |
| 47 | nocrt: true, |
| 48 | } |
| 49 | |
| 50 | cc_library_headers { |
| 51 | name: "libvendor_headers", |
| 52 | vendor_available: true, |
| 53 | nocrt: true, |
| 54 | } |
| 55 | |
| 56 | cc_binary { |
| 57 | name: "vendor_bin", |
| 58 | vendor: true, |
| 59 | nocrt: true, |
| 60 | } |
| 61 | |
| 62 | cc_binary { |
| 63 | name: "vendor_available_bin", |
| 64 | vendor_available: true, |
| 65 | nocrt: true, |
| 66 | } |
| 67 | |
| 68 | toolchain_library { |
| 69 | name: "libb", |
| 70 | vendor_available: true, |
| 71 | src: "libb.a", |
| 72 | } |
| 73 | |
| 74 | cc_object { |
| 75 | name: "obj", |
| 76 | vendor_available: true, |
| 77 | } |
| 78 | |
| 79 | cc_library { |
| 80 | name: "libllndk", |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 81 | llndk: { |
| 82 | symbol_file: "libllndk.map.txt", |
| 83 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 84 | } |
| 85 | ` |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 86 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 87 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 88 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 89 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 90 | ctx := testCcWithConfig(t, config) |
| 91 | |
| 92 | // Check Vendor snapshot output. |
| 93 | |
| 94 | snapshotDir := "vendor-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 95 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 96 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 97 | |
| 98 | var jsonFiles []string |
| 99 | |
| 100 | for _, arch := range [][]string{ |
| 101 | []string{"arm64", "armv8-a"}, |
| 102 | []string{"arm", "armv7-a-neon"}, |
| 103 | } { |
| 104 | archType := arch[0] |
| 105 | archVariant := arch[1] |
| 106 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 107 | |
| 108 | // For shared libraries, only non-VNDK vendor_available modules are captured |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 109 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 110 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 111 | CheckSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
| 112 | CheckSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 113 | jsonFiles = append(jsonFiles, |
| 114 | filepath.Join(sharedDir, "libvendor.so.json"), |
| 115 | filepath.Join(sharedDir, "libvendor_available.so.json")) |
| 116 | |
| 117 | // LLNDK modules are not captured |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 118 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 119 | |
| 120 | // For static libraries, all vendor:true and vendor_available modules (including VNDK) are captured. |
| 121 | // Also cfi variants are captured, except for prebuilts like toolchain_library |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 122 | staticVariant := fmt.Sprintf("android_vendor.29_%s_%s_static", archType, archVariant) |
| 123 | staticCfiVariant := fmt.Sprintf("android_vendor.29_%s_%s_static_cfi", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 124 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 125 | CheckSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant) |
| 126 | CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.a", staticDir, staticVariant) |
| 127 | CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.cfi.a", staticDir, staticCfiVariant) |
| 128 | CheckSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.a", staticDir, staticVariant) |
| 129 | CheckSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.cfi.a", staticDir, staticCfiVariant) |
| 130 | CheckSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.a", staticDir, staticVariant) |
| 131 | CheckSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.cfi.a", staticDir, staticCfiVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 132 | jsonFiles = append(jsonFiles, |
| 133 | filepath.Join(staticDir, "libb.a.json"), |
| 134 | filepath.Join(staticDir, "libvndk.a.json"), |
| 135 | filepath.Join(staticDir, "libvndk.cfi.a.json"), |
| 136 | filepath.Join(staticDir, "libvendor.a.json"), |
| 137 | filepath.Join(staticDir, "libvendor.cfi.a.json"), |
| 138 | filepath.Join(staticDir, "libvendor_available.a.json"), |
| 139 | filepath.Join(staticDir, "libvendor_available.cfi.a.json")) |
| 140 | |
| 141 | // For binary executables, all vendor:true and vendor_available modules are captured. |
| 142 | if archType == "arm64" { |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 143 | binaryVariant := fmt.Sprintf("android_vendor.29_%s_%s", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 144 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 145 | CheckSnapshot(t, ctx, snapshotSingleton, "vendor_bin", "vendor_bin", binaryDir, binaryVariant) |
| 146 | CheckSnapshot(t, ctx, snapshotSingleton, "vendor_available_bin", "vendor_available_bin", binaryDir, binaryVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 147 | jsonFiles = append(jsonFiles, |
| 148 | filepath.Join(binaryDir, "vendor_bin.json"), |
| 149 | filepath.Join(binaryDir, "vendor_available_bin.json")) |
| 150 | } |
| 151 | |
| 152 | // For header libraries, all vendor:true and vendor_available modules are captured. |
| 153 | headerDir := filepath.Join(snapshotVariantPath, archDir, "header") |
| 154 | jsonFiles = append(jsonFiles, filepath.Join(headerDir, "libvendor_headers.json")) |
| 155 | |
| 156 | // For object modules, all vendor:true and vendor_available modules are captured. |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 157 | objectVariant := fmt.Sprintf("android_vendor.29_%s_%s", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 158 | objectDir := filepath.Join(snapshotVariantPath, archDir, "object") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 159 | CheckSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 160 | jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json")) |
| 161 | } |
| 162 | |
| 163 | for _, jsonFile := range jsonFiles { |
| 164 | // verify all json files exist |
| 165 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 166 | t.Errorf("%q expected but not found", jsonFile) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // fake snapshot should have all outputs in the normal snapshot. |
| 171 | fakeSnapshotSingleton := ctx.SingletonForTests("vendor-fake-snapshot") |
| 172 | for _, output := range snapshotSingleton.AllOutputs() { |
| 173 | fakeOutput := strings.Replace(output, "/vendor-snapshot/", "/fake/vendor-snapshot/", 1) |
| 174 | if fakeSnapshotSingleton.MaybeOutput(fakeOutput).Rule == nil { |
| 175 | t.Errorf("%q expected but not found", fakeOutput) |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | func TestVendorSnapshotDirected(t *testing.T) { |
| 181 | bp := ` |
| 182 | cc_library_shared { |
| 183 | name: "libvendor", |
| 184 | vendor: true, |
| 185 | nocrt: true, |
| 186 | } |
| 187 | |
| 188 | cc_library_shared { |
| 189 | name: "libvendor_available", |
| 190 | vendor_available: true, |
| 191 | nocrt: true, |
| 192 | } |
| 193 | |
| 194 | genrule { |
| 195 | name: "libfoo_gen", |
| 196 | cmd: "", |
| 197 | out: ["libfoo.so"], |
| 198 | } |
| 199 | |
| 200 | cc_prebuilt_library_shared { |
| 201 | name: "libfoo", |
| 202 | vendor: true, |
| 203 | prefer: true, |
| 204 | srcs: [":libfoo_gen"], |
| 205 | } |
| 206 | |
| 207 | cc_library_shared { |
| 208 | name: "libfoo", |
| 209 | vendor: true, |
| 210 | nocrt: true, |
| 211 | } |
| 212 | ` |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 213 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 214 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 215 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 216 | config.TestProductVariables.DirectedVendorSnapshot = true |
| 217 | config.TestProductVariables.VendorSnapshotModules = make(map[string]bool) |
| 218 | config.TestProductVariables.VendorSnapshotModules["libvendor"] = true |
| 219 | config.TestProductVariables.VendorSnapshotModules["libfoo"] = true |
| 220 | ctx := testCcWithConfig(t, config) |
| 221 | |
| 222 | // Check Vendor snapshot output. |
| 223 | |
| 224 | snapshotDir := "vendor-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 225 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 226 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 227 | |
| 228 | var includeJsonFiles []string |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 229 | |
| 230 | for _, arch := range [][]string{ |
| 231 | []string{"arm64", "armv8-a"}, |
| 232 | []string{"arm", "armv7-a-neon"}, |
| 233 | } { |
| 234 | archType := arch[0] |
| 235 | archVariant := arch[1] |
| 236 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 237 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 238 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 239 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 240 | |
| 241 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 242 | CheckSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 243 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
| 244 | // Check that snapshot captures "prefer: true" prebuilt |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 245 | CheckSnapshot(t, ctx, snapshotSingleton, "prebuilt_libfoo", "libfoo.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 246 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libfoo.so.json")) |
| 247 | |
Jose Galmes | 0a942a0 | 2021-02-03 14:23:15 -0800 | [diff] [blame] | 248 | // Excluded modules. Modules not included in the directed vendor snapshot |
| 249 | // are still include as fake modules. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 250 | CheckSnapshotRule(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant) |
Jose Galmes | 0a942a0 | 2021-02-03 14:23:15 -0800 | [diff] [blame] | 251 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libvendor_available.so.json")) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | // Verify that each json file for an included module has a rule. |
| 255 | for _, jsonFile := range includeJsonFiles { |
| 256 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 257 | t.Errorf("include json file %q not found", jsonFile) |
| 258 | } |
| 259 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | func TestVendorSnapshotUse(t *testing.T) { |
| 263 | frameworkBp := ` |
| 264 | cc_library { |
| 265 | name: "libvndk", |
| 266 | vendor_available: true, |
| 267 | product_available: true, |
| 268 | vndk: { |
| 269 | enabled: true, |
| 270 | }, |
| 271 | nocrt: true, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | cc_library { |
| 275 | name: "libvendor", |
| 276 | vendor: true, |
| 277 | nocrt: true, |
| 278 | no_libcrt: true, |
| 279 | stl: "none", |
| 280 | system_shared_libs: [], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 281 | } |
| 282 | |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 283 | cc_library { |
| 284 | name: "libvendor_available", |
| 285 | vendor_available: true, |
| 286 | nocrt: true, |
| 287 | no_libcrt: true, |
| 288 | stl: "none", |
| 289 | system_shared_libs: [], |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | cc_library { |
| 293 | name: "lib32", |
| 294 | vendor: true, |
| 295 | nocrt: true, |
| 296 | no_libcrt: true, |
| 297 | stl: "none", |
| 298 | system_shared_libs: [], |
| 299 | compile_multilib: "32", |
| 300 | } |
| 301 | |
| 302 | cc_library { |
| 303 | name: "lib64", |
| 304 | vendor: true, |
| 305 | nocrt: true, |
| 306 | no_libcrt: true, |
| 307 | stl: "none", |
| 308 | system_shared_libs: [], |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 309 | compile_multilib: "64", |
| 310 | } |
| 311 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 312 | cc_library { |
| 313 | name: "libllndk", |
| 314 | llndk: { |
| 315 | symbol_file: "libllndk.map.txt", |
| 316 | }, |
| 317 | } |
| 318 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 319 | cc_binary { |
| 320 | name: "bin", |
| 321 | vendor: true, |
| 322 | nocrt: true, |
| 323 | no_libcrt: true, |
| 324 | stl: "none", |
| 325 | system_shared_libs: [], |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | cc_binary { |
| 329 | name: "bin32", |
| 330 | vendor: true, |
| 331 | nocrt: true, |
| 332 | no_libcrt: true, |
| 333 | stl: "none", |
| 334 | system_shared_libs: [], |
| 335 | compile_multilib: "32", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 336 | } |
| 337 | ` |
| 338 | |
| 339 | vndkBp := ` |
| 340 | vndk_prebuilt_shared { |
| 341 | name: "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 342 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 343 | target_arch: "arm64", |
| 344 | vendor_available: true, |
| 345 | product_available: true, |
| 346 | vndk: { |
| 347 | enabled: true, |
| 348 | }, |
| 349 | arch: { |
| 350 | arm64: { |
| 351 | srcs: ["libvndk.so"], |
| 352 | export_include_dirs: ["include/libvndk"], |
| 353 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 354 | arm: { |
| 355 | srcs: ["libvndk.so"], |
| 356 | export_include_dirs: ["include/libvndk"], |
| 357 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 358 | }, |
| 359 | } |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 360 | |
| 361 | // old snapshot module which has to be ignored |
| 362 | vndk_prebuilt_shared { |
| 363 | name: "libvndk", |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 364 | version: "26", |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 365 | target_arch: "arm64", |
| 366 | vendor_available: true, |
| 367 | product_available: true, |
| 368 | vndk: { |
| 369 | enabled: true, |
| 370 | }, |
| 371 | arch: { |
| 372 | arm64: { |
| 373 | srcs: ["libvndk.so"], |
| 374 | export_include_dirs: ["include/libvndk"], |
| 375 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 376 | arm: { |
| 377 | srcs: ["libvndk.so"], |
| 378 | export_include_dirs: ["include/libvndk"], |
| 379 | }, |
| 380 | }, |
| 381 | } |
| 382 | |
| 383 | // different arch snapshot which has to be ignored |
| 384 | vndk_prebuilt_shared { |
| 385 | name: "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 386 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 387 | target_arch: "arm", |
| 388 | vendor_available: true, |
| 389 | product_available: true, |
| 390 | vndk: { |
| 391 | enabled: true, |
| 392 | }, |
| 393 | arch: { |
| 394 | arm: { |
| 395 | srcs: ["libvndk.so"], |
| 396 | export_include_dirs: ["include/libvndk"], |
| 397 | }, |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 398 | }, |
| 399 | } |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 400 | |
| 401 | vndk_prebuilt_shared { |
| 402 | name: "libllndk", |
| 403 | version: "31", |
| 404 | target_arch: "arm64", |
| 405 | vendor_available: true, |
| 406 | product_available: true, |
| 407 | arch: { |
| 408 | arm64: { |
| 409 | srcs: ["libllndk.so"], |
| 410 | }, |
| 411 | arm: { |
| 412 | srcs: ["libllndk.so"], |
| 413 | }, |
| 414 | }, |
| 415 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 416 | ` |
| 417 | |
| 418 | vendorProprietaryBp := ` |
| 419 | cc_library { |
| 420 | name: "libvendor_without_snapshot", |
| 421 | vendor: true, |
| 422 | nocrt: true, |
| 423 | no_libcrt: true, |
| 424 | stl: "none", |
| 425 | system_shared_libs: [], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | cc_library_shared { |
| 429 | name: "libclient", |
| 430 | vendor: true, |
| 431 | nocrt: true, |
| 432 | no_libcrt: true, |
| 433 | stl: "none", |
| 434 | system_shared_libs: [], |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 435 | shared_libs: ["libvndk", "libvendor_available", "libllndk"], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 436 | static_libs: ["libvendor", "libvendor_without_snapshot"], |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 437 | arch: { |
| 438 | arm64: { |
| 439 | shared_libs: ["lib64"], |
| 440 | }, |
| 441 | arm: { |
| 442 | shared_libs: ["lib32"], |
| 443 | }, |
| 444 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 445 | srcs: ["client.cpp"], |
| 446 | } |
| 447 | |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 448 | cc_library_shared { |
| 449 | name: "libclient_cfi", |
| 450 | vendor: true, |
| 451 | nocrt: true, |
| 452 | no_libcrt: true, |
| 453 | stl: "none", |
| 454 | system_shared_libs: [], |
| 455 | static_libs: ["libvendor"], |
| 456 | sanitize: { |
| 457 | cfi: true, |
| 458 | }, |
| 459 | srcs: ["client.cpp"], |
| 460 | } |
| 461 | |
Justin Yun | 27b9572 | 2021-07-28 17:04:44 +0900 | [diff] [blame] | 462 | cc_library_shared { |
| 463 | name: "libvndkext", |
| 464 | vendor: true, |
| 465 | nocrt: true, |
| 466 | no_libcrt: true, |
| 467 | stl: "none", |
| 468 | system_shared_libs: [], |
| 469 | vndk: { |
| 470 | extends: "libvndk", |
| 471 | enabled: true, |
| 472 | } |
| 473 | } |
| 474 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 475 | cc_binary { |
| 476 | name: "bin_without_snapshot", |
| 477 | vendor: true, |
| 478 | nocrt: true, |
| 479 | no_libcrt: true, |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 480 | stl: "libc++_static", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 481 | system_shared_libs: [], |
| 482 | static_libs: ["libvndk"], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 483 | srcs: ["bin.cpp"], |
| 484 | } |
| 485 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 486 | vendor_snapshot { |
| 487 | name: "vendor_snapshot", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 488 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 489 | arch: { |
| 490 | arm64: { |
| 491 | vndk_libs: [ |
| 492 | "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 493 | "libllndk", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 494 | ], |
| 495 | static_libs: [ |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 496 | "libc++_static", |
| 497 | "libc++demangle", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 498 | "libunwind", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 499 | "libvendor", |
| 500 | "libvendor_available", |
| 501 | "libvndk", |
| 502 | "lib64", |
| 503 | ], |
| 504 | shared_libs: [ |
| 505 | "libvendor", |
| 506 | "libvendor_available", |
| 507 | "lib64", |
| 508 | ], |
| 509 | binaries: [ |
| 510 | "bin", |
| 511 | ], |
| 512 | }, |
| 513 | arm: { |
| 514 | vndk_libs: [ |
| 515 | "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 516 | "libllndk", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 517 | ], |
| 518 | static_libs: [ |
| 519 | "libvendor", |
| 520 | "libvendor_available", |
| 521 | "libvndk", |
| 522 | "lib32", |
| 523 | ], |
| 524 | shared_libs: [ |
| 525 | "libvendor", |
| 526 | "libvendor_available", |
| 527 | "lib32", |
| 528 | ], |
| 529 | binaries: [ |
| 530 | "bin32", |
| 531 | ], |
| 532 | }, |
| 533 | } |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 534 | } |
| 535 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 536 | vendor_snapshot_static { |
| 537 | name: "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 538 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 539 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 540 | compile_multilib: "both", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 541 | vendor: true, |
| 542 | arch: { |
| 543 | arm64: { |
| 544 | src: "libvndk.a", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 545 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 546 | arm: { |
| 547 | src: "libvndk.a", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 548 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 549 | }, |
Inseob Kim | dd0295d | 2021-04-12 21:09:59 +0900 | [diff] [blame] | 550 | shared_libs: ["libvndk"], |
| 551 | export_shared_lib_headers: ["libvndk"], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | vendor_snapshot_shared { |
| 555 | name: "libvendor", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 556 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 557 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 558 | compile_multilib: "both", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 559 | vendor: true, |
Justin Yun | 4813867 | 2021-02-25 18:21:27 +0900 | [diff] [blame] | 560 | shared_libs: [ |
| 561 | "libvendor_without_snapshot", |
| 562 | "libvendor_available", |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 563 | "libvndk", |
Justin Yun | 4813867 | 2021-02-25 18:21:27 +0900 | [diff] [blame] | 564 | ], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 565 | arch: { |
| 566 | arm64: { |
| 567 | src: "libvendor.so", |
| 568 | export_include_dirs: ["include/libvendor"], |
| 569 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 570 | arm: { |
| 571 | src: "libvendor.so", |
| 572 | export_include_dirs: ["include/libvendor"], |
| 573 | }, |
| 574 | }, |
| 575 | } |
| 576 | |
| 577 | vendor_snapshot_static { |
| 578 | name: "lib32", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 579 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 580 | target_arch: "arm64", |
| 581 | compile_multilib: "32", |
| 582 | vendor: true, |
| 583 | arch: { |
| 584 | arm: { |
| 585 | src: "lib32.a", |
| 586 | }, |
| 587 | }, |
| 588 | } |
| 589 | |
| 590 | vendor_snapshot_shared { |
| 591 | name: "lib32", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 592 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 593 | target_arch: "arm64", |
| 594 | compile_multilib: "32", |
| 595 | vendor: true, |
| 596 | arch: { |
| 597 | arm: { |
| 598 | src: "lib32.so", |
| 599 | }, |
| 600 | }, |
| 601 | } |
| 602 | |
| 603 | vendor_snapshot_static { |
| 604 | name: "lib64", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 605 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 606 | target_arch: "arm64", |
| 607 | compile_multilib: "64", |
| 608 | vendor: true, |
| 609 | arch: { |
| 610 | arm64: { |
| 611 | src: "lib64.a", |
| 612 | }, |
| 613 | }, |
| 614 | } |
| 615 | |
| 616 | vendor_snapshot_shared { |
| 617 | name: "lib64", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 618 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 619 | target_arch: "arm64", |
| 620 | compile_multilib: "64", |
| 621 | vendor: true, |
| 622 | arch: { |
| 623 | arm64: { |
| 624 | src: "lib64.so", |
| 625 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 626 | }, |
| 627 | } |
| 628 | |
| 629 | vendor_snapshot_static { |
| 630 | name: "libvendor", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 631 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 632 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 633 | compile_multilib: "both", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 634 | vendor: true, |
| 635 | arch: { |
| 636 | arm64: { |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 637 | cfi: { |
| 638 | src: "libvendor.cfi.a", |
| 639 | export_include_dirs: ["include/libvendor_cfi"], |
| 640 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 641 | src: "libvendor.a", |
| 642 | export_include_dirs: ["include/libvendor"], |
| 643 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 644 | arm: { |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 645 | cfi: { |
| 646 | src: "libvendor.cfi.a", |
| 647 | export_include_dirs: ["include/libvendor_cfi"], |
| 648 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 649 | src: "libvendor.a", |
| 650 | export_include_dirs: ["include/libvendor"], |
| 651 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 652 | }, |
| 653 | } |
| 654 | |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 655 | vendor_snapshot_shared { |
| 656 | name: "libvendor_available", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 657 | version: "31", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 658 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 659 | compile_multilib: "both", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 660 | vendor: true, |
| 661 | arch: { |
| 662 | arm64: { |
| 663 | src: "libvendor_available.so", |
| 664 | export_include_dirs: ["include/libvendor"], |
| 665 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 666 | arm: { |
| 667 | src: "libvendor_available.so", |
| 668 | export_include_dirs: ["include/libvendor"], |
| 669 | }, |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 670 | }, |
| 671 | } |
| 672 | |
| 673 | vendor_snapshot_static { |
| 674 | name: "libvendor_available", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 675 | version: "31", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 676 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 677 | compile_multilib: "both", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 678 | vendor: true, |
| 679 | arch: { |
| 680 | arm64: { |
| 681 | src: "libvendor_available.a", |
| 682 | export_include_dirs: ["include/libvendor"], |
| 683 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 684 | arm: { |
| 685 | src: "libvendor_available.so", |
| 686 | export_include_dirs: ["include/libvendor"], |
| 687 | }, |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 688 | }, |
| 689 | } |
| 690 | |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 691 | vendor_snapshot_static { |
| 692 | name: "libc++_static", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 693 | version: "31", |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 694 | target_arch: "arm64", |
| 695 | compile_multilib: "64", |
| 696 | vendor: true, |
| 697 | arch: { |
| 698 | arm64: { |
| 699 | src: "libc++_static.a", |
| 700 | }, |
| 701 | }, |
| 702 | } |
| 703 | |
| 704 | vendor_snapshot_static { |
| 705 | name: "libc++demangle", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 706 | version: "31", |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 707 | target_arch: "arm64", |
| 708 | compile_multilib: "64", |
| 709 | vendor: true, |
| 710 | arch: { |
| 711 | arm64: { |
| 712 | src: "libc++demangle.a", |
| 713 | }, |
| 714 | }, |
| 715 | } |
| 716 | |
| 717 | vendor_snapshot_static { |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 718 | name: "libunwind", |
| 719 | version: "31", |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 720 | target_arch: "arm64", |
| 721 | compile_multilib: "64", |
| 722 | vendor: true, |
| 723 | arch: { |
| 724 | arm64: { |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 725 | src: "libunwind.a", |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 726 | }, |
| 727 | }, |
| 728 | } |
| 729 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 730 | vendor_snapshot_binary { |
| 731 | name: "bin", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 732 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 733 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 734 | compile_multilib: "64", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 735 | vendor: true, |
| 736 | arch: { |
| 737 | arm64: { |
| 738 | src: "bin", |
| 739 | }, |
| 740 | }, |
| 741 | } |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 742 | |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 743 | vendor_snapshot_binary { |
| 744 | name: "bin32", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 745 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 746 | target_arch: "arm64", |
| 747 | compile_multilib: "32", |
| 748 | vendor: true, |
| 749 | arch: { |
| 750 | arm: { |
| 751 | src: "bin32", |
| 752 | }, |
| 753 | }, |
| 754 | } |
| 755 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 756 | // old snapshot module which has to be ignored |
| 757 | vendor_snapshot_binary { |
| 758 | name: "bin", |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 759 | version: "26", |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 760 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 761 | compile_multilib: "first", |
| 762 | vendor: true, |
| 763 | arch: { |
| 764 | arm64: { |
| 765 | src: "bin", |
| 766 | }, |
| 767 | }, |
| 768 | } |
| 769 | |
| 770 | // different arch snapshot which has to be ignored |
| 771 | vendor_snapshot_binary { |
| 772 | name: "bin", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 773 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 774 | target_arch: "arm", |
| 775 | compile_multilib: "first", |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 776 | vendor: true, |
| 777 | arch: { |
| 778 | arm64: { |
| 779 | src: "bin", |
| 780 | }, |
| 781 | }, |
| 782 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 783 | ` |
| 784 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 785 | |
| 786 | mockFS := map[string][]byte{ |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 787 | "deps/Android.bp": []byte(depsBp), |
| 788 | "framework/Android.bp": []byte(frameworkBp), |
| 789 | "framework/symbol.txt": nil, |
| 790 | "vendor/Android.bp": []byte(vendorProprietaryBp), |
| 791 | "vendor/bin": nil, |
| 792 | "vendor/bin32": nil, |
| 793 | "vendor/bin.cpp": nil, |
| 794 | "vendor/client.cpp": nil, |
| 795 | "vendor/include/libvndk/a.h": nil, |
| 796 | "vendor/include/libvendor/b.h": nil, |
| 797 | "vendor/include/libvendor_cfi/c.h": nil, |
| 798 | "vendor/libc++_static.a": nil, |
| 799 | "vendor/libc++demangle.a": nil, |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 800 | "vendor/libunwind.a": nil, |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 801 | "vendor/libvndk.a": nil, |
| 802 | "vendor/libvendor.a": nil, |
| 803 | "vendor/libvendor.cfi.a": nil, |
| 804 | "vendor/libvendor.so": nil, |
| 805 | "vendor/lib32.a": nil, |
| 806 | "vendor/lib32.so": nil, |
| 807 | "vendor/lib64.a": nil, |
| 808 | "vendor/lib64.so": nil, |
| 809 | "vndk/Android.bp": []byte(vndkBp), |
| 810 | "vndk/include/libvndk/a.h": nil, |
| 811 | "vndk/libvndk.so": nil, |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 812 | "vndk/libllndk.so": nil, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 813 | } |
| 814 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 815 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 816 | config.TestProductVariables.DeviceVndkVersion = StringPtr("31") |
| 817 | config.TestProductVariables.Platform_vndk_version = StringPtr("32") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 818 | ctx := CreateTestContext(config) |
| 819 | ctx.Register() |
| 820 | |
| 821 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "vendor/Android.bp", "vndk/Android.bp"}) |
| 822 | android.FailIfErrored(t, errs) |
| 823 | _, errs = ctx.PrepareBuildActions(config) |
| 824 | android.FailIfErrored(t, errs) |
| 825 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 826 | sharedVariant := "android_vendor.31_arm64_armv8-a_shared" |
| 827 | staticVariant := "android_vendor.31_arm64_armv8-a_static" |
| 828 | binaryVariant := "android_vendor.31_arm64_armv8-a" |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 829 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 830 | sharedCfiVariant := "android_vendor.31_arm64_armv8-a_shared_cfi" |
| 831 | staticCfiVariant := "android_vendor.31_arm64_armv8-a_static_cfi" |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 832 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 833 | shared32Variant := "android_vendor.31_arm_armv7-a-neon_shared" |
| 834 | binary32Variant := "android_vendor.31_arm_armv7-a-neon" |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 835 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 836 | // libclient uses libvndk.vndk.31.arm64, libvendor.vendor_static.31.arm64, libvendor_without_snapshot |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 837 | libclientCcFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("cc").Args["cFlags"] |
| 838 | for _, includeFlags := range []string{ |
| 839 | "-Ivndk/include/libvndk", // libvndk |
| 840 | "-Ivendor/include/libvendor", // libvendor |
| 841 | } { |
| 842 | if !strings.Contains(libclientCcFlags, includeFlags) { |
| 843 | t.Errorf("flags for libclient must contain %#v, but was %#v.", |
| 844 | includeFlags, libclientCcFlags) |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | libclientLdFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("ld").Args["libFlags"] |
| 849 | for _, input := range [][]string{ |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 850 | []string{sharedVariant, "libvndk.vndk.31.arm64"}, |
| 851 | []string{sharedVariant, "libllndk.vndk.31.arm64"}, |
| 852 | []string{staticVariant, "libvendor.vendor_static.31.arm64"}, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 853 | []string{staticVariant, "libvendor_without_snapshot"}, |
| 854 | } { |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 855 | outputPaths := GetOutputPaths(ctx, input[0] /* variant */, []string{input[1]} /* module name */) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 856 | if !strings.Contains(libclientLdFlags, outputPaths[0].String()) { |
| 857 | t.Errorf("libflags for libclient must contain %#v, but was %#v", outputPaths[0], libclientLdFlags) |
| 858 | } |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 859 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 860 | } |
| 861 | |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 862 | libclientAndroidMkSharedLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkSharedLibs |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 863 | if g, w := libclientAndroidMkSharedLibs, []string{"libvndk.vendor", "libvendor_available.vendor", "libllndk.vendor", "lib64"}; !reflect.DeepEqual(g, w) { |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 864 | t.Errorf("wanted libclient AndroidMkSharedLibs %q, got %q", w, g) |
| 865 | } |
| 866 | |
| 867 | libclientAndroidMkStaticLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkStaticLibs |
| 868 | if g, w := libclientAndroidMkStaticLibs, []string{"libvendor", "libvendor_without_snapshot"}; !reflect.DeepEqual(g, w) { |
| 869 | t.Errorf("wanted libclient AndroidMkStaticLibs %q, got %q", w, g) |
| 870 | } |
| 871 | |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 872 | libclient32AndroidMkSharedLibs := ctx.ModuleForTests("libclient", shared32Variant).Module().(*Module).Properties.AndroidMkSharedLibs |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 873 | if g, w := libclient32AndroidMkSharedLibs, []string{"libvndk.vendor", "libvendor_available.vendor", "libllndk.vendor", "lib32"}; !reflect.DeepEqual(g, w) { |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 874 | t.Errorf("wanted libclient32 AndroidMkSharedLibs %q, got %q", w, g) |
| 875 | } |
| 876 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 877 | // libclient_cfi uses libvendor.vendor_static.31.arm64's cfi variant |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 878 | libclientCfiCcFlags := ctx.ModuleForTests("libclient_cfi", sharedCfiVariant).Rule("cc").Args["cFlags"] |
| 879 | if !strings.Contains(libclientCfiCcFlags, "-Ivendor/include/libvendor_cfi") { |
| 880 | t.Errorf("flags for libclient_cfi must contain %#v, but was %#v.", |
| 881 | "-Ivendor/include/libvendor_cfi", libclientCfiCcFlags) |
| 882 | } |
| 883 | |
| 884 | libclientCfiLdFlags := ctx.ModuleForTests("libclient_cfi", sharedCfiVariant).Rule("ld").Args["libFlags"] |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 885 | libvendorCfiOutputPaths := GetOutputPaths(ctx, staticCfiVariant, []string{"libvendor.vendor_static.31.arm64"}) |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 886 | if !strings.Contains(libclientCfiLdFlags, libvendorCfiOutputPaths[0].String()) { |
| 887 | t.Errorf("libflags for libclientCfi must contain %#v, but was %#v", libvendorCfiOutputPaths[0], libclientCfiLdFlags) |
| 888 | } |
| 889 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 890 | // bin_without_snapshot uses libvndk.vendor_static.31.arm64 (which reexports vndk's exported headers) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 891 | binWithoutSnapshotCcFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("cc").Args["cFlags"] |
Inseob Kim | dd0295d | 2021-04-12 21:09:59 +0900 | [diff] [blame] | 892 | if !strings.Contains(binWithoutSnapshotCcFlags, "-Ivndk/include/libvndk") { |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 893 | t.Errorf("flags for bin_without_snapshot must contain %#v, but was %#v.", |
| 894 | "-Ivendor/include/libvndk", binWithoutSnapshotCcFlags) |
| 895 | } |
| 896 | |
| 897 | binWithoutSnapshotLdFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("ld").Args["libFlags"] |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 898 | libVndkStaticOutputPaths := GetOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.31.arm64"}) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 899 | if !strings.Contains(binWithoutSnapshotLdFlags, libVndkStaticOutputPaths[0].String()) { |
| 900 | t.Errorf("libflags for bin_without_snapshot must contain %#v, but was %#v", |
| 901 | libVndkStaticOutputPaths[0], binWithoutSnapshotLdFlags) |
| 902 | } |
| 903 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 904 | // libvendor.so is installed by libvendor.vendor_shared.31.arm64 |
| 905 | ctx.ModuleForTests("libvendor.vendor_shared.31.arm64", sharedVariant).Output("libvendor.so") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 906 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 907 | // lib64.so is installed by lib64.vendor_shared.31.arm64 |
| 908 | ctx.ModuleForTests("lib64.vendor_shared.31.arm64", sharedVariant).Output("lib64.so") |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 909 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 910 | // lib32.so is installed by lib32.vendor_shared.31.arm64 |
| 911 | ctx.ModuleForTests("lib32.vendor_shared.31.arm64", shared32Variant).Output("lib32.so") |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 912 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 913 | // libvendor_available.so is installed by libvendor_available.vendor_shared.31.arm64 |
| 914 | ctx.ModuleForTests("libvendor_available.vendor_shared.31.arm64", sharedVariant).Output("libvendor_available.so") |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 915 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 916 | // libvendor_without_snapshot.so is installed by libvendor_without_snapshot |
| 917 | ctx.ModuleForTests("libvendor_without_snapshot", sharedVariant).Output("libvendor_without_snapshot.so") |
| 918 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 919 | // bin is installed by bin.vendor_binary.31.arm64 |
| 920 | ctx.ModuleForTests("bin.vendor_binary.31.arm64", binaryVariant).Output("bin") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 921 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 922 | // bin32 is installed by bin32.vendor_binary.31.arm64 |
| 923 | ctx.ModuleForTests("bin32.vendor_binary.31.arm64", binary32Variant).Output("bin32") |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 924 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 925 | // bin_without_snapshot is installed by bin_without_snapshot |
| 926 | ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot") |
| 927 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 928 | // libvendor, libvendor_available and bin don't have vendor.31 variant |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 929 | libvendorVariants := ctx.ModuleVariantsForTests("libvendor") |
| 930 | if inList(sharedVariant, libvendorVariants) { |
| 931 | t.Errorf("libvendor must not have variant %#v, but it does", sharedVariant) |
| 932 | } |
| 933 | |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 934 | libvendorAvailableVariants := ctx.ModuleVariantsForTests("libvendor_available") |
| 935 | if inList(sharedVariant, libvendorAvailableVariants) { |
| 936 | t.Errorf("libvendor_available must not have variant %#v, but it does", sharedVariant) |
| 937 | } |
| 938 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 939 | binVariants := ctx.ModuleVariantsForTests("bin") |
| 940 | if inList(binaryVariant, binVariants) { |
| 941 | t.Errorf("bin must not have variant %#v, but it does", sharedVariant) |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | func TestVendorSnapshotSanitizer(t *testing.T) { |
| 946 | bp := ` |
Inseob Kim | 253f521 | 2021-04-08 17:10:31 +0900 | [diff] [blame] | 947 | vendor_snapshot { |
| 948 | name: "vendor_snapshot", |
| 949 | version: "28", |
| 950 | arch: { |
| 951 | arm64: { |
| 952 | static_libs: [ |
| 953 | "libsnapshot", |
| 954 | "note_memtag_heap_sync", |
| 955 | ], |
| 956 | }, |
| 957 | }, |
| 958 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 959 | vendor_snapshot_static { |
| 960 | name: "libsnapshot", |
| 961 | vendor: true, |
| 962 | target_arch: "arm64", |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 963 | version: "28", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 964 | arch: { |
| 965 | arm64: { |
| 966 | src: "libsnapshot.a", |
| 967 | cfi: { |
| 968 | src: "libsnapshot.cfi.a", |
| 969 | } |
| 970 | }, |
| 971 | }, |
| 972 | } |
Inseob Kim | 253f521 | 2021-04-08 17:10:31 +0900 | [diff] [blame] | 973 | |
| 974 | vendor_snapshot_static { |
| 975 | name: "note_memtag_heap_sync", |
| 976 | vendor: true, |
| 977 | target_arch: "arm64", |
| 978 | version: "28", |
| 979 | arch: { |
| 980 | arm64: { |
| 981 | src: "note_memtag_heap_sync.a", |
| 982 | }, |
| 983 | }, |
| 984 | } |
| 985 | |
| 986 | cc_test { |
| 987 | name: "vstest", |
| 988 | gtest: false, |
| 989 | vendor: true, |
| 990 | compile_multilib: "64", |
| 991 | nocrt: true, |
| 992 | no_libcrt: true, |
| 993 | stl: "none", |
| 994 | static_libs: ["libsnapshot"], |
| 995 | system_shared_libs: [], |
| 996 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 997 | ` |
Inseob Kim | 253f521 | 2021-04-08 17:10:31 +0900 | [diff] [blame] | 998 | |
| 999 | mockFS := map[string][]byte{ |
| 1000 | "vendor/Android.bp": []byte(bp), |
| 1001 | "vendor/libc++demangle.a": nil, |
| 1002 | "vendor/libsnapshot.a": nil, |
| 1003 | "vendor/libsnapshot.cfi.a": nil, |
| 1004 | "vendor/note_memtag_heap_sync.a": nil, |
| 1005 | } |
| 1006 | |
| 1007 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1008 | config.TestProductVariables.DeviceVndkVersion = StringPtr("28") |
| 1009 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1010 | ctx := testCcWithConfig(t, config) |
| 1011 | |
| 1012 | // Check non-cfi and cfi variant. |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1013 | staticVariant := "android_vendor.28_arm64_armv8-a_static" |
| 1014 | staticCfiVariant := "android_vendor.28_arm64_armv8-a_static_cfi" |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1015 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1016 | staticModule := ctx.ModuleForTests("libsnapshot.vendor_static.28.arm64", staticVariant).Module().(*Module) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1017 | assertString(t, staticModule.outputFile.Path().Base(), "libsnapshot.a") |
| 1018 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1019 | staticCfiModule := ctx.ModuleForTests("libsnapshot.vendor_static.28.arm64", staticCfiVariant).Module().(*Module) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1020 | assertString(t, staticCfiModule.outputFile.Path().Base(), "libsnapshot.cfi.a") |
| 1021 | } |
| 1022 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1023 | func TestVendorSnapshotExclude(t *testing.T) { |
| 1024 | |
| 1025 | // This test verifies that the exclude_from_vendor_snapshot property |
| 1026 | // makes its way from the Android.bp source file into the module data |
| 1027 | // structure. It also verifies that modules are correctly included or |
| 1028 | // excluded in the vendor snapshot based on their path (framework or |
| 1029 | // vendor) and the exclude_from_vendor_snapshot property. |
| 1030 | |
| 1031 | frameworkBp := ` |
| 1032 | cc_library_shared { |
| 1033 | name: "libinclude", |
| 1034 | srcs: ["src/include.cpp"], |
| 1035 | vendor_available: true, |
| 1036 | } |
| 1037 | cc_library_shared { |
| 1038 | name: "libexclude", |
| 1039 | srcs: ["src/exclude.cpp"], |
| 1040 | vendor: true, |
| 1041 | exclude_from_vendor_snapshot: true, |
| 1042 | } |
| 1043 | cc_library_shared { |
| 1044 | name: "libavailable_exclude", |
| 1045 | srcs: ["src/exclude.cpp"], |
| 1046 | vendor_available: true, |
| 1047 | exclude_from_vendor_snapshot: true, |
| 1048 | } |
| 1049 | ` |
| 1050 | |
| 1051 | vendorProprietaryBp := ` |
| 1052 | cc_library_shared { |
| 1053 | name: "libvendor", |
| 1054 | srcs: ["vendor.cpp"], |
| 1055 | vendor: true, |
| 1056 | } |
| 1057 | ` |
| 1058 | |
| 1059 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1060 | |
| 1061 | mockFS := map[string][]byte{ |
| 1062 | "deps/Android.bp": []byte(depsBp), |
| 1063 | "framework/Android.bp": []byte(frameworkBp), |
| 1064 | "framework/include.cpp": nil, |
| 1065 | "framework/exclude.cpp": nil, |
| 1066 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1067 | "device/vendor.cpp": nil, |
| 1068 | } |
| 1069 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1070 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1071 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1072 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1073 | ctx := CreateTestContext(config) |
| 1074 | ctx.Register() |
| 1075 | |
| 1076 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1077 | android.FailIfErrored(t, errs) |
| 1078 | _, errs = ctx.PrepareBuildActions(config) |
| 1079 | android.FailIfErrored(t, errs) |
| 1080 | |
| 1081 | // Test an include and exclude framework module. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1082 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libinclude", false, vendorVariant) |
| 1083 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libexclude", true, vendorVariant) |
| 1084 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libavailable_exclude", true, vendorVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1085 | |
| 1086 | // A vendor module is excluded, but by its path, not the |
| 1087 | // exclude_from_vendor_snapshot property. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1088 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libvendor", false, vendorVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1089 | |
| 1090 | // Verify the content of the vendor snapshot. |
| 1091 | |
| 1092 | snapshotDir := "vendor-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1093 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1094 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 1095 | |
| 1096 | var includeJsonFiles []string |
| 1097 | var excludeJsonFiles []string |
| 1098 | |
| 1099 | for _, arch := range [][]string{ |
| 1100 | []string{"arm64", "armv8-a"}, |
| 1101 | []string{"arm", "armv7-a-neon"}, |
| 1102 | } { |
| 1103 | archType := arch[0] |
| 1104 | archVariant := arch[1] |
| 1105 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1106 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1107 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1108 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1109 | |
| 1110 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1111 | CheckSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1112 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1113 | |
| 1114 | // Excluded modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1115 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1116 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1117 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1118 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1119 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1120 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| 1121 | } |
| 1122 | |
| 1123 | // Verify that each json file for an included module has a rule. |
| 1124 | for _, jsonFile := range includeJsonFiles { |
| 1125 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1126 | t.Errorf("include json file %q not found", jsonFile) |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | // Verify that each json file for an excluded module has no rule. |
| 1131 | for _, jsonFile := range excludeJsonFiles { |
| 1132 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1133 | t.Errorf("exclude json file %q found", jsonFile) |
| 1134 | } |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) { |
| 1139 | |
| 1140 | // This test verifies that using the exclude_from_vendor_snapshot |
| 1141 | // property on a module in a vendor proprietary path generates an |
| 1142 | // error. These modules are already excluded, so we prohibit using the |
| 1143 | // property in this way, which could add to confusion. |
| 1144 | |
| 1145 | vendorProprietaryBp := ` |
| 1146 | cc_library_shared { |
| 1147 | name: "libvendor", |
| 1148 | srcs: ["vendor.cpp"], |
| 1149 | vendor: true, |
| 1150 | exclude_from_vendor_snapshot: true, |
| 1151 | } |
| 1152 | ` |
| 1153 | |
| 1154 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1155 | |
| 1156 | mockFS := map[string][]byte{ |
| 1157 | "deps/Android.bp": []byte(depsBp), |
| 1158 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1159 | "device/vendor.cpp": nil, |
| 1160 | } |
| 1161 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1162 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1163 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1164 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1165 | ctx := CreateTestContext(config) |
| 1166 | ctx.Register() |
| 1167 | |
| 1168 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"}) |
| 1169 | android.FailIfErrored(t, errs) |
| 1170 | |
| 1171 | _, errs = ctx.PrepareBuildActions(config) |
| 1172 | android.CheckErrorsAgainstExpectations(t, errs, []string{ |
| 1173 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1174 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1175 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1176 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1177 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1178 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1179 | }) |
| 1180 | } |
| 1181 | |
| 1182 | func TestRecoverySnapshotCapture(t *testing.T) { |
| 1183 | bp := ` |
| 1184 | cc_library { |
| 1185 | name: "libvndk", |
| 1186 | vendor_available: true, |
| 1187 | recovery_available: true, |
| 1188 | product_available: true, |
| 1189 | vndk: { |
| 1190 | enabled: true, |
| 1191 | }, |
| 1192 | nocrt: true, |
| 1193 | } |
| 1194 | |
| 1195 | cc_library { |
| 1196 | name: "librecovery", |
| 1197 | recovery: true, |
| 1198 | nocrt: true, |
| 1199 | } |
| 1200 | |
| 1201 | cc_library { |
| 1202 | name: "librecovery_available", |
| 1203 | recovery_available: true, |
| 1204 | nocrt: true, |
| 1205 | } |
| 1206 | |
| 1207 | cc_library_headers { |
| 1208 | name: "librecovery_headers", |
| 1209 | recovery_available: true, |
| 1210 | nocrt: true, |
| 1211 | } |
| 1212 | |
| 1213 | cc_binary { |
| 1214 | name: "recovery_bin", |
| 1215 | recovery: true, |
| 1216 | nocrt: true, |
| 1217 | } |
| 1218 | |
| 1219 | cc_binary { |
| 1220 | name: "recovery_available_bin", |
| 1221 | recovery_available: true, |
| 1222 | nocrt: true, |
| 1223 | } |
| 1224 | |
| 1225 | toolchain_library { |
| 1226 | name: "libb", |
| 1227 | recovery_available: true, |
| 1228 | src: "libb.a", |
| 1229 | } |
| 1230 | |
| 1231 | cc_object { |
| 1232 | name: "obj", |
| 1233 | recovery_available: true, |
| 1234 | } |
| 1235 | ` |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1236 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1237 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1238 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1239 | ctx := testCcWithConfig(t, config) |
| 1240 | |
| 1241 | // Check Recovery snapshot output. |
| 1242 | |
| 1243 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1244 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1245 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1246 | |
| 1247 | var jsonFiles []string |
| 1248 | |
| 1249 | for _, arch := range [][]string{ |
| 1250 | []string{"arm64", "armv8-a"}, |
| 1251 | } { |
| 1252 | archType := arch[0] |
| 1253 | archVariant := arch[1] |
| 1254 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1255 | |
| 1256 | // For shared libraries, only recovery_available modules are captured. |
| 1257 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1258 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1259 | CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", sharedDir, sharedVariant) |
| 1260 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
| 1261 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1262 | jsonFiles = append(jsonFiles, |
| 1263 | filepath.Join(sharedDir, "libvndk.so.json"), |
| 1264 | filepath.Join(sharedDir, "librecovery.so.json"), |
| 1265 | filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1266 | |
| 1267 | // For static libraries, all recovery:true and recovery_available modules are captured. |
| 1268 | staticVariant := fmt.Sprintf("android_recovery_%s_%s_static", archType, archVariant) |
| 1269 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1270 | CheckSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant) |
| 1271 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.a", staticDir, staticVariant) |
| 1272 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.a", staticDir, staticVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1273 | jsonFiles = append(jsonFiles, |
| 1274 | filepath.Join(staticDir, "libb.a.json"), |
| 1275 | filepath.Join(staticDir, "librecovery.a.json"), |
| 1276 | filepath.Join(staticDir, "librecovery_available.a.json")) |
| 1277 | |
| 1278 | // For binary executables, all recovery:true and recovery_available modules are captured. |
| 1279 | if archType == "arm64" { |
| 1280 | binaryVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1281 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1282 | CheckSnapshot(t, ctx, snapshotSingleton, "recovery_bin", "recovery_bin", binaryDir, binaryVariant) |
| 1283 | CheckSnapshot(t, ctx, snapshotSingleton, "recovery_available_bin", "recovery_available_bin", binaryDir, binaryVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1284 | jsonFiles = append(jsonFiles, |
| 1285 | filepath.Join(binaryDir, "recovery_bin.json"), |
| 1286 | filepath.Join(binaryDir, "recovery_available_bin.json")) |
| 1287 | } |
| 1288 | |
| 1289 | // For header libraries, all vendor:true and vendor_available modules are captured. |
| 1290 | headerDir := filepath.Join(snapshotVariantPath, archDir, "header") |
| 1291 | jsonFiles = append(jsonFiles, filepath.Join(headerDir, "librecovery_headers.json")) |
| 1292 | |
| 1293 | // For object modules, all vendor:true and vendor_available modules are captured. |
| 1294 | objectVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1295 | objectDir := filepath.Join(snapshotVariantPath, archDir, "object") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1296 | CheckSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1297 | jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json")) |
| 1298 | } |
| 1299 | |
| 1300 | for _, jsonFile := range jsonFiles { |
| 1301 | // verify all json files exist |
| 1302 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1303 | t.Errorf("%q expected but not found", jsonFile) |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | func TestRecoverySnapshotExclude(t *testing.T) { |
| 1309 | // This test verifies that the exclude_from_recovery_snapshot property |
| 1310 | // makes its way from the Android.bp source file into the module data |
| 1311 | // structure. It also verifies that modules are correctly included or |
| 1312 | // excluded in the recovery snapshot based on their path (framework or |
| 1313 | // vendor) and the exclude_from_recovery_snapshot property. |
| 1314 | |
| 1315 | frameworkBp := ` |
| 1316 | cc_library_shared { |
| 1317 | name: "libinclude", |
| 1318 | srcs: ["src/include.cpp"], |
| 1319 | recovery_available: true, |
| 1320 | } |
| 1321 | cc_library_shared { |
| 1322 | name: "libexclude", |
| 1323 | srcs: ["src/exclude.cpp"], |
| 1324 | recovery: true, |
| 1325 | exclude_from_recovery_snapshot: true, |
| 1326 | } |
| 1327 | cc_library_shared { |
| 1328 | name: "libavailable_exclude", |
| 1329 | srcs: ["src/exclude.cpp"], |
| 1330 | recovery_available: true, |
| 1331 | exclude_from_recovery_snapshot: true, |
| 1332 | } |
| 1333 | ` |
| 1334 | |
| 1335 | vendorProprietaryBp := ` |
| 1336 | cc_library_shared { |
| 1337 | name: "librecovery", |
| 1338 | srcs: ["recovery.cpp"], |
| 1339 | recovery: true, |
| 1340 | } |
| 1341 | ` |
| 1342 | |
| 1343 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1344 | |
| 1345 | mockFS := map[string][]byte{ |
| 1346 | "deps/Android.bp": []byte(depsBp), |
| 1347 | "framework/Android.bp": []byte(frameworkBp), |
| 1348 | "framework/include.cpp": nil, |
| 1349 | "framework/exclude.cpp": nil, |
| 1350 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1351 | "device/recovery.cpp": nil, |
| 1352 | } |
| 1353 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1354 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1355 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1356 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1357 | ctx := CreateTestContext(config) |
| 1358 | ctx.Register() |
| 1359 | |
| 1360 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1361 | android.FailIfErrored(t, errs) |
| 1362 | _, errs = ctx.PrepareBuildActions(config) |
| 1363 | android.FailIfErrored(t, errs) |
| 1364 | |
| 1365 | // Test an include and exclude framework module. |
Ivan Lozano | c2ca1ee | 2021-11-09 16:23:40 -0500 | [diff] [blame^] | 1366 | AssertExcludeFromRecoverySnapshotIs(t, ctx, "libinclude", false, recoveryVariant) |
| 1367 | AssertExcludeFromRecoverySnapshotIs(t, ctx, "libexclude", true, recoveryVariant) |
| 1368 | AssertExcludeFromRecoverySnapshotIs(t, ctx, "libavailable_exclude", true, recoveryVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1369 | |
| 1370 | // A recovery module is excluded, but by its path, not the |
| 1371 | // exclude_from_recovery_snapshot property. |
Ivan Lozano | c2ca1ee | 2021-11-09 16:23:40 -0500 | [diff] [blame^] | 1372 | AssertExcludeFromRecoverySnapshotIs(t, ctx, "librecovery", false, recoveryVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1373 | |
| 1374 | // Verify the content of the recovery snapshot. |
| 1375 | |
| 1376 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1377 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1378 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1379 | |
| 1380 | var includeJsonFiles []string |
| 1381 | var excludeJsonFiles []string |
| 1382 | |
| 1383 | for _, arch := range [][]string{ |
| 1384 | []string{"arm64", "armv8-a"}, |
| 1385 | } { |
| 1386 | archType := arch[0] |
| 1387 | archVariant := arch[1] |
| 1388 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1389 | |
| 1390 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1391 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1392 | |
| 1393 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1394 | CheckSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1395 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1396 | |
| 1397 | // Excluded modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1398 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1399 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1400 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1401 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1402 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1403 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| 1404 | } |
| 1405 | |
| 1406 | // Verify that each json file for an included module has a rule. |
| 1407 | for _, jsonFile := range includeJsonFiles { |
| 1408 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1409 | t.Errorf("include json file %q not found", jsonFile) |
| 1410 | } |
| 1411 | } |
| 1412 | |
| 1413 | // Verify that each json file for an excluded module has no rule. |
| 1414 | for _, jsonFile := range excludeJsonFiles { |
| 1415 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1416 | t.Errorf("exclude json file %q found", jsonFile) |
| 1417 | } |
| 1418 | } |
| 1419 | } |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1420 | |
| 1421 | func TestRecoverySnapshotDirected(t *testing.T) { |
| 1422 | bp := ` |
| 1423 | cc_library_shared { |
| 1424 | name: "librecovery", |
| 1425 | recovery: true, |
| 1426 | nocrt: true, |
| 1427 | } |
| 1428 | |
| 1429 | cc_library_shared { |
| 1430 | name: "librecovery_available", |
| 1431 | recovery_available: true, |
| 1432 | nocrt: true, |
| 1433 | } |
| 1434 | |
| 1435 | genrule { |
| 1436 | name: "libfoo_gen", |
| 1437 | cmd: "", |
| 1438 | out: ["libfoo.so"], |
| 1439 | } |
| 1440 | |
| 1441 | cc_prebuilt_library_shared { |
| 1442 | name: "libfoo", |
| 1443 | recovery: true, |
| 1444 | prefer: true, |
| 1445 | srcs: [":libfoo_gen"], |
| 1446 | } |
| 1447 | |
| 1448 | cc_library_shared { |
| 1449 | name: "libfoo", |
| 1450 | recovery: true, |
| 1451 | nocrt: true, |
| 1452 | } |
| 1453 | ` |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1454 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1455 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1456 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1457 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1458 | config.TestProductVariables.DirectedRecoverySnapshot = true |
| 1459 | config.TestProductVariables.RecoverySnapshotModules = make(map[string]bool) |
| 1460 | config.TestProductVariables.RecoverySnapshotModules["librecovery"] = true |
| 1461 | config.TestProductVariables.RecoverySnapshotModules["libfoo"] = true |
| 1462 | ctx := testCcWithConfig(t, config) |
| 1463 | |
| 1464 | // Check recovery snapshot output. |
| 1465 | |
| 1466 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1467 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1468 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1469 | |
| 1470 | var includeJsonFiles []string |
| 1471 | |
| 1472 | for _, arch := range [][]string{ |
| 1473 | []string{"arm64", "armv8-a"}, |
| 1474 | } { |
| 1475 | archType := arch[0] |
| 1476 | archVariant := arch[1] |
| 1477 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1478 | |
| 1479 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1480 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1481 | |
| 1482 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1483 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1484 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json")) |
| 1485 | // Check that snapshot captures "prefer: true" prebuilt |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1486 | CheckSnapshot(t, ctx, snapshotSingleton, "prebuilt_libfoo", "libfoo.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1487 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libfoo.so.json")) |
| 1488 | |
| 1489 | // Excluded modules. Modules not included in the directed recovery snapshot |
| 1490 | // are still include as fake modules. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1491 | CheckSnapshotRule(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1492 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1493 | } |
| 1494 | |
| 1495 | // Verify that each json file for an included module has a rule. |
| 1496 | for _, jsonFile := range includeJsonFiles { |
| 1497 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1498 | t.Errorf("include json file %q not found", jsonFile) |
| 1499 | } |
| 1500 | } |
| 1501 | } |