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