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