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