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 assertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool) { |
| 1024 | t.Helper() |
| 1025 | m := ctx.ModuleForTests(name, recoveryVariant).Module().(*Module) |
| 1026 | if m.ExcludeFromRecoverySnapshot() != expected { |
| 1027 | t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected) |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | func TestVendorSnapshotExclude(t *testing.T) { |
| 1032 | |
| 1033 | // This test verifies that the exclude_from_vendor_snapshot property |
| 1034 | // makes its way from the Android.bp source file into the module data |
| 1035 | // structure. It also verifies that modules are correctly included or |
| 1036 | // excluded in the vendor snapshot based on their path (framework or |
| 1037 | // vendor) and the exclude_from_vendor_snapshot property. |
| 1038 | |
| 1039 | frameworkBp := ` |
| 1040 | cc_library_shared { |
| 1041 | name: "libinclude", |
| 1042 | srcs: ["src/include.cpp"], |
| 1043 | vendor_available: true, |
| 1044 | } |
| 1045 | cc_library_shared { |
| 1046 | name: "libexclude", |
| 1047 | srcs: ["src/exclude.cpp"], |
| 1048 | vendor: true, |
| 1049 | exclude_from_vendor_snapshot: true, |
| 1050 | } |
| 1051 | cc_library_shared { |
| 1052 | name: "libavailable_exclude", |
| 1053 | srcs: ["src/exclude.cpp"], |
| 1054 | vendor_available: true, |
| 1055 | exclude_from_vendor_snapshot: true, |
| 1056 | } |
| 1057 | ` |
| 1058 | |
| 1059 | vendorProprietaryBp := ` |
| 1060 | cc_library_shared { |
| 1061 | name: "libvendor", |
| 1062 | srcs: ["vendor.cpp"], |
| 1063 | vendor: true, |
| 1064 | } |
| 1065 | ` |
| 1066 | |
| 1067 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1068 | |
| 1069 | mockFS := map[string][]byte{ |
| 1070 | "deps/Android.bp": []byte(depsBp), |
| 1071 | "framework/Android.bp": []byte(frameworkBp), |
| 1072 | "framework/include.cpp": nil, |
| 1073 | "framework/exclude.cpp": nil, |
| 1074 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1075 | "device/vendor.cpp": nil, |
| 1076 | } |
| 1077 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1078 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1079 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1080 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1081 | ctx := CreateTestContext(config) |
| 1082 | ctx.Register() |
| 1083 | |
| 1084 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1085 | android.FailIfErrored(t, errs) |
| 1086 | _, errs = ctx.PrepareBuildActions(config) |
| 1087 | android.FailIfErrored(t, errs) |
| 1088 | |
| 1089 | // Test an include and exclude framework module. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1090 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libinclude", false, vendorVariant) |
| 1091 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libexclude", true, vendorVariant) |
| 1092 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libavailable_exclude", true, vendorVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1093 | |
| 1094 | // A vendor module is excluded, but by its path, not the |
| 1095 | // exclude_from_vendor_snapshot property. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1096 | AssertExcludeFromVendorSnapshotIs(t, ctx, "libvendor", false, vendorVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1097 | |
| 1098 | // Verify the content of the vendor snapshot. |
| 1099 | |
| 1100 | snapshotDir := "vendor-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1101 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1102 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 1103 | |
| 1104 | var includeJsonFiles []string |
| 1105 | var excludeJsonFiles []string |
| 1106 | |
| 1107 | for _, arch := range [][]string{ |
| 1108 | []string{"arm64", "armv8-a"}, |
| 1109 | []string{"arm", "armv7-a-neon"}, |
| 1110 | } { |
| 1111 | archType := arch[0] |
| 1112 | archVariant := arch[1] |
| 1113 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1114 | |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1115 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1116 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1117 | |
| 1118 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1119 | CheckSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1120 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1121 | |
| 1122 | // Excluded modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1123 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1124 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1125 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1126 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1127 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1128 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| 1129 | } |
| 1130 | |
| 1131 | // Verify that each json file for an included module has a rule. |
| 1132 | for _, jsonFile := range includeJsonFiles { |
| 1133 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1134 | t.Errorf("include json file %q not found", jsonFile) |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | // Verify that each json file for an excluded module has no rule. |
| 1139 | for _, jsonFile := range excludeJsonFiles { |
| 1140 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1141 | t.Errorf("exclude json file %q found", jsonFile) |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) { |
| 1147 | |
| 1148 | // This test verifies that using the exclude_from_vendor_snapshot |
| 1149 | // property on a module in a vendor proprietary path generates an |
| 1150 | // error. These modules are already excluded, so we prohibit using the |
| 1151 | // property in this way, which could add to confusion. |
| 1152 | |
| 1153 | vendorProprietaryBp := ` |
| 1154 | cc_library_shared { |
| 1155 | name: "libvendor", |
| 1156 | srcs: ["vendor.cpp"], |
| 1157 | vendor: true, |
| 1158 | exclude_from_vendor_snapshot: true, |
| 1159 | } |
| 1160 | ` |
| 1161 | |
| 1162 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1163 | |
| 1164 | mockFS := map[string][]byte{ |
| 1165 | "deps/Android.bp": []byte(depsBp), |
| 1166 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1167 | "device/vendor.cpp": nil, |
| 1168 | } |
| 1169 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1170 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1171 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1172 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1173 | ctx := CreateTestContext(config) |
| 1174 | ctx.Register() |
| 1175 | |
| 1176 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"}) |
| 1177 | android.FailIfErrored(t, errs) |
| 1178 | |
| 1179 | _, errs = ctx.PrepareBuildActions(config) |
| 1180 | android.CheckErrorsAgainstExpectations(t, errs, []string{ |
| 1181 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1182 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1183 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1184 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1185 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1186 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1187 | }) |
| 1188 | } |
| 1189 | |
| 1190 | func TestRecoverySnapshotCapture(t *testing.T) { |
| 1191 | bp := ` |
| 1192 | cc_library { |
| 1193 | name: "libvndk", |
| 1194 | vendor_available: true, |
| 1195 | recovery_available: true, |
| 1196 | product_available: true, |
| 1197 | vndk: { |
| 1198 | enabled: true, |
| 1199 | }, |
| 1200 | nocrt: true, |
| 1201 | } |
| 1202 | |
| 1203 | cc_library { |
| 1204 | name: "librecovery", |
| 1205 | recovery: true, |
| 1206 | nocrt: true, |
| 1207 | } |
| 1208 | |
| 1209 | cc_library { |
| 1210 | name: "librecovery_available", |
| 1211 | recovery_available: true, |
| 1212 | nocrt: true, |
| 1213 | } |
| 1214 | |
| 1215 | cc_library_headers { |
| 1216 | name: "librecovery_headers", |
| 1217 | recovery_available: true, |
| 1218 | nocrt: true, |
| 1219 | } |
| 1220 | |
| 1221 | cc_binary { |
| 1222 | name: "recovery_bin", |
| 1223 | recovery: true, |
| 1224 | nocrt: true, |
| 1225 | } |
| 1226 | |
| 1227 | cc_binary { |
| 1228 | name: "recovery_available_bin", |
| 1229 | recovery_available: true, |
| 1230 | nocrt: true, |
| 1231 | } |
| 1232 | |
| 1233 | toolchain_library { |
| 1234 | name: "libb", |
| 1235 | recovery_available: true, |
| 1236 | src: "libb.a", |
| 1237 | } |
| 1238 | |
| 1239 | cc_object { |
| 1240 | name: "obj", |
| 1241 | recovery_available: true, |
| 1242 | } |
| 1243 | ` |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1244 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1245 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1246 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1247 | ctx := testCcWithConfig(t, config) |
| 1248 | |
| 1249 | // Check Recovery snapshot output. |
| 1250 | |
| 1251 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1252 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1253 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1254 | |
| 1255 | var jsonFiles []string |
| 1256 | |
| 1257 | for _, arch := range [][]string{ |
| 1258 | []string{"arm64", "armv8-a"}, |
| 1259 | } { |
| 1260 | archType := arch[0] |
| 1261 | archVariant := arch[1] |
| 1262 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1263 | |
| 1264 | // For shared libraries, only recovery_available modules are captured. |
| 1265 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1266 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1267 | CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", sharedDir, sharedVariant) |
| 1268 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
| 1269 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1270 | jsonFiles = append(jsonFiles, |
| 1271 | filepath.Join(sharedDir, "libvndk.so.json"), |
| 1272 | filepath.Join(sharedDir, "librecovery.so.json"), |
| 1273 | filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1274 | |
| 1275 | // For static libraries, all recovery:true and recovery_available modules are captured. |
| 1276 | staticVariant := fmt.Sprintf("android_recovery_%s_%s_static", archType, archVariant) |
| 1277 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1278 | CheckSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant) |
| 1279 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.a", staticDir, staticVariant) |
| 1280 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.a", staticDir, staticVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1281 | jsonFiles = append(jsonFiles, |
| 1282 | filepath.Join(staticDir, "libb.a.json"), |
| 1283 | filepath.Join(staticDir, "librecovery.a.json"), |
| 1284 | filepath.Join(staticDir, "librecovery_available.a.json")) |
| 1285 | |
| 1286 | // For binary executables, all recovery:true and recovery_available modules are captured. |
| 1287 | if archType == "arm64" { |
| 1288 | binaryVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1289 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1290 | CheckSnapshot(t, ctx, snapshotSingleton, "recovery_bin", "recovery_bin", binaryDir, binaryVariant) |
| 1291 | CheckSnapshot(t, ctx, snapshotSingleton, "recovery_available_bin", "recovery_available_bin", binaryDir, binaryVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1292 | jsonFiles = append(jsonFiles, |
| 1293 | filepath.Join(binaryDir, "recovery_bin.json"), |
| 1294 | filepath.Join(binaryDir, "recovery_available_bin.json")) |
| 1295 | } |
| 1296 | |
| 1297 | // For header libraries, all vendor:true and vendor_available modules are captured. |
| 1298 | headerDir := filepath.Join(snapshotVariantPath, archDir, "header") |
| 1299 | jsonFiles = append(jsonFiles, filepath.Join(headerDir, "librecovery_headers.json")) |
| 1300 | |
| 1301 | // For object modules, all vendor:true and vendor_available modules are captured. |
| 1302 | objectVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1303 | objectDir := filepath.Join(snapshotVariantPath, archDir, "object") |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1304 | CheckSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1305 | jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json")) |
| 1306 | } |
| 1307 | |
| 1308 | for _, jsonFile := range jsonFiles { |
| 1309 | // verify all json files exist |
| 1310 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1311 | t.Errorf("%q expected but not found", jsonFile) |
| 1312 | } |
| 1313 | } |
| 1314 | } |
| 1315 | |
| 1316 | func TestRecoverySnapshotExclude(t *testing.T) { |
| 1317 | // This test verifies that the exclude_from_recovery_snapshot property |
| 1318 | // makes its way from the Android.bp source file into the module data |
| 1319 | // structure. It also verifies that modules are correctly included or |
| 1320 | // excluded in the recovery snapshot based on their path (framework or |
| 1321 | // vendor) and the exclude_from_recovery_snapshot property. |
| 1322 | |
| 1323 | frameworkBp := ` |
| 1324 | cc_library_shared { |
| 1325 | name: "libinclude", |
| 1326 | srcs: ["src/include.cpp"], |
| 1327 | recovery_available: true, |
| 1328 | } |
| 1329 | cc_library_shared { |
| 1330 | name: "libexclude", |
| 1331 | srcs: ["src/exclude.cpp"], |
| 1332 | recovery: true, |
| 1333 | exclude_from_recovery_snapshot: true, |
| 1334 | } |
| 1335 | cc_library_shared { |
| 1336 | name: "libavailable_exclude", |
| 1337 | srcs: ["src/exclude.cpp"], |
| 1338 | recovery_available: true, |
| 1339 | exclude_from_recovery_snapshot: true, |
| 1340 | } |
| 1341 | ` |
| 1342 | |
| 1343 | vendorProprietaryBp := ` |
| 1344 | cc_library_shared { |
| 1345 | name: "librecovery", |
| 1346 | srcs: ["recovery.cpp"], |
| 1347 | recovery: true, |
| 1348 | } |
| 1349 | ` |
| 1350 | |
| 1351 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1352 | |
| 1353 | mockFS := map[string][]byte{ |
| 1354 | "deps/Android.bp": []byte(depsBp), |
| 1355 | "framework/Android.bp": []byte(frameworkBp), |
| 1356 | "framework/include.cpp": nil, |
| 1357 | "framework/exclude.cpp": nil, |
| 1358 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1359 | "device/recovery.cpp": nil, |
| 1360 | } |
| 1361 | |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1362 | config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1363 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1364 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1365 | ctx := CreateTestContext(config) |
| 1366 | ctx.Register() |
| 1367 | |
| 1368 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1369 | android.FailIfErrored(t, errs) |
| 1370 | _, errs = ctx.PrepareBuildActions(config) |
| 1371 | android.FailIfErrored(t, errs) |
| 1372 | |
| 1373 | // Test an include and exclude framework module. |
| 1374 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libinclude", false) |
| 1375 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libexclude", true) |
| 1376 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libavailable_exclude", true) |
| 1377 | |
| 1378 | // A recovery module is excluded, but by its path, not the |
| 1379 | // exclude_from_recovery_snapshot property. |
| 1380 | assertExcludeFromRecoverySnapshotIs(t, ctx, "librecovery", false) |
| 1381 | |
| 1382 | // Verify the content of the recovery snapshot. |
| 1383 | |
| 1384 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1385 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1386 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1387 | |
| 1388 | var includeJsonFiles []string |
| 1389 | var excludeJsonFiles []string |
| 1390 | |
| 1391 | for _, arch := range [][]string{ |
| 1392 | []string{"arm64", "armv8-a"}, |
| 1393 | } { |
| 1394 | archType := arch[0] |
| 1395 | archVariant := arch[1] |
| 1396 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1397 | |
| 1398 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1399 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1400 | |
| 1401 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1402 | CheckSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1403 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1404 | |
| 1405 | // Excluded modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1406 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1407 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1408 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1409 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json")) |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1410 | CheckSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
Colin Cross | 0fce0ba | 2021-01-08 16:40:12 -0800 | [diff] [blame] | 1411 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| 1412 | } |
| 1413 | |
| 1414 | // Verify that each json file for an included module has a rule. |
| 1415 | for _, jsonFile := range includeJsonFiles { |
| 1416 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1417 | t.Errorf("include json file %q not found", jsonFile) |
| 1418 | } |
| 1419 | } |
| 1420 | |
| 1421 | // Verify that each json file for an excluded module has no rule. |
| 1422 | for _, jsonFile := range excludeJsonFiles { |
| 1423 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1424 | t.Errorf("exclude json file %q found", jsonFile) |
| 1425 | } |
| 1426 | } |
| 1427 | } |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1428 | |
| 1429 | func TestRecoverySnapshotDirected(t *testing.T) { |
| 1430 | bp := ` |
| 1431 | cc_library_shared { |
| 1432 | name: "librecovery", |
| 1433 | recovery: true, |
| 1434 | nocrt: true, |
| 1435 | } |
| 1436 | |
| 1437 | cc_library_shared { |
| 1438 | name: "librecovery_available", |
| 1439 | recovery_available: true, |
| 1440 | nocrt: true, |
| 1441 | } |
| 1442 | |
| 1443 | genrule { |
| 1444 | name: "libfoo_gen", |
| 1445 | cmd: "", |
| 1446 | out: ["libfoo.so"], |
| 1447 | } |
| 1448 | |
| 1449 | cc_prebuilt_library_shared { |
| 1450 | name: "libfoo", |
| 1451 | recovery: true, |
| 1452 | prefer: true, |
| 1453 | srcs: [":libfoo_gen"], |
| 1454 | } |
| 1455 | |
| 1456 | cc_library_shared { |
| 1457 | name: "libfoo", |
| 1458 | recovery: true, |
| 1459 | nocrt: true, |
| 1460 | } |
| 1461 | ` |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1462 | config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1463 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1464 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 1465 | config.TestProductVariables.Platform_vndk_version = StringPtr("29") |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1466 | config.TestProductVariables.DirectedRecoverySnapshot = true |
| 1467 | config.TestProductVariables.RecoverySnapshotModules = make(map[string]bool) |
| 1468 | config.TestProductVariables.RecoverySnapshotModules["librecovery"] = true |
| 1469 | config.TestProductVariables.RecoverySnapshotModules["libfoo"] = true |
| 1470 | ctx := testCcWithConfig(t, config) |
| 1471 | |
| 1472 | // Check recovery snapshot output. |
| 1473 | |
| 1474 | snapshotDir := "recovery-snapshot" |
Paul Duffin | c3e6ce0 | 2021-03-22 23:21:32 +0000 | [diff] [blame] | 1475 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1476 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1477 | |
| 1478 | var includeJsonFiles []string |
| 1479 | |
| 1480 | for _, arch := range [][]string{ |
| 1481 | []string{"arm64", "armv8-a"}, |
| 1482 | } { |
| 1483 | archType := arch[0] |
| 1484 | archVariant := arch[1] |
| 1485 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1486 | |
| 1487 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1488 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1489 | |
| 1490 | // Included modules |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1491 | CheckSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1492 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json")) |
| 1493 | // Check that snapshot captures "prefer: true" prebuilt |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1494 | CheckSnapshot(t, ctx, snapshotSingleton, "prebuilt_libfoo", "libfoo.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1495 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libfoo.so.json")) |
| 1496 | |
| 1497 | // Excluded modules. Modules not included in the directed recovery snapshot |
| 1498 | // are still include as fake modules. |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 1499 | CheckSnapshotRule(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1500 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1501 | } |
| 1502 | |
| 1503 | // Verify that each json file for an included module has a rule. |
| 1504 | for _, jsonFile := range includeJsonFiles { |
| 1505 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1506 | t.Errorf("include json file %q not found", jsonFile) |
| 1507 | } |
| 1508 | } |
| 1509 | } |