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