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