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