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 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 462 | cc_binary { |
| 463 | name: "bin_without_snapshot", |
| 464 | vendor: true, |
| 465 | nocrt: true, |
| 466 | no_libcrt: true, |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 467 | stl: "libc++_static", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 468 | system_shared_libs: [], |
| 469 | static_libs: ["libvndk"], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 470 | srcs: ["bin.cpp"], |
| 471 | } |
| 472 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 473 | vendor_snapshot { |
| 474 | name: "vendor_snapshot", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 475 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 476 | arch: { |
| 477 | arm64: { |
| 478 | vndk_libs: [ |
| 479 | "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 480 | "libllndk", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 481 | ], |
| 482 | static_libs: [ |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 483 | "libc++_static", |
| 484 | "libc++demangle", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 485 | "libunwind", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 486 | "libvendor", |
| 487 | "libvendor_available", |
| 488 | "libvndk", |
| 489 | "lib64", |
| 490 | ], |
| 491 | shared_libs: [ |
| 492 | "libvendor", |
| 493 | "libvendor_available", |
| 494 | "lib64", |
| 495 | ], |
| 496 | binaries: [ |
| 497 | "bin", |
| 498 | ], |
| 499 | }, |
| 500 | arm: { |
| 501 | vndk_libs: [ |
| 502 | "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 503 | "libllndk", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 504 | ], |
| 505 | static_libs: [ |
| 506 | "libvendor", |
| 507 | "libvendor_available", |
| 508 | "libvndk", |
| 509 | "lib32", |
| 510 | ], |
| 511 | shared_libs: [ |
| 512 | "libvendor", |
| 513 | "libvendor_available", |
| 514 | "lib32", |
| 515 | ], |
| 516 | binaries: [ |
| 517 | "bin32", |
| 518 | ], |
| 519 | }, |
| 520 | } |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 521 | } |
| 522 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 523 | vendor_snapshot_static { |
| 524 | name: "libvndk", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 525 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 526 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 527 | compile_multilib: "both", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 528 | vendor: true, |
| 529 | arch: { |
| 530 | arm64: { |
| 531 | src: "libvndk.a", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 532 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 533 | arm: { |
| 534 | src: "libvndk.a", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 535 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 536 | }, |
Inseob Kim | dd0295d | 2021-04-12 21:09:59 +0900 | [diff] [blame] | 537 | shared_libs: ["libvndk"], |
| 538 | export_shared_lib_headers: ["libvndk"], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | vendor_snapshot_shared { |
| 542 | name: "libvendor", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 543 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 544 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 545 | compile_multilib: "both", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 546 | vendor: true, |
Justin Yun | 4813867 | 2021-02-25 18:21:27 +0900 | [diff] [blame] | 547 | shared_libs: [ |
| 548 | "libvendor_without_snapshot", |
| 549 | "libvendor_available", |
Justin Yun | 07b9f86 | 2021-02-26 14:00:03 +0900 | [diff] [blame] | 550 | "libvndk", |
Justin Yun | 4813867 | 2021-02-25 18:21:27 +0900 | [diff] [blame] | 551 | ], |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 552 | arch: { |
| 553 | arm64: { |
| 554 | src: "libvendor.so", |
| 555 | export_include_dirs: ["include/libvendor"], |
| 556 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 557 | arm: { |
| 558 | src: "libvendor.so", |
| 559 | export_include_dirs: ["include/libvendor"], |
| 560 | }, |
| 561 | }, |
| 562 | } |
| 563 | |
| 564 | vendor_snapshot_static { |
| 565 | name: "lib32", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 566 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 567 | target_arch: "arm64", |
| 568 | compile_multilib: "32", |
| 569 | vendor: true, |
| 570 | arch: { |
| 571 | arm: { |
| 572 | src: "lib32.a", |
| 573 | }, |
| 574 | }, |
| 575 | } |
| 576 | |
| 577 | vendor_snapshot_shared { |
| 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.so", |
| 586 | }, |
| 587 | }, |
| 588 | } |
| 589 | |
| 590 | vendor_snapshot_static { |
| 591 | name: "lib64", |
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: "64", |
| 595 | vendor: true, |
| 596 | arch: { |
| 597 | arm64: { |
| 598 | src: "lib64.a", |
| 599 | }, |
| 600 | }, |
| 601 | } |
| 602 | |
| 603 | vendor_snapshot_shared { |
| 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.so", |
| 612 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 613 | }, |
| 614 | } |
| 615 | |
| 616 | vendor_snapshot_static { |
| 617 | name: "libvendor", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 618 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 619 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 620 | compile_multilib: "both", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 621 | vendor: true, |
| 622 | arch: { |
| 623 | arm64: { |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 624 | cfi: { |
| 625 | src: "libvendor.cfi.a", |
| 626 | export_include_dirs: ["include/libvendor_cfi"], |
| 627 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 628 | src: "libvendor.a", |
| 629 | export_include_dirs: ["include/libvendor"], |
| 630 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 631 | arm: { |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 632 | cfi: { |
| 633 | src: "libvendor.cfi.a", |
| 634 | export_include_dirs: ["include/libvendor_cfi"], |
| 635 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 636 | src: "libvendor.a", |
| 637 | export_include_dirs: ["include/libvendor"], |
| 638 | }, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 639 | }, |
| 640 | } |
| 641 | |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 642 | vendor_snapshot_shared { |
| 643 | name: "libvendor_available", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 644 | version: "31", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 645 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 646 | compile_multilib: "both", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 647 | vendor: true, |
| 648 | arch: { |
| 649 | arm64: { |
| 650 | src: "libvendor_available.so", |
| 651 | export_include_dirs: ["include/libvendor"], |
| 652 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 653 | arm: { |
| 654 | src: "libvendor_available.so", |
| 655 | export_include_dirs: ["include/libvendor"], |
| 656 | }, |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 657 | }, |
| 658 | } |
| 659 | |
| 660 | vendor_snapshot_static { |
| 661 | name: "libvendor_available", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 662 | version: "31", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 663 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 664 | compile_multilib: "both", |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 665 | vendor: true, |
| 666 | arch: { |
| 667 | arm64: { |
| 668 | src: "libvendor_available.a", |
| 669 | export_include_dirs: ["include/libvendor"], |
| 670 | }, |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 671 | arm: { |
| 672 | src: "libvendor_available.so", |
| 673 | export_include_dirs: ["include/libvendor"], |
| 674 | }, |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 675 | }, |
| 676 | } |
| 677 | |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 678 | vendor_snapshot_static { |
| 679 | name: "libc++_static", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 680 | version: "31", |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 681 | target_arch: "arm64", |
| 682 | compile_multilib: "64", |
| 683 | vendor: true, |
| 684 | arch: { |
| 685 | arm64: { |
| 686 | src: "libc++_static.a", |
| 687 | }, |
| 688 | }, |
| 689 | } |
| 690 | |
| 691 | vendor_snapshot_static { |
| 692 | name: "libc++demangle", |
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++demangle.a", |
| 700 | }, |
| 701 | }, |
| 702 | } |
| 703 | |
| 704 | vendor_snapshot_static { |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 705 | name: "libunwind", |
| 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: { |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 712 | src: "libunwind.a", |
Inseob Kim | d4c9f55 | 2021-04-08 19:28:28 +0900 | [diff] [blame] | 713 | }, |
| 714 | }, |
| 715 | } |
| 716 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 717 | vendor_snapshot_binary { |
| 718 | name: "bin", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 719 | version: "31", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 720 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 721 | compile_multilib: "64", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 722 | vendor: true, |
| 723 | arch: { |
| 724 | arm64: { |
| 725 | src: "bin", |
| 726 | }, |
| 727 | }, |
| 728 | } |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 729 | |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 730 | vendor_snapshot_binary { |
| 731 | name: "bin32", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 732 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 733 | target_arch: "arm64", |
| 734 | compile_multilib: "32", |
| 735 | vendor: true, |
| 736 | arch: { |
| 737 | arm: { |
| 738 | src: "bin32", |
| 739 | }, |
| 740 | }, |
| 741 | } |
| 742 | |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 743 | // old snapshot module which has to be ignored |
| 744 | vendor_snapshot_binary { |
| 745 | name: "bin", |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 746 | version: "26", |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 747 | target_arch: "arm64", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 748 | compile_multilib: "first", |
| 749 | vendor: true, |
| 750 | arch: { |
| 751 | arm64: { |
| 752 | src: "bin", |
| 753 | }, |
| 754 | }, |
| 755 | } |
| 756 | |
| 757 | // different arch snapshot which has to be ignored |
| 758 | vendor_snapshot_binary { |
| 759 | name: "bin", |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 760 | version: "31", |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 761 | target_arch: "arm", |
| 762 | compile_multilib: "first", |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 763 | vendor: true, |
| 764 | arch: { |
| 765 | arm64: { |
| 766 | src: "bin", |
| 767 | }, |
| 768 | }, |
| 769 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 770 | ` |
| 771 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 772 | |
| 773 | mockFS := map[string][]byte{ |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 774 | "deps/Android.bp": []byte(depsBp), |
| 775 | "framework/Android.bp": []byte(frameworkBp), |
| 776 | "framework/symbol.txt": nil, |
| 777 | "vendor/Android.bp": []byte(vendorProprietaryBp), |
| 778 | "vendor/bin": nil, |
| 779 | "vendor/bin32": nil, |
| 780 | "vendor/bin.cpp": nil, |
| 781 | "vendor/client.cpp": nil, |
| 782 | "vendor/include/libvndk/a.h": nil, |
| 783 | "vendor/include/libvendor/b.h": nil, |
| 784 | "vendor/include/libvendor_cfi/c.h": nil, |
| 785 | "vendor/libc++_static.a": nil, |
| 786 | "vendor/libc++demangle.a": nil, |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 787 | "vendor/libunwind.a": nil, |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 788 | "vendor/libvndk.a": nil, |
| 789 | "vendor/libvendor.a": nil, |
| 790 | "vendor/libvendor.cfi.a": nil, |
| 791 | "vendor/libvendor.so": nil, |
| 792 | "vendor/lib32.a": nil, |
| 793 | "vendor/lib32.so": nil, |
| 794 | "vendor/lib64.a": nil, |
| 795 | "vendor/lib64.so": nil, |
| 796 | "vndk/Android.bp": []byte(vndkBp), |
| 797 | "vndk/include/libvndk/a.h": nil, |
| 798 | "vndk/libvndk.so": nil, |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 799 | "vndk/libllndk.so": nil, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 800 | } |
| 801 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 802 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 803 | config.TestProductVariables.DeviceVndkVersion = StringPtr("31") |
| 804 | config.TestProductVariables.Platform_vndk_version = StringPtr("32") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 805 | ctx := CreateTestContext(config) |
| 806 | ctx.Register() |
| 807 | |
| 808 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "vendor/Android.bp", "vndk/Android.bp"}) |
| 809 | android.FailIfErrored(t, errs) |
| 810 | _, errs = ctx.PrepareBuildActions(config) |
| 811 | android.FailIfErrored(t, errs) |
| 812 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 813 | sharedVariant := "android_vendor.31_arm64_armv8-a_shared" |
| 814 | staticVariant := "android_vendor.31_arm64_armv8-a_static" |
| 815 | binaryVariant := "android_vendor.31_arm64_armv8-a" |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 816 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 817 | sharedCfiVariant := "android_vendor.31_arm64_armv8-a_shared_cfi" |
| 818 | staticCfiVariant := "android_vendor.31_arm64_armv8-a_static_cfi" |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 819 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 820 | shared32Variant := "android_vendor.31_arm_armv7-a-neon_shared" |
| 821 | binary32Variant := "android_vendor.31_arm_armv7-a-neon" |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 822 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 823 | // 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] | 824 | libclientCcFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("cc").Args["cFlags"] |
| 825 | for _, includeFlags := range []string{ |
| 826 | "-Ivndk/include/libvndk", // libvndk |
| 827 | "-Ivendor/include/libvendor", // libvendor |
| 828 | } { |
| 829 | if !strings.Contains(libclientCcFlags, includeFlags) { |
| 830 | t.Errorf("flags for libclient must contain %#v, but was %#v.", |
| 831 | includeFlags, libclientCcFlags) |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | libclientLdFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("ld").Args["libFlags"] |
| 836 | for _, input := range [][]string{ |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 837 | []string{sharedVariant, "libvndk.vndk.31.arm64"}, |
| 838 | []string{sharedVariant, "libllndk.vndk.31.arm64"}, |
| 839 | []string{staticVariant, "libvendor.vendor_static.31.arm64"}, |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 840 | []string{staticVariant, "libvendor_without_snapshot"}, |
| 841 | } { |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 842 | outputPaths := GetOutputPaths(ctx, input[0] /* variant */, []string{input[1]} /* module name */) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 843 | if !strings.Contains(libclientLdFlags, outputPaths[0].String()) { |
| 844 | t.Errorf("libflags for libclient must contain %#v, but was %#v", outputPaths[0], libclientLdFlags) |
| 845 | } |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 846 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 847 | } |
| 848 | |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 849 | libclientAndroidMkSharedLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkSharedLibs |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 850 | 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] | 851 | t.Errorf("wanted libclient AndroidMkSharedLibs %q, got %q", w, g) |
| 852 | } |
| 853 | |
| 854 | libclientAndroidMkStaticLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkStaticLibs |
| 855 | if g, w := libclientAndroidMkStaticLibs, []string{"libvendor", "libvendor_without_snapshot"}; !reflect.DeepEqual(g, w) { |
| 856 | t.Errorf("wanted libclient AndroidMkStaticLibs %q, got %q", w, g) |
| 857 | } |
| 858 | |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 859 | libclient32AndroidMkSharedLibs := ctx.ModuleForTests("libclient", shared32Variant).Module().(*Module).Properties.AndroidMkSharedLibs |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 860 | 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] | 861 | t.Errorf("wanted libclient32 AndroidMkSharedLibs %q, got %q", w, g) |
| 862 | } |
| 863 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 864 | // libclient_cfi uses libvendor.vendor_static.31.arm64's cfi variant |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 865 | libclientCfiCcFlags := ctx.ModuleForTests("libclient_cfi", sharedCfiVariant).Rule("cc").Args["cFlags"] |
| 866 | if !strings.Contains(libclientCfiCcFlags, "-Ivendor/include/libvendor_cfi") { |
| 867 | t.Errorf("flags for libclient_cfi must contain %#v, but was %#v.", |
| 868 | "-Ivendor/include/libvendor_cfi", libclientCfiCcFlags) |
| 869 | } |
| 870 | |
| 871 | libclientCfiLdFlags := ctx.ModuleForTests("libclient_cfi", sharedCfiVariant).Rule("ld").Args["libFlags"] |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 872 | libvendorCfiOutputPaths := GetOutputPaths(ctx, staticCfiVariant, []string{"libvendor.vendor_static.31.arm64"}) |
Inseob Kim | f7aadf7 | 2021-04-13 10:15:31 +0900 | [diff] [blame] | 873 | if !strings.Contains(libclientCfiLdFlags, libvendorCfiOutputPaths[0].String()) { |
| 874 | t.Errorf("libflags for libclientCfi must contain %#v, but was %#v", libvendorCfiOutputPaths[0], libclientCfiLdFlags) |
| 875 | } |
| 876 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 877 | // 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] | 878 | binWithoutSnapshotCcFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("cc").Args["cFlags"] |
Inseob Kim | dd0295d | 2021-04-12 21:09:59 +0900 | [diff] [blame] | 879 | if !strings.Contains(binWithoutSnapshotCcFlags, "-Ivndk/include/libvndk") { |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 880 | t.Errorf("flags for bin_without_snapshot must contain %#v, but was %#v.", |
| 881 | "-Ivendor/include/libvndk", binWithoutSnapshotCcFlags) |
| 882 | } |
| 883 | |
| 884 | binWithoutSnapshotLdFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("ld").Args["libFlags"] |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 885 | libVndkStaticOutputPaths := GetOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.31.arm64"}) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 886 | if !strings.Contains(binWithoutSnapshotLdFlags, libVndkStaticOutputPaths[0].String()) { |
| 887 | t.Errorf("libflags for bin_without_snapshot must contain %#v, but was %#v", |
| 888 | libVndkStaticOutputPaths[0], binWithoutSnapshotLdFlags) |
| 889 | } |
| 890 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 891 | // libvendor.so is installed by libvendor.vendor_shared.31.arm64 |
| 892 | ctx.ModuleForTests("libvendor.vendor_shared.31.arm64", sharedVariant).Output("libvendor.so") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 893 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 894 | // lib64.so is installed by lib64.vendor_shared.31.arm64 |
| 895 | ctx.ModuleForTests("lib64.vendor_shared.31.arm64", sharedVariant).Output("lib64.so") |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 896 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 897 | // lib32.so is installed by lib32.vendor_shared.31.arm64 |
| 898 | ctx.ModuleForTests("lib32.vendor_shared.31.arm64", shared32Variant).Output("lib32.so") |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 899 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 900 | // libvendor_available.so is installed by libvendor_available.vendor_shared.31.arm64 |
| 901 | 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] | 902 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 903 | // libvendor_without_snapshot.so is installed by libvendor_without_snapshot |
| 904 | ctx.ModuleForTests("libvendor_without_snapshot", sharedVariant).Output("libvendor_without_snapshot.so") |
| 905 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 906 | // bin is installed by bin.vendor_binary.31.arm64 |
| 907 | ctx.ModuleForTests("bin.vendor_binary.31.arm64", binaryVariant).Output("bin") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 908 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 909 | // bin32 is installed by bin32.vendor_binary.31.arm64 |
| 910 | ctx.ModuleForTests("bin32.vendor_binary.31.arm64", binary32Variant).Output("bin32") |
Jose Galmes | f9523ed | 2021-04-06 19:48:10 -0700 | [diff] [blame] | 911 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 912 | // bin_without_snapshot is installed by bin_without_snapshot |
| 913 | ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot") |
| 914 | |
Justin Yun | dee806f | 2021-05-18 23:10:00 +0900 | [diff] [blame] | 915 | // libvendor, libvendor_available and bin don't have vendor.31 variant |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 916 | libvendorVariants := ctx.ModuleVariantsForTests("libvendor") |
| 917 | if inList(sharedVariant, libvendorVariants) { |
| 918 | t.Errorf("libvendor must not have variant %#v, but it does", sharedVariant) |
| 919 | } |
| 920 | |
Colin Cross | 2e577f3 | 2021-01-22 13:06:25 -0800 | [diff] [blame] | 921 | libvendorAvailableVariants := ctx.ModuleVariantsForTests("libvendor_available") |
| 922 | if inList(sharedVariant, libvendorAvailableVariants) { |
| 923 | t.Errorf("libvendor_available must not have variant %#v, but it does", sharedVariant) |
| 924 | } |
| 925 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 926 | binVariants := ctx.ModuleVariantsForTests("bin") |
| 927 | if inList(binaryVariant, binVariants) { |
| 928 | t.Errorf("bin must not have variant %#v, but it does", sharedVariant) |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | func TestVendorSnapshotSanitizer(t *testing.T) { |
| 933 | bp := ` |
Inseob Kim | 253f521 | 2021-04-08 17:10:31 +0900 | [diff] [blame] | 934 | vendor_snapshot { |
| 935 | name: "vendor_snapshot", |
| 936 | version: "28", |
| 937 | arch: { |
| 938 | arm64: { |
| 939 | static_libs: [ |
| 940 | "libsnapshot", |
| 941 | "note_memtag_heap_sync", |
| 942 | ], |
| 943 | }, |
| 944 | }, |
| 945 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 946 | vendor_snapshot_static { |
| 947 | name: "libsnapshot", |
| 948 | vendor: true, |
| 949 | target_arch: "arm64", |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 950 | version: "28", |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 951 | arch: { |
| 952 | arm64: { |
| 953 | src: "libsnapshot.a", |
| 954 | cfi: { |
| 955 | src: "libsnapshot.cfi.a", |
| 956 | } |
| 957 | }, |
| 958 | }, |
| 959 | } |
Inseob Kim | 253f521 | 2021-04-08 17:10:31 +0900 | [diff] [blame] | 960 | |
| 961 | vendor_snapshot_static { |
| 962 | name: "note_memtag_heap_sync", |
| 963 | vendor: true, |
| 964 | target_arch: "arm64", |
| 965 | version: "28", |
| 966 | arch: { |
| 967 | arm64: { |
| 968 | src: "note_memtag_heap_sync.a", |
| 969 | }, |
| 970 | }, |
| 971 | } |
| 972 | |
| 973 | cc_test { |
| 974 | name: "vstest", |
| 975 | gtest: false, |
| 976 | vendor: true, |
| 977 | compile_multilib: "64", |
| 978 | nocrt: true, |
| 979 | no_libcrt: true, |
| 980 | stl: "none", |
| 981 | static_libs: ["libsnapshot"], |
| 982 | system_shared_libs: [], |
| 983 | } |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 984 | ` |
Inseob Kim | 253f521 | 2021-04-08 17:10:31 +0900 | [diff] [blame] | 985 | |
| 986 | mockFS := map[string][]byte{ |
| 987 | "vendor/Android.bp": []byte(bp), |
| 988 | "vendor/libc++demangle.a": nil, |
| 989 | "vendor/libsnapshot.a": nil, |
| 990 | "vendor/libsnapshot.cfi.a": nil, |
| 991 | "vendor/note_memtag_heap_sync.a": nil, |
| 992 | } |
| 993 | |
| 994 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 995 | config.TestProductVariables.DeviceVndkVersion = StringPtr("28") |
| 996 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 997 | ctx := testCcWithConfig(t, config) |
| 998 | |
| 999 | // Check non-cfi and cfi variant. |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1000 | staticVariant := "android_vendor.28_arm64_armv8-a_static" |
| 1001 | staticCfiVariant := "android_vendor.28_arm64_armv8-a_static_cfi" |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1002 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1003 | staticModule := ctx.ModuleForTests("libsnapshot.vendor_static.28.arm64", staticVariant).Module().(*Module) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1004 | assertString(t, staticModule.outputFile.Path().Base(), "libsnapshot.a") |
| 1005 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1006 | staticCfiModule := ctx.ModuleForTests("libsnapshot.vendor_static.28.arm64", staticCfiVariant).Module().(*Module) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1007 | assertString(t, staticCfiModule.outputFile.Path().Base(), "libsnapshot.cfi.a") |
| 1008 | } |
| 1009 | |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1010 | func assertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool) { |
| 1011 | t.Helper() |
| 1012 | m := ctx.ModuleForTests(name, recoveryVariant).Module().(*Module) |
| 1013 | if m.ExcludeFromRecoverySnapshot() != expected { |
| 1014 | t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected) |
| 1015 | } |
| 1016 | } |
| 1017 | |
| 1018 | func TestVendorSnapshotExclude(t *testing.T) { |
| 1019 | |
| 1020 | // This test verifies that the exclude_from_vendor_snapshot property |
| 1021 | // makes its way from the Android.bp source file into the module data |
| 1022 | // structure. It also verifies that modules are correctly included or |
| 1023 | // excluded in the vendor snapshot based on their path (framework or |
| 1024 | // vendor) and the exclude_from_vendor_snapshot property. |
| 1025 | |
| 1026 | frameworkBp := ` |
| 1027 | cc_library_shared { |
| 1028 | name: "libinclude", |
| 1029 | srcs: ["src/include.cpp"], |
| 1030 | vendor_available: true, |
| 1031 | } |
| 1032 | cc_library_shared { |
| 1033 | name: "libexclude", |
| 1034 | srcs: ["src/exclude.cpp"], |
| 1035 | vendor: true, |
| 1036 | exclude_from_vendor_snapshot: true, |
| 1037 | } |
| 1038 | cc_library_shared { |
| 1039 | name: "libavailable_exclude", |
| 1040 | srcs: ["src/exclude.cpp"], |
| 1041 | vendor_available: true, |
| 1042 | exclude_from_vendor_snapshot: true, |
| 1043 | } |
| 1044 | ` |
| 1045 | |
| 1046 | vendorProprietaryBp := ` |
| 1047 | cc_library_shared { |
| 1048 | name: "libvendor", |
| 1049 | srcs: ["vendor.cpp"], |
| 1050 | vendor: true, |
| 1051 | } |
| 1052 | ` |
| 1053 | |
| 1054 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1055 | |
| 1056 | mockFS := map[string][]byte{ |
| 1057 | "deps/Android.bp": []byte(depsBp), |
| 1058 | "framework/Android.bp": []byte(frameworkBp), |
| 1059 | "framework/include.cpp": nil, |
| 1060 | "framework/exclude.cpp": nil, |
| 1061 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1062 | "device/vendor.cpp": nil, |
| 1063 | } |
| 1064 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1065 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1066 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1067 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1068 | ctx := CreateTestContext(config) |
| 1069 | ctx.Register() |
| 1070 | |
| 1071 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1072 | android.FailIfErrored(t, errs) |
| 1073 | _, errs = ctx.PrepareBuildActions(config) |
| 1074 | android.FailIfErrored(t, errs) |
| 1075 | |
| 1076 | // Test an include and exclude framework module. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1077 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libinclude", false, vendorVariant) |
| 1078 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libexclude", true, vendorVariant) |
| 1079 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libavailable_exclude", true, vendorVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1080 | |
| 1081 | // A vendor module is excluded, but by its path, not the |
| 1082 | // exclude_from_vendor_snapshot property. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1083 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libvendor", false, vendorVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1084 | |
| 1085 | // Verify the content of the vendor snapshot. |
| 1086 | |
| 1087 | snapshotDir := "vendor-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1088 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1089 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 1090 | |
| 1091 | var includeJsonFiles []string |
| 1092 | var excludeJsonFiles []string |
| 1093 | |
| 1094 | for _, arch := range [][]string{ |
| 1095 | []string{"arm64", "armv8-a"}, |
| 1096 | []string{"arm", "armv7-a-neon"}, |
| 1097 | } { |
| 1098 | archType := arch[0] |
| 1099 | archVariant := arch[1] |
| 1100 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1101 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1102 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1103 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1104 | |
| 1105 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1106 | CheckSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1107 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1108 | |
| 1109 | // Excluded modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1110 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1111 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1112 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1113 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1114 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1115 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| 1116 | } |
| 1117 | |
| 1118 | // Verify that each json file for an included module has a rule. |
| 1119 | for _, jsonFile := range includeJsonFiles { |
| 1120 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1121 | t.Errorf("include json file %q not found", jsonFile) |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | // Verify that each json file for an excluded module has no rule. |
| 1126 | for _, jsonFile := range excludeJsonFiles { |
| 1127 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1128 | t.Errorf("exclude json file %q found", jsonFile) |
| 1129 | } |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) { |
| 1134 | |
| 1135 | // This test verifies that using the exclude_from_vendor_snapshot |
| 1136 | // property on a module in a vendor proprietary path generates an |
| 1137 | // error. These modules are already excluded, so we prohibit using the |
| 1138 | // property in this way, which could add to confusion. |
| 1139 | |
| 1140 | vendorProprietaryBp := ` |
| 1141 | cc_library_shared { |
| 1142 | name: "libvendor", |
| 1143 | srcs: ["vendor.cpp"], |
| 1144 | vendor: true, |
| 1145 | exclude_from_vendor_snapshot: true, |
| 1146 | } |
| 1147 | ` |
| 1148 | |
| 1149 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1150 | |
| 1151 | mockFS := map[string][]byte{ |
| 1152 | "deps/Android.bp": []byte(depsBp), |
| 1153 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1154 | "device/vendor.cpp": nil, |
| 1155 | } |
| 1156 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1157 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1158 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1159 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1160 | ctx := CreateTestContext(config) |
| 1161 | ctx.Register() |
| 1162 | |
| 1163 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"}) |
| 1164 | android.FailIfErrored(t, errs) |
| 1165 | |
| 1166 | _, errs = ctx.PrepareBuildActions(config) |
| 1167 | android.CheckErrorsAgainstExpectations(t, errs, []string{ |
| 1168 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1169 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1170 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1171 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1172 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1173 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1174 | }) |
| 1175 | } |
| 1176 | |
| 1177 | func TestRecoverySnapshotCapture(t *testing.T) { |
| 1178 | bp := ` |
| 1179 | cc_library { |
| 1180 | name: "libvndk", |
| 1181 | vendor_available: true, |
| 1182 | recovery_available: true, |
| 1183 | product_available: true, |
| 1184 | vndk: { |
| 1185 | enabled: true, |
| 1186 | }, |
| 1187 | nocrt: true, |
| 1188 | } |
| 1189 | |
| 1190 | cc_library { |
| 1191 | name: "librecovery", |
| 1192 | recovery: true, |
| 1193 | nocrt: true, |
| 1194 | } |
| 1195 | |
| 1196 | cc_library { |
| 1197 | name: "librecovery_available", |
| 1198 | recovery_available: true, |
| 1199 | nocrt: true, |
| 1200 | } |
| 1201 | |
| 1202 | cc_library_headers { |
| 1203 | name: "librecovery_headers", |
| 1204 | recovery_available: true, |
| 1205 | nocrt: true, |
| 1206 | } |
| 1207 | |
| 1208 | cc_binary { |
| 1209 | name: "recovery_bin", |
| 1210 | recovery: true, |
| 1211 | nocrt: true, |
| 1212 | } |
| 1213 | |
| 1214 | cc_binary { |
| 1215 | name: "recovery_available_bin", |
| 1216 | recovery_available: true, |
| 1217 | nocrt: true, |
| 1218 | } |
| 1219 | |
| 1220 | toolchain_library { |
| 1221 | name: "libb", |
| 1222 | recovery_available: true, |
| 1223 | src: "libb.a", |
| 1224 | } |
| 1225 | |
| 1226 | cc_object { |
| 1227 | name: "obj", |
| 1228 | recovery_available: true, |
| 1229 | } |
| 1230 | ` |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1231 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1232 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1233 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1234 | ctx := testCcWithConfig(t, config) |
| 1235 | |
| 1236 | // Check Recovery snapshot output. |
| 1237 | |
| 1238 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1239 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1240 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1241 | |
| 1242 | var jsonFiles []string |
| 1243 | |
| 1244 | for _, arch := range [][]string{ |
| 1245 | []string{"arm64", "armv8-a"}, |
| 1246 | } { |
| 1247 | archType := arch[0] |
| 1248 | archVariant := arch[1] |
| 1249 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1250 | |
| 1251 | // For shared libraries, only recovery_available modules are captured. |
| 1252 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1253 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1254 | CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", sharedDir, sharedVariant) |
| 1255 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
| 1256 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1257 | jsonFiles = append(jsonFiles, |
| 1258 | filepath.Join(sharedDir, "libvndk.so.json"), |
| 1259 | filepath.Join(sharedDir, "librecovery.so.json"), |
| 1260 | filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1261 | |
| 1262 | // For static libraries, all recovery:true and recovery_available modules are captured. |
| 1263 | staticVariant := fmt.Sprintf("android_recovery_%s_%s_static", archType, archVariant) |
| 1264 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1265 | CheckSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant) |
| 1266 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.a", staticDir, staticVariant) |
| 1267 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.a", staticDir, staticVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1268 | jsonFiles = append(jsonFiles, |
| 1269 | filepath.Join(staticDir, "libb.a.json"), |
| 1270 | filepath.Join(staticDir, "librecovery.a.json"), |
| 1271 | filepath.Join(staticDir, "librecovery_available.a.json")) |
| 1272 | |
| 1273 | // For binary executables, all recovery:true and recovery_available modules are captured. |
| 1274 | if archType == "arm64" { |
| 1275 | binaryVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1276 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1277 | CheckSnapshot(t, ctx, snapshotSingleton, "recovery_bin", "recovery_bin", binaryDir, binaryVariant) |
| 1278 | CheckSnapshot(t, ctx, snapshotSingleton, "recovery_available_bin", "recovery_available_bin", binaryDir, binaryVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1279 | jsonFiles = append(jsonFiles, |
| 1280 | filepath.Join(binaryDir, "recovery_bin.json"), |
| 1281 | filepath.Join(binaryDir, "recovery_available_bin.json")) |
| 1282 | } |
| 1283 | |
| 1284 | // For header libraries, all vendor:true and vendor_available modules are captured. |
| 1285 | headerDir := filepath.Join(snapshotVariantPath, archDir, "header") |
| 1286 | jsonFiles = append(jsonFiles, filepath.Join(headerDir, "librecovery_headers.json")) |
| 1287 | |
| 1288 | // For object modules, all vendor:true and vendor_available modules are captured. |
| 1289 | objectVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1290 | objectDir := filepath.Join(snapshotVariantPath, archDir, "object") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1291 | CheckSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1292 | jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json")) |
| 1293 | } |
| 1294 | |
| 1295 | for _, jsonFile := range jsonFiles { |
| 1296 | // verify all json files exist |
| 1297 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1298 | t.Errorf("%q expected but not found", jsonFile) |
| 1299 | } |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | func TestRecoverySnapshotExclude(t *testing.T) { |
| 1304 | // This test verifies that the exclude_from_recovery_snapshot property |
| 1305 | // makes its way from the Android.bp source file into the module data |
| 1306 | // structure. It also verifies that modules are correctly included or |
| 1307 | // excluded in the recovery snapshot based on their path (framework or |
| 1308 | // vendor) and the exclude_from_recovery_snapshot property. |
| 1309 | |
| 1310 | frameworkBp := ` |
| 1311 | cc_library_shared { |
| 1312 | name: "libinclude", |
| 1313 | srcs: ["src/include.cpp"], |
| 1314 | recovery_available: true, |
| 1315 | } |
| 1316 | cc_library_shared { |
| 1317 | name: "libexclude", |
| 1318 | srcs: ["src/exclude.cpp"], |
| 1319 | recovery: true, |
| 1320 | exclude_from_recovery_snapshot: true, |
| 1321 | } |
| 1322 | cc_library_shared { |
| 1323 | name: "libavailable_exclude", |
| 1324 | srcs: ["src/exclude.cpp"], |
| 1325 | recovery_available: true, |
| 1326 | exclude_from_recovery_snapshot: true, |
| 1327 | } |
| 1328 | ` |
| 1329 | |
| 1330 | vendorProprietaryBp := ` |
| 1331 | cc_library_shared { |
| 1332 | name: "librecovery", |
| 1333 | srcs: ["recovery.cpp"], |
| 1334 | recovery: true, |
| 1335 | } |
| 1336 | ` |
| 1337 | |
| 1338 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1339 | |
| 1340 | mockFS := map[string][]byte{ |
| 1341 | "deps/Android.bp": []byte(depsBp), |
| 1342 | "framework/Android.bp": []byte(frameworkBp), |
| 1343 | "framework/include.cpp": nil, |
| 1344 | "framework/exclude.cpp": nil, |
| 1345 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1346 | "device/recovery.cpp": nil, |
| 1347 | } |
| 1348 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1349 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1350 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1351 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1352 | ctx := CreateTestContext(config) |
| 1353 | ctx.Register() |
| 1354 | |
| 1355 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1356 | android.FailIfErrored(t, errs) |
| 1357 | _, errs = ctx.PrepareBuildActions(config) |
| 1358 | android.FailIfErrored(t, errs) |
| 1359 | |
| 1360 | // Test an include and exclude framework module. |
| 1361 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libinclude", false) |
| 1362 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libexclude", true) |
| 1363 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libavailable_exclude", true) |
| 1364 | |
| 1365 | // A recovery module is excluded, but by its path, not the |
| 1366 | // exclude_from_recovery_snapshot property. |
| 1367 | assertExcludeFromRecoverySnapshotIs(t, ctx, "librecovery", false) |
| 1368 | |
| 1369 | // Verify the content of the recovery snapshot. |
| 1370 | |
| 1371 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1372 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1373 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1374 | |
| 1375 | var includeJsonFiles []string |
| 1376 | var excludeJsonFiles []string |
| 1377 | |
| 1378 | for _, arch := range [][]string{ |
| 1379 | []string{"arm64", "armv8-a"}, |
| 1380 | } { |
| 1381 | archType := arch[0] |
| 1382 | archVariant := arch[1] |
| 1383 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1384 | |
| 1385 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1386 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1387 | |
| 1388 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1389 | CheckSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1390 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1391 | |
| 1392 | // Excluded modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1393 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1394 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1395 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1396 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1397 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1398 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| 1399 | } |
| 1400 | |
| 1401 | // Verify that each json file for an included module has a rule. |
| 1402 | for _, jsonFile := range includeJsonFiles { |
| 1403 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1404 | t.Errorf("include json file %q not found", jsonFile) |
| 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | // Verify that each json file for an excluded module has no rule. |
| 1409 | for _, jsonFile := range excludeJsonFiles { |
| 1410 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1411 | t.Errorf("exclude json file %q found", jsonFile) |
| 1412 | } |
| 1413 | } |
| 1414 | } |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1415 | |
| 1416 | func TestRecoverySnapshotDirected(t *testing.T) { |
| 1417 | bp := ` |
| 1418 | cc_library_shared { |
| 1419 | name: "librecovery", |
| 1420 | recovery: true, |
| 1421 | nocrt: true, |
| 1422 | } |
| 1423 | |
| 1424 | cc_library_shared { |
| 1425 | name: "librecovery_available", |
| 1426 | recovery_available: true, |
| 1427 | nocrt: true, |
| 1428 | } |
| 1429 | |
| 1430 | genrule { |
| 1431 | name: "libfoo_gen", |
| 1432 | cmd: "", |
| 1433 | out: ["libfoo.so"], |
| 1434 | } |
| 1435 | |
| 1436 | cc_prebuilt_library_shared { |
| 1437 | name: "libfoo", |
| 1438 | recovery: true, |
| 1439 | prefer: true, |
| 1440 | srcs: [":libfoo_gen"], |
| 1441 | } |
| 1442 | |
| 1443 | cc_library_shared { |
| 1444 | name: "libfoo", |
| 1445 | recovery: true, |
| 1446 | nocrt: true, |
| 1447 | } |
| 1448 | ` |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1449 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1450 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1451 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1452 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1453 | config.TestProductVariables.DirectedRecoverySnapshot = true |
| 1454 | config.TestProductVariables.RecoverySnapshotModules = make(map[string]bool) |
| 1455 | config.TestProductVariables.RecoverySnapshotModules["librecovery"] = true |
| 1456 | config.TestProductVariables.RecoverySnapshotModules["libfoo"] = true |
| 1457 | ctx := testCcWithConfig(t, config) |
| 1458 | |
| 1459 | // Check recovery snapshot output. |
| 1460 | |
| 1461 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1462 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1463 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1464 | |
| 1465 | var includeJsonFiles []string |
| 1466 | |
| 1467 | for _, arch := range [][]string{ |
| 1468 | []string{"arm64", "armv8-a"}, |
| 1469 | } { |
| 1470 | archType := arch[0] |
| 1471 | archVariant := arch[1] |
| 1472 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1473 | |
| 1474 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1475 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1476 | |
| 1477 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1478 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1479 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json")) |
| 1480 | // Check that snapshot captures "prefer: true" prebuilt |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1481 | CheckSnapshot(t, ctx, snapshotSingleton, "prebuilt_libfoo", "libfoo.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1482 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libfoo.so.json")) |
| 1483 | |
| 1484 | // Excluded modules. Modules not included in the directed recovery snapshot |
| 1485 | // are still include as fake modules. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1486 | CheckSnapshotRule(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1487 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1488 | } |
| 1489 | |
| 1490 | // Verify that each json file for an included module has a rule. |
| 1491 | for _, jsonFile := range includeJsonFiles { |
| 1492 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1493 | t.Errorf("include json file %q not found", jsonFile) |
| 1494 | } |
| 1495 | } |
| 1496 | } |