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