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