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