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