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" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 24 | ) |
| 25 | |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 26 | func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) { |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 27 | RegisterPrebuiltBuildComponents(ctx) |
Paul Duffin | 036e700 | 2019-12-19 19:16:28 +0000 | [diff] [blame] | 28 | RegisterCCBuildComponents(ctx) |
Paul Duffin | 2ee6979 | 2020-01-16 12:14:42 +0000 | [diff] [blame] | 29 | RegisterBinaryBuildComponents(ctx) |
Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 30 | RegisterLibraryBuildComponents(ctx) |
Paul Duffin | 1c6c1c7 | 2020-02-21 10:28:43 +0000 | [diff] [blame] | 31 | RegisterLibraryHeadersBuildComponents(ctx) |
Inseob Kim | 5eb7ee9 | 2022-04-27 10:30:34 +0900 | [diff] [blame] | 32 | RegisterLibraryStubBuildComponents(ctx) |
Paul Duffin | 6c26dc7 | 2019-12-19 15:02:40 +0000 | [diff] [blame] | 33 | |
Kiyoung Kim | 487689e | 2022-07-26 09:48:22 +0900 | [diff] [blame] | 34 | multitree.RegisterApiImportsModule(ctx) |
| 35 | |
Sam Delmerico | f2b1606 | 2023-09-25 12:13:17 +0000 | [diff] [blame] | 36 | ctx.RegisterModuleType("prebuilt_build_tool", android.NewPrebuiltBuildTool) |
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) |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 42 | ctx.RegisterModuleType("ndk_library", NdkLibraryFactory) |
Spandan Das | 319711b | 2023-09-19 19:04:41 +0000 | [diff] [blame] | 43 | ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory) |
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", |
Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 71 | host_supported: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 72 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 73 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 74 | recovery_available: true, |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 75 | no_libcrt: true, |
| 76 | sdk_version: "minimum", |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 77 | nocrt: true, |
Kalesh Singh | f4ffe0a | 2024-01-29 13:01:51 -0800 | [diff] [blame] | 78 | no_crt_pad_segment: 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 | }, |
Spandan Das | 4de7b49 | 2023-05-05 21:13:01 +0000 | [diff] [blame] | 85 | apex_available: [ |
| 86 | "//apex_available:anyapex", |
| 87 | "//apex_available:platform", |
| 88 | ], |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 89 | } |
| 90 | |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 91 | cc_prebuilt_library_static { |
| 92 | name: "libcompiler_rt-extras", |
| 93 | defaults: ["toolchain_libs_defaults"], |
| 94 | vendor_ramdisk_available: true, |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 95 | srcs: [""], |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | cc_prebuilt_library_static { |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 99 | name: "libclang_rt.builtins", |
Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 100 | defaults: ["toolchain_libs_defaults"], |
| 101 | host_supported: true, |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 102 | vendor_available: true, |
| 103 | vendor_ramdisk_available: true, |
| 104 | native_bridge_supported: true, |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 105 | srcs: [""], |
Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 106 | } |
| 107 | |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 108 | cc_prebuilt_library_shared { |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 109 | name: "libclang_rt.hwasan", |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 110 | defaults: ["toolchain_libs_defaults"], |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 111 | srcs: [""], |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | cc_prebuilt_library_static { |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 115 | name: "libunwind", |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 116 | defaults: [ |
| 117 | "linux_bionic_supported", |
| 118 | "toolchain_libs_defaults", |
| 119 | ], |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 120 | vendor_ramdisk_available: true, |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 121 | native_bridge_supported: true, |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 122 | srcs: [""], |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 123 | } |
| 124 | |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 125 | cc_prebuilt_library_static { |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 126 | name: "libclang_rt.fuzzer", |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 127 | defaults: [ |
| 128 | "linux_bionic_supported", |
| 129 | "toolchain_libs_defaults", |
| 130 | ], |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 131 | srcs: [""], |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 134 | // Needed for sanitizer |
| 135 | cc_prebuilt_library_shared { |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 136 | name: "libclang_rt.ubsan_standalone", |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 137 | defaults: ["toolchain_libs_defaults"], |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 138 | srcs: [""], |
Paul Duffin | d686791 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 141 | cc_prebuilt_library_static { |
Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 142 | name: "libclang_rt.ubsan_standalone.static", |
| 143 | defaults: ["toolchain_libs_defaults"], |
| 144 | srcs: [""], |
| 145 | } |
| 146 | |
| 147 | cc_prebuilt_library_static { |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 148 | name: "libclang_rt.ubsan_minimal", |
Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 149 | defaults: ["toolchain_libs_defaults"], |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 150 | host_supported: true, |
| 151 | target: { |
| 152 | android_arm64: { |
| 153 | srcs: ["libclang_rt.ubsan_minimal.android_arm64.a"], |
| 154 | }, |
| 155 | android_arm: { |
| 156 | srcs: ["libclang_rt.ubsan_minimal.android_arm.a"], |
| 157 | }, |
| 158 | linux_glibc_x86_64: { |
| 159 | srcs: ["libclang_rt.ubsan_minimal.x86_64.a"], |
| 160 | }, |
| 161 | linux_glibc_x86: { |
| 162 | srcs: ["libclang_rt.ubsan_minimal.x86.a"], |
| 163 | }, |
Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 164 | linux_musl_x86_64: { |
| 165 | srcs: ["libclang_rt.ubsan_minimal.x86_64.a"], |
| 166 | }, |
| 167 | linux_musl_x86: { |
| 168 | srcs: ["libclang_rt.ubsan_minimal.x86.a"], |
| 169 | }, |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 170 | }, |
Colin Cross | 06c80eb | 2022-02-10 10:34:19 -0800 | [diff] [blame] | 171 | } |
| 172 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 173 | cc_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 174 | name: "libc", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 175 | defaults: ["linux_bionic_supported"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 176 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 177 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 178 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 179 | system_shared_libs: [], |
| 180 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 181 | stubs: { |
| 182 | versions: ["27", "28", "29"], |
| 183 | }, |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 184 | llndk: { |
| 185 | symbol_file: "libc.map.txt", |
| 186 | }, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 187 | } |
| 188 | cc_library { |
| 189 | name: "libm", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 190 | defaults: ["linux_bionic_supported"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 191 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 192 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 193 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 194 | system_shared_libs: [], |
| 195 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 196 | stubs: { |
| 197 | versions: ["27", "28", "29"], |
| 198 | }, |
| 199 | apex_available: [ |
| 200 | "//apex_available:platform", |
| 201 | "myapex" |
| 202 | ], |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 203 | llndk: { |
| 204 | symbol_file: "libm.map.txt", |
| 205 | }, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 206 | } |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 207 | |
| 208 | // Coverage libraries |
| 209 | cc_library { |
| 210 | name: "libprofile-extras", |
| 211 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 212 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 213 | product_available: true, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 214 | recovery_available: true, |
| 215 | native_coverage: false, |
| 216 | system_shared_libs: [], |
| 217 | stl: "none", |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 218 | } |
| 219 | cc_library { |
| 220 | name: "libprofile-clang-extras", |
| 221 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 222 | vendor_ramdisk_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 | recovery_available: true, |
| 225 | native_coverage: false, |
| 226 | system_shared_libs: [], |
| 227 | stl: "none", |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 228 | } |
| 229 | cc_library { |
| 230 | name: "libprofile-extras_ndk", |
| 231 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 232 | product_available: true, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 233 | native_coverage: false, |
| 234 | system_shared_libs: [], |
| 235 | stl: "none", |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 236 | sdk_version: "current", |
| 237 | } |
| 238 | cc_library { |
| 239 | name: "libprofile-clang-extras_ndk", |
| 240 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 241 | product_available: true, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 242 | native_coverage: false, |
| 243 | system_shared_libs: [], |
| 244 | stl: "none", |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 245 | sdk_version: "current", |
| 246 | } |
| 247 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 248 | cc_library { |
| 249 | name: "libdl", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 250 | defaults: ["linux_bionic_supported"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 251 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 252 | nocrt: true, |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 253 | stl: "none", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 254 | system_shared_libs: [], |
| 255 | recovery_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 256 | stubs: { |
| 257 | versions: ["27", "28", "29"], |
| 258 | }, |
| 259 | apex_available: [ |
| 260 | "//apex_available:platform", |
| 261 | "myapex" |
| 262 | ], |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 263 | llndk: { |
| 264 | symbol_file: "libdl.map.txt", |
| 265 | }, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 266 | } |
| 267 | cc_library { |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 268 | name: "libft2", |
| 269 | no_libcrt: true, |
| 270 | nocrt: true, |
| 271 | system_shared_libs: [], |
| 272 | recovery_available: true, |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 273 | llndk: { |
| 274 | symbol_file: "libft2.map.txt", |
| 275 | private: true, |
| 276 | } |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 277 | } |
| 278 | cc_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 279 | name: "libc++_static", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 280 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 281 | nocrt: true, |
| 282 | system_shared_libs: [], |
| 283 | stl: "none", |
| 284 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 285 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 286 | product_available: true, |
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", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 290 | apex_available: [ |
| 291 | "//apex_available:platform", |
| 292 | "//apex_available:anyapex", |
| 293 | ], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 294 | } |
| 295 | cc_library { |
| 296 | name: "libc++", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 297 | no_libcrt: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 298 | nocrt: true, |
| 299 | system_shared_libs: [], |
| 300 | stl: "none", |
| 301 | vendor_available: true, |
Ivan Lozano | 0a468a4 | 2024-05-13 21:03:34 -0400 | [diff] [blame^] | 302 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 303 | product_available: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 304 | recovery_available: true, |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 305 | host_supported: true, |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 306 | min_sdk_version: "29", |
Kiyoung Kim | 0d1c1e6 | 2024-03-26 16:33:58 +0900 | [diff] [blame] | 307 | double_loadable: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 308 | apex_available: [ |
| 309 | "//apex_available:platform", |
Ivan Lozano | 3e9f9e4 | 2020-12-04 15:05:43 -0500 | [diff] [blame] | 310 | "//apex_available:anyapex", |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 311 | ], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 312 | } |
| 313 | cc_library { |
Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 314 | name: "libc++demangle", |
| 315 | no_libcrt: true, |
| 316 | nocrt: true, |
| 317 | system_shared_libs: [], |
| 318 | stl: "none", |
| 319 | host_supported: false, |
| 320 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 321 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 322 | product_available: true, |
Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 323 | recovery_available: true, |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 324 | min_sdk_version: "29", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 325 | apex_available: [ |
| 326 | "//apex_available:platform", |
| 327 | "//apex_available:anyapex", |
| 328 | ], |
Dan Albert | 2da19cb | 2019-07-24 12:17:40 -0700 | [diff] [blame] | 329 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 330 | |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 331 | cc_defaults { |
| 332 | name: "crt_defaults", |
Martin Stjernholm | 7feceb2 | 2020-07-11 04:33:29 +0100 | [diff] [blame] | 333 | defaults: ["linux_bionic_supported"], |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 334 | recovery_available: true, |
| 335 | vendor_available: true, |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 336 | vendor_ramdisk_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 337 | product_available: true, |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 338 | native_bridge_supported: true, |
| 339 | stl: "none", |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame] | 340 | min_sdk_version: "16", |
| 341 | crt: true, |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 342 | system_shared_libs: [], |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 343 | apex_available: [ |
| 344 | "//apex_available:platform", |
| 345 | "//apex_available:anyapex", |
| 346 | ], |
| 347 | } |
| 348 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 349 | cc_object { |
| 350 | name: "crtbegin_so", |
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_so.c"], |
| 353 | objs: ["crtbrand"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | cc_object { |
Colin Cross | 815daf9 | 2019-05-14 16:05:20 -0700 | [diff] [blame] | 357 | name: "crtbegin_dynamic", |
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: ["crtbegin.c"], |
| 360 | objs: ["crtbrand"], |
Colin Cross | 815daf9 | 2019-05-14 16:05:20 -0700 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | cc_object { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 364 | name: "crtbegin_static", |
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: ["crtbegin.c"], |
| 367 | objs: ["crtbrand"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | cc_object { |
| 371 | name: "crtend_so", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 372 | defaults: ["crt_defaults"], |
Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 373 | srcs: ["crtend_so.c"], |
| 374 | objs: ["crtbrand"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | cc_object { |
| 378 | name: "crtend_android", |
Jiyong Park | 541142c | 2020-03-07 16:35:46 +0900 | [diff] [blame] | 379 | defaults: ["crt_defaults"], |
Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 380 | srcs: ["crtend.c"], |
| 381 | objs: ["crtbrand"], |
| 382 | } |
| 383 | |
| 384 | cc_object { |
Kalesh Singh | f4ffe0a | 2024-01-29 13:01:51 -0800 | [diff] [blame] | 385 | name: "crt_pad_segment", |
| 386 | defaults: ["crt_defaults"], |
| 387 | } |
| 388 | |
| 389 | cc_object { |
Jiyong Park | 7549d46 | 2021-08-25 16:16:03 +0900 | [diff] [blame] | 390 | name: "crtbrand", |
| 391 | defaults: ["crt_defaults"], |
| 392 | srcs: ["crtbrand.c"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | cc_library { |
| 396 | name: "libprotobuf-cpp-lite", |
| 397 | } |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 398 | |
| 399 | cc_library { |
| 400 | name: "ndk_libunwind", |
Colin Cross | ae62818 | 2021-06-14 16:52:28 -0700 | [diff] [blame] | 401 | sdk_version: "minimum", |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 402 | stl: "none", |
| 403 | system_shared_libs: [], |
| 404 | } |
| 405 | |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 406 | ndk_library { |
| 407 | name: "libc", |
| 408 | first_version: "minimum", |
| 409 | symbol_file: "libc.map.txt", |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 412 | ndk_library { |
| 413 | name: "libm", |
| 414 | first_version: "minimum", |
| 415 | symbol_file: "libm.map.txt", |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 416 | } |
| 417 | |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 418 | ndk_library { |
| 419 | name: "libdl", |
| 420 | first_version: "minimum", |
| 421 | symbol_file: "libdl.map.txt", |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 422 | } |
| 423 | |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 424 | ndk_prebuilt_shared_stl { |
| 425 | name: "ndk_libc++_shared", |
Colin Cross | ae62818 | 2021-06-14 16:52:28 -0700 | [diff] [blame] | 426 | export_include_dirs: ["ndk_libc++_shared"], |
| 427 | } |
| 428 | |
Jiyong Park | 46a512f | 2020-12-04 18:02:13 +0900 | [diff] [blame] | 429 | cc_library_static { |
| 430 | name: "libgoogle-benchmark", |
| 431 | sdk_version: "current", |
| 432 | stl: "none", |
| 433 | system_shared_libs: [], |
| 434 | } |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 435 | |
| 436 | cc_library_static { |
| 437 | name: "note_memtag_heap_async", |
| 438 | } |
| 439 | |
| 440 | cc_library_static { |
| 441 | name: "note_memtag_heap_sync", |
| 442 | } |
Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 443 | |
Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 444 | cc_library { |
| 445 | name: "libc_musl", |
| 446 | host_supported: true, |
| 447 | no_libcrt: true, |
| 448 | nocrt: true, |
| 449 | system_shared_libs: [], |
| 450 | stl: "none", |
| 451 | } |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 452 | ` |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 453 | } |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 454 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 455 | func withWindowsModules() string { |
| 456 | return ` |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 457 | cc_prebuilt_library_static { |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 458 | name: "libwinpthread", |
| 459 | host_supported: true, |
| 460 | enabled: false, |
| 461 | target: { |
| 462 | windows: { |
| 463 | enabled: true, |
| 464 | }, |
| 465 | }, |
Liz Kammer | 718eb27 | 2022-01-07 10:53:37 -0500 | [diff] [blame] | 466 | stl: "none", |
| 467 | srcs:[""], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 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) { |
Cory Barker | a1da26f | 2022-06-07 20:12:06 +0000 | [diff] [blame] | 552 | ctx.RegisterModuleType("cc_fuzz", LibFuzzFactory) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 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. |
Spandan Das | 6e332d2 | 2023-09-13 17:58:52 +0000 | [diff] [blame] | 564 | "defaults/cc/common/current/sources/cxx-stl/llvm-libc++/libs": nil, |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 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{ |
Ivan Lozano | 0a468a4 | 2024-05-13 21:03:34 -0400 | [diff] [blame^] | 574 | "defaults/cc/common/libc.map.txt": nil, |
| 575 | "defaults/cc/common/libdl.map.txt": nil, |
| 576 | "defaults/cc/common/libft2.map.txt": nil, |
| 577 | "defaults/cc/common/libm.map.txt": nil, |
| 578 | "defaults/cc/common/ndk_libc++_shared": nil, |
| 579 | "defaults/cc/common/crtbegin_so.c": nil, |
| 580 | "defaults/cc/common/crtbegin.c": nil, |
| 581 | "defaults/cc/common/crtend_so.c": nil, |
| 582 | "defaults/cc/common/crtend.c": nil, |
| 583 | "defaults/cc/common/crtbrand.c": nil, |
| 584 | "external/compiler-rt/lib/cfi/cfi_blocklist.txt": nil, |
Colin Cross | 3e5e778 | 2022-06-17 22:17:05 +0000 | [diff] [blame] | 585 | |
| 586 | "defaults/cc/common/libclang_rt.ubsan_minimal.android_arm64.a": nil, |
| 587 | "defaults/cc/common/libclang_rt.ubsan_minimal.android_arm.a": nil, |
| 588 | "defaults/cc/common/libclang_rt.ubsan_minimal.x86_64.a": nil, |
| 589 | "defaults/cc/common/libclang_rt.ubsan_minimal.x86.a": nil, |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 590 | }.AddToFixture(), |
| 591 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 592 | // Place the default cc test modules that are common to all platforms in a location that will not |
| 593 | // conflict with default test modules defined by other packages. |
| 594 | android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()), |
| 595 | // Disable linux bionic by default. |
| 596 | android.FixtureAddTextFile(linuxBionicDefaultsPath, withoutLinuxBionic()), |
| 597 | ) |
| 598 | |
| 599 | // Prepare a fixture to use all cc module types, mutators and singletons fully. |
| 600 | // |
| 601 | // This should only be used by tests that want to run with as much of the build enabled as possible. |
| 602 | var PrepareForIntegrationTestWithCc = android.GroupFixturePreparers( |
| 603 | android.PrepareForIntegrationTestWithAndroid, |
| 604 | genrule.PrepareForIntegrationTestWithGenrule, |
| 605 | PrepareForTestWithCcDefaultModules, |
| 606 | ) |
| 607 | |
| 608 | // The preparer to include if running a cc related test for windows. |
| 609 | var PrepareForTestOnWindows = android.GroupFixturePreparers( |
| 610 | // Place the default cc test modules for windows platforms in a location that will not conflict |
| 611 | // with default test modules defined by other packages. |
| 612 | android.FixtureAddTextFile("defaults/cc/windows/Android.bp", withWindowsModules()), |
| 613 | ) |
| 614 | |
| 615 | // The preparer to include if running a cc related test for linux bionic. |
| 616 | var PrepareForTestOnLinuxBionic = android.GroupFixturePreparers( |
Paul Duffin | 6e9a400 | 2021-03-11 19:01:26 +0000 | [diff] [blame] | 617 | // Enable linux bionic |
| 618 | // |
| 619 | // Can be used after PrepareForTestWithCcDefaultModules to override its default behavior of |
| 620 | // disabling linux bionic, hence why this uses FixtureOverrideTextFile. |
| 621 | android.FixtureOverrideTextFile(linuxBionicDefaultsPath, withLinuxBionic()), |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 622 | ) |
| 623 | |
Colin Cross | 5dc62c9 | 2023-02-15 12:20:19 -0800 | [diff] [blame] | 624 | // PrepareForTestWithHostMusl sets the host configuration to musl libc instead of glibc. It also disables the test |
| 625 | // on mac, which doesn't support musl libc, and adds musl modules. |
| 626 | var PrepareForTestWithHostMusl = android.GroupFixturePreparers( |
| 627 | android.FixtureModifyConfig(android.ModifyTestConfigForMusl), |
| 628 | android.PrepareForSkipTestOnMac, |
| 629 | android.FixtureAddTextFile("external/musl/Android.bp", ` |
| 630 | cc_defaults { |
| 631 | name: "libc_musl_crt_defaults", |
| 632 | host_supported: true, |
| 633 | device_supported: false, |
| 634 | } |
| 635 | |
| 636 | cc_object { |
| 637 | name: "libc_musl_crtbegin_so", |
| 638 | defaults: ["libc_musl_crt_defaults"], |
| 639 | } |
| 640 | |
| 641 | cc_object { |
| 642 | name: "libc_musl_crtend_so", |
| 643 | defaults: ["libc_musl_crt_defaults"], |
| 644 | } |
| 645 | |
| 646 | cc_object { |
| 647 | name: "libc_musl_crtbegin_dynamic", |
| 648 | defaults: ["libc_musl_crt_defaults"], |
| 649 | } |
| 650 | |
| 651 | cc_object { |
| 652 | name: "libc_musl_crtbegin_static", |
| 653 | defaults: ["libc_musl_crt_defaults"], |
| 654 | } |
| 655 | |
| 656 | cc_object { |
| 657 | name: "libc_musl_crtend", |
| 658 | defaults: ["libc_musl_crt_defaults"], |
| 659 | } |
| 660 | `), |
| 661 | ) |
| 662 | |
Vinh Tran | cde1016 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 663 | // PrepareForTestWithFdoProfile registers module types to test with fdo_profile |
| 664 | var PrepareForTestWithFdoProfile = android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { |
| 665 | ctx.RegisterModuleType("soong_namespace", android.NamespaceFactory) |
Vinh Tran | ce40b92 | 2023-06-05 12:57:55 -0400 | [diff] [blame] | 666 | ctx.RegisterModuleType("fdo_profile", FdoProfileFactory) |
Vinh Tran | cde1016 | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 667 | }) |
| 668 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 669 | // TestConfig is the legacy way of creating a test Config for testing cc modules. |
| 670 | // |
| 671 | // See testCc for an explanation as to how to stop using this deprecated method. |
| 672 | // |
| 673 | // deprecated |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 674 | func TestConfig(buildDir string, os android.OsType, env map[string]string, |
| 675 | bp string, fs map[string][]byte) android.Config { |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 676 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 677 | // add some modules that are required by the compiler and/or linker |
| 678 | bp = bp + GatherRequiredDepsForTest(os) |
| 679 | |
Colin Cross | 2fce23a | 2020-06-07 17:02:48 -0700 | [diff] [blame] | 680 | mockFS := map[string][]byte{} |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 681 | |
Colin Cross | f28329d | 2020-02-15 11:00:10 -0800 | [diff] [blame] | 682 | GatherRequiredFilesForTest(mockFS) |
| 683 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 684 | for k, v := range fs { |
| 685 | mockFS[k] = v |
| 686 | } |
| 687 | |
Colin Cross | cb0ac95 | 2021-07-20 13:17:15 -0700 | [diff] [blame] | 688 | return android.TestArchConfig(buildDir, env, bp, mockFS) |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 689 | } |
| 690 | |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 691 | // CreateTestContext is the legacy way of creating a TestContext for testing cc modules. |
| 692 | // |
| 693 | // See testCc for an explanation as to how to stop using this deprecated method. |
| 694 | // |
| 695 | // deprecated |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 696 | func CreateTestContext(config android.Config) *android.TestContext { |
| 697 | ctx := android.NewTestArchContext(config) |
Paul Duffin | d6ceb86 | 2021-03-04 23:02:31 +0000 | [diff] [blame] | 698 | genrule.RegisterGenruleBuildComponents(ctx) |
Cory Barker | a1da26f | 2022-06-07 20:12:06 +0000 | [diff] [blame] | 699 | ctx.RegisterModuleType("cc_fuzz", LibFuzzFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 700 | ctx.RegisterModuleType("cc_test", TestFactory) |
Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 701 | ctx.RegisterModuleType("cc_test_library", TestLibraryFactory) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 702 | ctx.RegisterModuleType("filegroup", android.FileGroupFactory) |
| 703 | ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 704 | |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 705 | RegisterVndkLibraryTxtTypes(ctx) |
Paul Duffin | 02a3d65 | 2021-02-24 18:51:54 +0000 | [diff] [blame] | 706 | |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 707 | ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) |
Paul Duffin | 021f4e5 | 2020-07-30 16:04:17 +0100 | [diff] [blame] | 708 | android.RegisterPrebuiltMutators(ctx) |
Paul Duffin | c988c8e | 2020-04-29 18:27:14 +0100 | [diff] [blame] | 709 | RegisterRequiredBuildComponentsForTest(ctx) |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 710 | |
Colin Cross | 9a94287 | 2019-05-14 15:44:26 -0700 | [diff] [blame] | 711 | return ctx |
| 712 | } |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 713 | |
| 714 | func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool, fake bool) { |
| 715 | t.Helper() |
| 716 | mod := ctx.ModuleForTests(moduleName, variant) |
| 717 | outputFiles := mod.OutputFiles(t, "") |
| 718 | if len(outputFiles) != 1 { |
| 719 | t.Errorf("%q must have single output\n", moduleName) |
| 720 | return |
| 721 | } |
| 722 | snapshotPath := filepath.Join(subDir, snapshotFilename) |
| 723 | |
| 724 | if include { |
| 725 | out := singleton.Output(snapshotPath) |
| 726 | if fake { |
| 727 | if out.Rule == nil { |
| 728 | t.Errorf("Missing rule for module %q output file %q", moduleName, outputFiles[0]) |
| 729 | } |
| 730 | } else { |
| 731 | if out.Input.String() != outputFiles[0].String() { |
| 732 | t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0]) |
| 733 | } |
| 734 | } |
| 735 | } else { |
| 736 | out := singleton.MaybeOutput(snapshotPath) |
| 737 | if out.Rule != nil { |
| 738 | t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0]) |
| 739 | } |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | func CheckSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 744 | t.Helper() |
| 745 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, false) |
| 746 | } |
| 747 | |
| 748 | func CheckSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 749 | t.Helper() |
| 750 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false, false) |
| 751 | } |
| 752 | |
| 753 | func CheckSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 754 | t.Helper() |
| 755 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true) |
| 756 | } |
| 757 | |
Ivan Lozano | d67a6b0 | 2021-05-20 13:01:32 -0400 | [diff] [blame] | 758 | func GetOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) { |
| 759 | for _, moduleName := range moduleNames { |
| 760 | module := ctx.ModuleForTests(moduleName, variant).Module().(*Module) |
| 761 | output := module.outputFile.Path().RelativeToTop() |
| 762 | paths = append(paths, output) |
| 763 | } |
| 764 | return paths |
| 765 | } |