Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1 | // Copyright (C) 2019 The Android Open Source Project |
| 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 ( |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 18 | "path/filepath" |
| 19 | "testing" |
| 20 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 21 | "android/soong/android" |
Colin Cross | e9fe294 | 2020-11-10 18:12:15 -0800 | [diff] [blame] | 22 | "android/soong/genrule" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 23 | ) |
| 24 | |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 25 | func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) { |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 26 | RegisterPrebuiltBuildComponents(ctx) |
Paul Duffin | 036e700 | 2019-12-19 19:16:28 +0000 | [diff] [blame] | 27 | RegisterCCBuildComponents(ctx) |
Paul Duffin | 2ee6979 | 2020-01-16 12:14:42 +0000 | [diff] [blame] | 28 | RegisterBinaryBuildComponents(ctx) |
Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 29 | RegisterLibraryBuildComponents(ctx) |
Paul Duffin | 1c6c1c7 | 2020-02-21 10:28:43 +0000 | [diff] [blame] | 30 | RegisterLibraryHeadersBuildComponents(ctx) |
Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 31 | |
| 32 | ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory) |
Jiyong Park | 46a512f | 2020-12-04 18:02:13 +0900 | [diff] [blame] | 33 | ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory) |
Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 34 | ctx.RegisterModuleType("cc_object", ObjectFactory) |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 35 | ctx.RegisterModuleType("cc_genrule", genRuleFactory) |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 36 | ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory) |
| 37 | ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory) |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 38 | ctx.RegisterModuleType("ndk_library", NdkLibraryFactory) |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 41 | func GatherRequiredDepsForTest(oses ...android.OsType) string { |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 42 | ret := commonDefaultModules() |
| 43 | |
| 44 | supportLinuxBionic := false |
| 45 | for _, os := range oses { |
| 46 | if os == android.Fuchsia { |
| 47 | ret += withFuchsiaModules() |
| 48 | } |
| 49 | if os == android.Windows { |
| 50 | ret += withWindowsModules() |
| 51 | } |
| 52 | if os == android.LinuxBionic { |
| 53 | supportLinuxBionic = true |
| 54 | ret += withLinuxBionic() |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | if !supportLinuxBionic { |
| 59 | ret += withoutLinuxBionic() |
| 60 | } |
| 61 | |
| 62 | return ret |
| 63 | } |
| 64 | |
| 65 | func commonDefaultModules() string { |
| 66 | return ` |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 67 | toolchain_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 68 | name: "libcompiler_rt-extras", |
| 69 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 70 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 71 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 72 | recovery_available: true, |
| 73 | src: "", |
| 74 | } |
| 75 | |
| 76 | toolchain_library { |
| 77 | name: "libclang_rt.builtins-arm-android", |
| 78 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 79 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 80 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 81 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 82 | native_bridge_supported: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 83 | src: "", |
| 84 | } |
| 85 | |
| 86 | toolchain_library { |
| 87 | name: "libclang_rt.builtins-aarch64-android", |
| 88 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 89 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 90 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 91 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 92 | native_bridge_supported: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 93 | src: "", |
| 94 | } |
| 95 | |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 96 | cc_prebuilt_library_shared { |
| 97 | name: "libclang_rt.hwasan-aarch64-android", |
| 98 | nocrt: true, |
| 99 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 100 | product_available: true, |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 101 | recovery_available: true, |
| 102 | system_shared_libs: [], |
| 103 | stl: "none", |
| 104 | srcs: [""], |
| 105 | check_elf_files: false, |
| 106 | sanitize: { |
| 107 | never: true, |
| 108 | }, |
| 109 | } |
| 110 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 111 | toolchain_library { |
| 112 | name: "libclang_rt.builtins-i686-android", |
| 113 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 114 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 115 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 116 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 117 | native_bridge_supported: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 118 | src: "", |
| 119 | } |
| 120 | |
| 121 | toolchain_library { |
| 122 | name: "libclang_rt.builtins-x86_64-android", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 123 | defaults: ["linux_bionic_supported"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 124 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 125 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 126 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 127 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 128 | native_bridge_supported: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 129 | src: "", |
| 130 | } |
| 131 | |
| 132 | toolchain_library { |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 133 | name: "libunwind", |
| 134 | defaults: ["linux_bionic_supported"], |
| 135 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 136 | vendor_ramdisk_available: true, |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 137 | product_available: true, |
| 138 | recovery_available: true, |
| 139 | native_bridge_supported: true, |
| 140 | src: "", |
| 141 | } |
| 142 | |
| 143 | toolchain_library { |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 144 | name: "libclang_rt.fuzzer-arm-android", |
| 145 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 146 | product_available: true, |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 147 | recovery_available: true, |
| 148 | src: "", |
| 149 | } |
| 150 | |
| 151 | toolchain_library { |
| 152 | name: "libclang_rt.fuzzer-aarch64-android", |
| 153 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 154 | product_available: true, |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 155 | recovery_available: true, |
| 156 | src: "", |
| 157 | } |
| 158 | |
| 159 | toolchain_library { |
| 160 | name: "libclang_rt.fuzzer-i686-android", |
| 161 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 162 | product_available: true, |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 163 | recovery_available: true, |
| 164 | src: "", |
| 165 | } |
| 166 | |
| 167 | toolchain_library { |
| 168 | name: "libclang_rt.fuzzer-x86_64-android", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 169 | defaults: ["linux_bionic_supported"], |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 170 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 171 | product_available: true, |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 172 | recovery_available: true, |
| 173 | src: "", |
| 174 | } |
| 175 | |
| 176 | toolchain_library { |
| 177 | name: "libclang_rt.fuzzer-x86_64", |
| 178 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 179 | product_available: true, |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 180 | recovery_available: true, |
| 181 | src: "", |
| 182 | } |
| 183 | |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 184 | // Needed for sanitizer |
| 185 | cc_prebuilt_library_shared { |
| 186 | name: "libclang_rt.ubsan_standalone-aarch64-android", |
| 187 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 188 | product_available: true, |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 189 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 190 | system_shared_libs: [], |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 191 | srcs: [""], |
| 192 | } |
| 193 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 194 | cc_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 195 | name: "libc", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 196 | defaults: ["linux_bionic_supported"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 197 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 198 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 199 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 200 | system_shared_libs: [], |
| 201 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 202 | stubs: { |
| 203 | versions: ["27", "28", "29"], |
| 204 | }, |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 205 | llndk: { |
| 206 | symbol_file: "libc.map.txt", |
| 207 | }, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 208 | } |
| 209 | cc_library { |
| 210 | name: "libm", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 211 | defaults: ["linux_bionic_supported"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 212 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 213 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 214 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 215 | system_shared_libs: [], |
| 216 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 217 | stubs: { |
| 218 | versions: ["27", "28", "29"], |
| 219 | }, |
| 220 | apex_available: [ |
| 221 | "//apex_available:platform", |
| 222 | "myapex" |
| 223 | ], |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 224 | llndk: { |
| 225 | symbol_file: "libm.map.txt", |
| 226 | }, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 227 | } |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 228 | |
| 229 | // Coverage libraries |
| 230 | cc_library { |
| 231 | name: "libprofile-extras", |
| 232 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 233 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 234 | product_available: true, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 235 | recovery_available: true, |
| 236 | native_coverage: false, |
| 237 | system_shared_libs: [], |
| 238 | stl: "none", |
| 239 | notice: "custom_notice", |
| 240 | } |
| 241 | cc_library { |
| 242 | name: "libprofile-clang-extras", |
| 243 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 244 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 245 | product_available: true, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 246 | recovery_available: true, |
| 247 | native_coverage: false, |
| 248 | system_shared_libs: [], |
| 249 | stl: "none", |
| 250 | notice: "custom_notice", |
| 251 | } |
| 252 | cc_library { |
| 253 | name: "libprofile-extras_ndk", |
| 254 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 255 | product_available: true, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 256 | native_coverage: false, |
| 257 | system_shared_libs: [], |
| 258 | stl: "none", |
| 259 | notice: "custom_notice", |
| 260 | sdk_version: "current", |
| 261 | } |
| 262 | cc_library { |
| 263 | name: "libprofile-clang-extras_ndk", |
| 264 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 265 | product_available: true, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 266 | native_coverage: false, |
| 267 | system_shared_libs: [], |
| 268 | stl: "none", |
| 269 | notice: "custom_notice", |
| 270 | sdk_version: "current", |
| 271 | } |
| 272 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 273 | cc_library { |
| 274 | name: "libdl", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 275 | defaults: ["linux_bionic_supported"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 276 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 277 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 278 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 279 | system_shared_libs: [], |
| 280 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 281 | stubs: { |
| 282 | versions: ["27", "28", "29"], |
| 283 | }, |
| 284 | apex_available: [ |
| 285 | "//apex_available:platform", |
| 286 | "myapex" |
| 287 | ], |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 288 | llndk: { |
| 289 | symbol_file: "libdl.map.txt", |
| 290 | }, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 291 | } |
| 292 | cc_library { |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 293 | name: "libft2", |
| 294 | no_libcrt: true, |
| 295 | nocrt: true, |
| 296 | system_shared_libs: [], |
| 297 | recovery_available: true, |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 298 | llndk: { |
| 299 | symbol_file: "libft2.map.txt", |
| 300 | private: true, |
| 301 | } |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 302 | } |
| 303 | cc_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 304 | name: "libc++_static", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 305 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 306 | nocrt: true, |
| 307 | system_shared_libs: [], |
| 308 | stl: "none", |
| 309 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 310 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 311 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 312 | recovery_available: true, |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 313 | host_supported: true, |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 314 | min_sdk_version: "29", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 315 | apex_available: [ |
| 316 | "//apex_available:platform", |
| 317 | "//apex_available:anyapex", |
| 318 | ], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 319 | } |
| 320 | cc_library { |
| 321 | name: "libc++", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 322 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 323 | nocrt: true, |
| 324 | system_shared_libs: [], |
| 325 | stl: "none", |
| 326 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 327 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 328 | recovery_available: true, |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 329 | host_supported: true, |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 330 | min_sdk_version: "29", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 331 | vndk: { |
| 332 | enabled: true, |
| 333 | support_system_process: true, |
| 334 | }, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 335 | apex_available: [ |
| 336 | "//apex_available:platform", |
Ivan Lozano | 3e9f9e4 | 2020-12-04 15:05:43 -0500 | [diff] [blame] | 337 | "//apex_available:anyapex", |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 338 | ], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 339 | } |
| 340 | cc_library { |
Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 341 | name: "libc++demangle", |
| 342 | no_libcrt: true, |
| 343 | nocrt: true, |
| 344 | system_shared_libs: [], |
| 345 | stl: "none", |
| 346 | host_supported: false, |
| 347 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 348 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 349 | product_available: true, |
Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 350 | recovery_available: true, |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 351 | min_sdk_version: "29", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 352 | apex_available: [ |
| 353 | "//apex_available:platform", |
| 354 | "//apex_available:anyapex", |
| 355 | ], |
Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 356 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 357 | |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 358 | cc_defaults { |
| 359 | name: "crt_defaults", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 360 | defaults: ["linux_bionic_supported"], |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 361 | recovery_available: true, |
| 362 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 363 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 364 | product_available: true, |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 365 | native_bridge_supported: true, |
| 366 | stl: "none", |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame] | 367 | min_sdk_version: "16", |
| 368 | crt: true, |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 369 | apex_available: [ |
| 370 | "//apex_available:platform", |
| 371 | "//apex_available:anyapex", |
| 372 | ], |
| 373 | } |
| 374 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 375 | cc_object { |
| 376 | name: "crtbegin_so", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 377 | defaults: ["crt_defaults"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | cc_object { |
Colin Cross | 815daf9 | 2019-05-14 16:05:20 -0700 | [diff] [blame] | 381 | name: "crtbegin_dynamic", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 382 | defaults: ["crt_defaults"], |
Colin Cross | 815daf9 | 2019-05-14 16:05:20 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | cc_object { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 386 | name: "crtbegin_static", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 387 | defaults: ["crt_defaults"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | cc_object { |
| 391 | name: "crtend_so", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 392 | defaults: ["crt_defaults"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | cc_object { |
| 396 | name: "crtend_android", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 397 | defaults: ["crt_defaults"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | cc_library { |
| 401 | name: "libprotobuf-cpp-lite", |
| 402 | } |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 403 | |
| 404 | cc_library { |
| 405 | name: "ndk_libunwind", |
| 406 | sdk_version: "current", |
| 407 | stl: "none", |
| 408 | system_shared_libs: [], |
| 409 | } |
| 410 | |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 411 | ndk_library { |
| 412 | name: "libc", |
| 413 | first_version: "minimum", |
| 414 | symbol_file: "libc.map.txt", |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 415 | } |
| 416 | |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 417 | ndk_library { |
| 418 | name: "libm", |
| 419 | first_version: "minimum", |
| 420 | symbol_file: "libm.map.txt", |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 421 | } |
| 422 | |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 423 | ndk_library { |
| 424 | name: "libdl", |
| 425 | first_version: "minimum", |
| 426 | symbol_file: "libdl.map.txt", |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 427 | } |
| 428 | |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 429 | ndk_prebuilt_shared_stl { |
| 430 | name: "ndk_libc++_shared", |
| 431 | } |
Jiyong Park | 46a512f | 2020-12-04 18:02:13 +0900 | [diff] [blame] | 432 | |
| 433 | cc_library_static { |
| 434 | name: "libgoogle-benchmark", |
| 435 | sdk_version: "current", |
| 436 | stl: "none", |
| 437 | system_shared_libs: [], |
| 438 | } |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 439 | |
| 440 | cc_library_static { |
| 441 | name: "note_memtag_heap_async", |
| 442 | } |
| 443 | |
| 444 | cc_library_static { |
| 445 | name: "note_memtag_heap_sync", |
| 446 | } |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 447 | ` |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 448 | } |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 449 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 450 | func withWindowsModules() string { |
| 451 | return ` |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 452 | toolchain_library { |
| 453 | name: "libwinpthread", |
| 454 | host_supported: true, |
| 455 | enabled: false, |
| 456 | target: { |
| 457 | windows: { |
| 458 | enabled: true, |
| 459 | }, |
| 460 | }, |
| 461 | src: "", |
| 462 | } |
| 463 | ` |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | func withFuchsiaModules() string { |
| 467 | return ` |
| 468 | cc_library { |
| 469 | name: "libbioniccompat", |
| 470 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 471 | } |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 472 | cc_library { |
| 473 | name: "libcompiler_rt", |
| 474 | stl: "none", |
| 475 | } |
| 476 | ` |
| 477 | } |
| 478 | |
| 479 | func withLinuxBionic() string { |
| 480 | return ` |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 481 | cc_binary { |
| 482 | name: "linker", |
| 483 | defaults: ["linux_bionic_supported"], |
| 484 | recovery_available: true, |
| 485 | stl: "none", |
| 486 | nocrt: true, |
| 487 | static_executable: true, |
| 488 | native_coverage: false, |
| 489 | system_shared_libs: [], |
| 490 | } |
| 491 | |
| 492 | cc_genrule { |
Colin Cross | 9cfe611 | 2021-06-11 18:02:22 -0700 | [diff] [blame^] | 493 | name: "host_bionic_linker_script", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 494 | host_supported: true, |
| 495 | device_supported: false, |
| 496 | target: { |
| 497 | host: { |
| 498 | enabled: false, |
| 499 | }, |
| 500 | linux_bionic: { |
| 501 | enabled: true, |
| 502 | }, |
| 503 | }, |
Colin Cross | 9cfe611 | 2021-06-11 18:02:22 -0700 | [diff] [blame^] | 504 | out: ["linker.script"], |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | cc_defaults { |
| 508 | name: "linux_bionic_supported", |
| 509 | host_supported: true, |
| 510 | target: { |
| 511 | host: { |
| 512 | enabled: false, |
| 513 | }, |
| 514 | linux_bionic: { |
| 515 | enabled: true, |
| 516 | }, |
| 517 | }, |
| 518 | } |
| 519 | ` |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 520 | } |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 521 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 522 | func withoutLinuxBionic() string { |
| 523 | return ` |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 524 | cc_defaults { |
| 525 | name: "linux_bionic_supported", |
| 526 | } |
| 527 | ` |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 528 | } |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 529 | |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 530 | func GatherRequiredFilesForTest(fs map[string][]byte) { |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 531 | } |
| 532 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 533 | // The directory in which cc linux bionic default modules will be defined. |
| 534 | // |
| 535 | // Placing them here ensures that their location does not conflict with default test modules |
| 536 | // defined by other packages. |
| 537 | const linuxBionicDefaultsPath = "defaults/cc/linux-bionic/Android.bp" |
| 538 | |
| 539 | // The directory in which the default cc common test modules will be defined. |
| 540 | // |
| 541 | // Placing them here ensures that their location does not conflict with default test modules |
| 542 | // defined by other packages. |
| 543 | const DefaultCcCommonTestModulesDir = "defaults/cc/common/" |
| 544 | |
| 545 | // Test fixture preparer that will register most cc build components. |
| 546 | // |
| 547 | // Singletons and mutators should only be added here if they are needed for a majority of cc |
| 548 | // module types, otherwise they should be added under a separate preparer to allow them to be |
| 549 | // selected only when needed to reduce test execution time. |
| 550 | // |
| 551 | // Module types do not have much of an overhead unless they are used so this should include as many |
| 552 | // module types as possible. The exceptions are those module types that require mutators and/or |
| 553 | // singletons in order to function in which case they should be kept together in a separate |
| 554 | // preparer. |
| 555 | var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers( |
| 556 | android.PrepareForTestWithAndroidBuildComponents, |
| 557 | android.FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest), |
| 558 | android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { |
| 559 | ctx.RegisterModuleType("cc_fuzz", FuzzFactory) |
| 560 | ctx.RegisterModuleType("cc_test", TestFactory) |
| 561 | ctx.RegisterModuleType("cc_test_library", TestLibraryFactory) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 562 | ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) |
| 563 | |
| 564 | RegisterVndkLibraryTxtTypes(ctx) |
| 565 | }), |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 566 | |
| 567 | // Additional files needed in tests that disallow non-existent source files. |
| 568 | // This includes files that are needed by all, or at least most, instances of a cc module type. |
| 569 | android.MockFS{ |
| 570 | // Needed for ndk_prebuilt_(shared|static)_stl. |
| 571 | "prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs": nil, |
| 572 | }.AddToFixture(), |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 573 | ) |
| 574 | |
| 575 | // Preparer that will define default cc modules, e.g. standard prebuilt modules. |
| 576 | var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers( |
| 577 | PrepareForTestWithCcBuildComponents, |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 578 | |
| 579 | // Additional files needed in tests that disallow non-existent source. |
| 580 | android.MockFS{ |
| 581 | "defaults/cc/common/libc.map.txt": nil, |
| 582 | "defaults/cc/common/libdl.map.txt": nil, |
| 583 | "defaults/cc/common/libm.map.txt": nil, |
| 584 | }.AddToFixture(), |
| 585 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 586 | // Place the default cc test modules that are common to all platforms in a location that will not |
| 587 | // conflict with default test modules defined by other packages. |
| 588 | android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()), |
| 589 | // Disable linux bionic by default. |
| 590 | android.FixtureAddTextFile(linuxBionicDefaultsPath, withoutLinuxBionic()), |
| 591 | ) |
| 592 | |
| 593 | // Prepare a fixture to use all cc module types, mutators and singletons fully. |
| 594 | // |
| 595 | // This should only be used by tests that want to run with as much of the build enabled as possible. |
| 596 | var PrepareForIntegrationTestWithCc = android.GroupFixturePreparers( |
| 597 | android.PrepareForIntegrationTestWithAndroid, |
| 598 | genrule.PrepareForIntegrationTestWithGenrule, |
| 599 | PrepareForTestWithCcDefaultModules, |
| 600 | ) |
| 601 | |
| 602 | // The preparer to include if running a cc related test for windows. |
| 603 | var PrepareForTestOnWindows = android.GroupFixturePreparers( |
| 604 | // Place the default cc test modules for windows platforms in a location that will not conflict |
| 605 | // with default test modules defined by other packages. |
| 606 | android.FixtureAddTextFile("defaults/cc/windows/Android.bp", withWindowsModules()), |
| 607 | ) |
| 608 | |
| 609 | // The preparer to include if running a cc related test for linux bionic. |
| 610 | var PrepareForTestOnLinuxBionic = android.GroupFixturePreparers( |
Paul Duffin | 6e9a400 | 2021-03-11 19:01:26 +0000 | [diff] [blame] | 611 | // Enable linux bionic |
| 612 | // |
| 613 | // Can be used after PrepareForTestWithCcDefaultModules to override its default behavior of |
| 614 | // disabling linux bionic, hence why this uses FixtureOverrideTextFile. |
| 615 | android.FixtureOverrideTextFile(linuxBionicDefaultsPath, withLinuxBionic()), |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 616 | ) |
| 617 | |
Paul Duffin | ecdac8a | 2021-02-24 19:18:42 +0000 | [diff] [blame] | 618 | // The preparer to include if running a cc related test for fuchsia. |
| 619 | var PrepareForTestOnFuchsia = android.GroupFixturePreparers( |
| 620 | // Place the default cc test modules for fuschia in a location that will not conflict with default |
| 621 | // test modules defined by other packages. |
| 622 | android.FixtureAddTextFile("defaults/cc/fuschia/Android.bp", withFuchsiaModules()), |
| 623 | android.PrepareForTestSetDeviceToFuchsia, |
| 624 | ) |
| 625 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 626 | // This adds some additional modules and singletons which might negatively impact the performance |
| 627 | // of tests so they are not included in the PrepareForIntegrationTestWithCc. |
| 628 | var PrepareForTestWithCcIncludeVndk = android.GroupFixturePreparers( |
| 629 | PrepareForIntegrationTestWithCc, |
| 630 | android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 631 | VendorSnapshotImageSingleton.Init(ctx) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 632 | recoverySnapshotImageSingleton.init(ctx) |
| 633 | ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton) |
| 634 | }), |
| 635 | ) |
| 636 | |
| 637 | // TestConfig is the legacy way of creating a test Config for testing cc modules. |
| 638 | // |
| 639 | // See testCc for an explanation as to how to stop using this deprecated method. |
| 640 | // |
| 641 | // deprecated |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 642 | func TestConfig(buildDir string, os android.OsType, env map[string]string, |
| 643 | bp string, fs map[string][]byte) android.Config { |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 644 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 645 | // add some modules that are required by the compiler and/or linker |
| 646 | bp = bp + GatherRequiredDepsForTest(os) |
| 647 | |
Colin Cross | 2fce23a | 2020-06-07 17:02:48 -0700 | [diff] [blame] | 648 | mockFS := map[string][]byte{} |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 649 | |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 650 | GatherRequiredFilesForTest(mockFS) |
| 651 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 652 | for k, v := range fs { |
| 653 | mockFS[k] = v |
| 654 | } |
| 655 | |
| 656 | var config android.Config |
| 657 | if os == android.Fuchsia { |
Paul Duffin | ecdac8a | 2021-02-24 19:18:42 +0000 | [diff] [blame] | 658 | panic("Fuchsia not supported use test fixture instead") |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 659 | } else { |
| 660 | config = android.TestArchConfig(buildDir, env, bp, mockFS) |
| 661 | } |
| 662 | |
| 663 | return config |
| 664 | } |
| 665 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 666 | // CreateTestContext is the legacy way of creating a TestContext for testing cc modules. |
| 667 | // |
| 668 | // See testCc for an explanation as to how to stop using this deprecated method. |
| 669 | // |
| 670 | // deprecated |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 671 | func CreateTestContext(config android.Config) *android.TestContext { |
| 672 | ctx := android.NewTestArchContext(config) |
Paul Duffin | d6ceb86 | 2021-03-04 23:02:31 +0000 | [diff] [blame] | 673 | genrule.RegisterGenruleBuildComponents(ctx) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 674 | ctx.RegisterModuleType("cc_fuzz", FuzzFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 675 | ctx.RegisterModuleType("cc_test", TestFactory) |
Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 676 | ctx.RegisterModuleType("cc_test_library", TestLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 677 | ctx.RegisterModuleType("filegroup", android.FileGroupFactory) |
| 678 | ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 679 | |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 680 | VendorSnapshotImageSingleton.Init(ctx) |
Colin Cross | e0edaf9 | 2021-01-11 17:31:17 -0800 | [diff] [blame] | 681 | recoverySnapshotImageSingleton.init(ctx) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 682 | ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton) |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 683 | RegisterVndkLibraryTxtTypes(ctx) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 684 | |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 685 | ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) |
Paul Duffin | 021f4e5 | 2020-07-30 16:04:17 +0100 | [diff] [blame] | 686 | android.RegisterPrebuiltMutators(ctx) |
Paul Duffin | c988c8e | 2020-04-29 18:27:14 +0100 | [diff] [blame] | 687 | RegisterRequiredBuildComponentsForTest(ctx) |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 688 | |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 689 | return ctx |
| 690 | } |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 691 | |
| 692 | func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool, fake bool) { |
| 693 | t.Helper() |
| 694 | mod := ctx.ModuleForTests(moduleName, variant) |
| 695 | outputFiles := mod.OutputFiles(t, "") |
| 696 | if len(outputFiles) != 1 { |
| 697 | t.Errorf("%q must have single output\n", moduleName) |
| 698 | return |
| 699 | } |
| 700 | snapshotPath := filepath.Join(subDir, snapshotFilename) |
| 701 | |
| 702 | if include { |
| 703 | out := singleton.Output(snapshotPath) |
| 704 | if fake { |
| 705 | if out.Rule == nil { |
| 706 | t.Errorf("Missing rule for module %q output file %q", moduleName, outputFiles[0]) |
| 707 | } |
| 708 | } else { |
| 709 | if out.Input.String() != outputFiles[0].String() { |
| 710 | t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0]) |
| 711 | } |
| 712 | } |
| 713 | } else { |
| 714 | out := singleton.MaybeOutput(snapshotPath) |
| 715 | if out.Rule != nil { |
| 716 | t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0]) |
| 717 | } |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | func CheckSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 722 | t.Helper() |
| 723 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, false) |
| 724 | } |
| 725 | |
| 726 | func CheckSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 727 | t.Helper() |
| 728 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false, false) |
| 729 | } |
| 730 | |
| 731 | func CheckSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 732 | t.Helper() |
| 733 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true) |
| 734 | } |
| 735 | |
| 736 | func AssertExcludeFromVendorSnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool, variant string) { |
| 737 | t.Helper() |
| 738 | m := ctx.ModuleForTests(name, variant).Module().(LinkableInterface) |
| 739 | if m.ExcludeFromVendorSnapshot() != expected { |
| 740 | t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", m.String(), expected) |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | func GetOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) { |
| 745 | for _, moduleName := range moduleNames { |
| 746 | module := ctx.ModuleForTests(moduleName, variant).Module().(*Module) |
| 747 | output := module.outputFile.Path().RelativeToTop() |
| 748 | paths = append(paths, output) |
| 749 | } |
| 750 | return paths |
| 751 | } |