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