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