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