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