blob: fcd124e11a9baa3a01f3429ec1dba5fafb3b4f6d [file] [log] [blame]
Inseob Kimc0907f12019-02-08 21:00:45 +09001// 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
15package cc
16
17import (
18 "android/soong/android"
Colin Crosse9fe2942020-11-10 18:12:15 -080019 "android/soong/genrule"
Inseob Kimc0907f12019-02-08 21:00:45 +090020)
21
Paul Duffin77980a82019-12-19 16:01:36 +000022func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
Paul Duffind6867912019-12-19 14:38:36 +000023 RegisterPrebuiltBuildComponents(ctx)
Paul Duffin036e7002019-12-19 19:16:28 +000024 RegisterCCBuildComponents(ctx)
Paul Duffin2ee69792020-01-16 12:14:42 +000025 RegisterBinaryBuildComponents(ctx)
Paul Duffin6c26dc72019-12-19 15:02:40 +000026 RegisterLibraryBuildComponents(ctx)
Paul Duffin1c6c1c72020-02-21 10:28:43 +000027 RegisterLibraryHeadersBuildComponents(ctx)
Paul Duffin6c26dc72019-12-19 15:02:40 +000028
29 ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
30 ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
Jiyong Park46a512f2020-12-04 18:02:13 +090031 ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory)
Paul Duffin6c26dc72019-12-19 15:02:40 +000032 ctx.RegisterModuleType("cc_object", ObjectFactory)
Martin Stjernholm7feceb22020-07-11 04:33:29 +010033 ctx.RegisterModuleType("cc_genrule", genRuleFactory)
Colin Crossf28329d2020-02-15 11:00:10 -080034 ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
35 ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
Dan Albertde5aade2020-06-30 12:32:51 -070036 ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
Paul Duffin77980a82019-12-19 16:01:36 +000037}
38
Paul Duffina04c1072020-03-02 10:16:35 +000039func GatherRequiredDepsForTest(oses ...android.OsType) string {
Paul Duffin02a3d652021-02-24 18:51:54 +000040 ret := commonDefaultModules()
41
42 supportLinuxBionic := false
43 for _, os := range oses {
44 if os == android.Fuchsia {
45 ret += withFuchsiaModules()
46 }
47 if os == android.Windows {
48 ret += withWindowsModules()
49 }
50 if os == android.LinuxBionic {
51 supportLinuxBionic = true
52 ret += withLinuxBionic()
53 }
54 }
55
56 if !supportLinuxBionic {
57 ret += withoutLinuxBionic()
58 }
59
60 return ret
61}
62
63func commonDefaultModules() string {
64 return `
Inseob Kimc0907f12019-02-08 21:00:45 +090065 toolchain_library {
66 name: "libatomic",
Martin Stjernholm7feceb22020-07-11 04:33:29 +010067 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +090068 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050069 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090070 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090071 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080072 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090073 src: "",
74 }
75
76 toolchain_library {
77 name: "libcompiler_rt-extras",
78 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050079 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090080 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090081 recovery_available: true,
82 src: "",
83 }
84
85 toolchain_library {
86 name: "libclang_rt.builtins-arm-android",
87 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050088 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090089 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090090 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080091 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090092 src: "",
93 }
94
95 toolchain_library {
96 name: "libclang_rt.builtins-aarch64-android",
97 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050098 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090099 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900100 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800101 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900102 src: "",
103 }
104
Jooyung Han75568392020-03-20 04:29:24 +0900105 cc_prebuilt_library_shared {
106 name: "libclang_rt.hwasan-aarch64-android",
107 nocrt: true,
108 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900109 product_available: true,
Jooyung Han75568392020-03-20 04:29:24 +0900110 recovery_available: true,
111 system_shared_libs: [],
112 stl: "none",
113 srcs: [""],
114 check_elf_files: false,
115 sanitize: {
116 never: true,
117 },
118 }
119
Inseob Kimc0907f12019-02-08 21:00:45 +0900120 toolchain_library {
121 name: "libclang_rt.builtins-i686-android",
122 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500123 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900124 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900125 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800126 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900127 src: "",
128 }
129
130 toolchain_library {
131 name: "libclang_rt.builtins-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100132 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900133 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500134 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900135 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900136 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800137 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900138 src: "",
139 }
140
141 toolchain_library {
Ryan Prichardb35a85e2021-01-13 19:18:53 -0800142 name: "libunwind",
143 defaults: ["linux_bionic_supported"],
144 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500145 vendor_ramdisk_available: true,
Ryan Prichardb35a85e2021-01-13 19:18:53 -0800146 product_available: true,
147 recovery_available: true,
148 native_bridge_supported: true,
149 src: "",
150 }
151
152 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700153 name: "libclang_rt.fuzzer-arm-android",
154 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900155 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700156 recovery_available: true,
157 src: "",
158 }
159
160 toolchain_library {
161 name: "libclang_rt.fuzzer-aarch64-android",
162 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900163 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700164 recovery_available: true,
165 src: "",
166 }
167
168 toolchain_library {
169 name: "libclang_rt.fuzzer-i686-android",
170 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900171 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700172 recovery_available: true,
173 src: "",
174 }
175
176 toolchain_library {
177 name: "libclang_rt.fuzzer-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100178 defaults: ["linux_bionic_supported"],
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700179 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900180 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700181 recovery_available: true,
182 src: "",
183 }
184
185 toolchain_library {
186 name: "libclang_rt.fuzzer-x86_64",
187 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900188 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700189 recovery_available: true,
190 src: "",
191 }
192
Paul Duffind6867912019-12-19 14:38:36 +0000193 // Needed for sanitizer
194 cc_prebuilt_library_shared {
195 name: "libclang_rt.ubsan_standalone-aarch64-android",
196 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900197 product_available: true,
Paul Duffind6867912019-12-19 14:38:36 +0000198 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800199 system_shared_libs: [],
Paul Duffind6867912019-12-19 14:38:36 +0000200 srcs: [""],
201 }
202
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700203 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900204 name: "libgcc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100205 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900206 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900207 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900208 recovery_available: true,
209 src: "",
Jiyong Park99644e92020-11-17 22:21:02 +0900210 apex_available: [
211 "//apex_available:platform",
212 "//apex_available:anyapex",
213 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900214 }
215
Yi Kongacee27c2019-03-29 20:05:14 -0700216 toolchain_library {
217 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100218 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700219 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900220 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700221 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000222 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700223 src: "",
224 }
225
Inseob Kimc0907f12019-02-08 21:00:45 +0900226 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900227 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100228 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700229 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900230 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800231 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900232 system_shared_libs: [],
233 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800234 stubs: {
235 versions: ["27", "28", "29"],
236 },
Colin Cross0477b422020-10-13 18:43:54 -0700237 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900238 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900239 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700240 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900241 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000242 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900243 }
244 cc_library {
245 name: "libm",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100246 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700247 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900248 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800249 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900250 system_shared_libs: [],
251 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800252 stubs: {
253 versions: ["27", "28", "29"],
254 },
255 apex_available: [
256 "//apex_available:platform",
257 "myapex"
258 ],
Colin Cross0477b422020-10-13 18:43:54 -0700259 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900260 }
261 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700262 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900263 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000264 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900265 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400266
267 // Coverage libraries
268 cc_library {
269 name: "libprofile-extras",
270 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500271 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900272 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400273 recovery_available: true,
274 native_coverage: false,
275 system_shared_libs: [],
276 stl: "none",
277 notice: "custom_notice",
278 }
279 cc_library {
280 name: "libprofile-clang-extras",
281 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500282 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900283 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400284 recovery_available: true,
285 native_coverage: false,
286 system_shared_libs: [],
287 stl: "none",
288 notice: "custom_notice",
289 }
290 cc_library {
291 name: "libprofile-extras_ndk",
292 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900293 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400294 native_coverage: false,
295 system_shared_libs: [],
296 stl: "none",
297 notice: "custom_notice",
298 sdk_version: "current",
299 }
300 cc_library {
301 name: "libprofile-clang-extras_ndk",
302 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900303 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400304 native_coverage: false,
305 system_shared_libs: [],
306 stl: "none",
307 notice: "custom_notice",
308 sdk_version: "current",
309 }
310
Inseob Kimc0907f12019-02-08 21:00:45 +0900311 cc_library {
312 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100313 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700314 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900315 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800316 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900317 system_shared_libs: [],
318 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800319 stubs: {
320 versions: ["27", "28", "29"],
321 },
322 apex_available: [
323 "//apex_available:platform",
324 "myapex"
325 ],
Colin Cross0477b422020-10-13 18:43:54 -0700326 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900327 }
328 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700329 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900330 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000331 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900332 }
333 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900334 name: "libft2",
335 no_libcrt: true,
336 nocrt: true,
337 system_shared_libs: [],
338 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700339 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900340 }
341 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700342 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900343 symbol_file: "",
Justin Yunc0d8c492021-01-07 17:45:31 +0900344 private: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000345 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900346 }
347 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900348 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700349 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900350 nocrt: true,
351 system_shared_libs: [],
352 stl: "none",
353 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500354 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900355 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900356 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900357 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900358 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900359 apex_available: [
360 "//apex_available:platform",
361 "//apex_available:anyapex",
362 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900363 }
364 cc_library {
365 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700366 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900367 nocrt: true,
368 system_shared_libs: [],
369 stl: "none",
370 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900371 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900372 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900373 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900374 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900375 vndk: {
376 enabled: true,
377 support_system_process: true,
378 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800379 apex_available: [
380 "//apex_available:platform",
Ivan Lozano3e9f9e42020-12-04 15:05:43 -0500381 "//apex_available:anyapex",
Colin Crossf9aabd72020-02-15 11:29:50 -0800382 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900383 }
384 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700385 name: "libc++demangle",
386 no_libcrt: true,
387 nocrt: true,
388 system_shared_libs: [],
389 stl: "none",
390 host_supported: false,
391 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500392 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900393 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700394 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900395 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900396 apex_available: [
397 "//apex_available:platform",
398 "//apex_available:anyapex",
399 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700400 }
401 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900402 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700403 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900404 nocrt: true,
405 system_shared_libs: [],
406 stl: "none",
407 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900408 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900409 recovery_available: true,
410 }
411
Jiyong Park541142c2020-03-07 16:35:46 +0900412 cc_defaults {
413 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100414 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900415 recovery_available: true,
416 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500417 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900418 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900419 native_bridge_supported: true,
420 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700421 min_sdk_version: "16",
422 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900423 apex_available: [
424 "//apex_available:platform",
425 "//apex_available:anyapex",
426 ],
427 }
428
Inseob Kimc0907f12019-02-08 21:00:45 +0900429 cc_object {
430 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900431 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900432 }
433
434 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700435 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900436 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700437 }
438
439 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900440 name: "crtbegin_static",
Jiyong Park541142c2020-03-07 16:35:46 +0900441 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900442 }
443
444 cc_object {
445 name: "crtend_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900446 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900447 }
448
449 cc_object {
450 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900451 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900452 }
453
454 cc_library {
455 name: "libprotobuf-cpp-lite",
456 }
Colin Crossf28329d2020-02-15 11:00:10 -0800457
458 cc_library {
459 name: "ndk_libunwind",
460 sdk_version: "current",
461 stl: "none",
462 system_shared_libs: [],
463 }
464
Dan Albertde5aade2020-06-30 12:32:51 -0700465 ndk_library {
466 name: "libc",
467 first_version: "minimum",
468 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800469 }
470
Dan Albertde5aade2020-06-30 12:32:51 -0700471 ndk_library {
472 name: "libm",
473 first_version: "minimum",
474 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800475 }
476
Dan Albertde5aade2020-06-30 12:32:51 -0700477 ndk_library {
478 name: "libdl",
479 first_version: "minimum",
480 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800481 }
482
Colin Crossf28329d2020-02-15 11:00:10 -0800483 ndk_prebuilt_shared_stl {
484 name: "ndk_libc++_shared",
485 }
Jiyong Park46a512f2020-12-04 18:02:13 +0900486
487 cc_library_static {
488 name: "libgoogle-benchmark",
489 sdk_version: "current",
490 stl: "none",
491 system_shared_libs: [],
492 }
Evgenii Stepanov193ac2e2020-04-28 15:09:12 -0700493
494 cc_library_static {
495 name: "note_memtag_heap_async",
496 }
497
498 cc_library_static {
499 name: "note_memtag_heap_sync",
500 }
Colin Crossf28329d2020-02-15 11:00:10 -0800501 `
Paul Duffin02a3d652021-02-24 18:51:54 +0000502}
Colin Crossf28329d2020-02-15 11:00:10 -0800503
Paul Duffin02a3d652021-02-24 18:51:54 +0000504func withWindowsModules() string {
505 return `
Paul Duffina04c1072020-03-02 10:16:35 +0000506 toolchain_library {
507 name: "libwinpthread",
508 host_supported: true,
509 enabled: false,
510 target: {
511 windows: {
512 enabled: true,
513 },
514 },
515 src: "",
516 }
517 `
Paul Duffin02a3d652021-02-24 18:51:54 +0000518}
519
520func withFuchsiaModules() string {
521 return `
522 cc_library {
523 name: "libbioniccompat",
524 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000525 }
Paul Duffin02a3d652021-02-24 18:51:54 +0000526 cc_library {
527 name: "libcompiler_rt",
528 stl: "none",
529 }
530 `
531}
532
533func withLinuxBionic() string {
534 return `
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100535 cc_binary {
536 name: "linker",
537 defaults: ["linux_bionic_supported"],
538 recovery_available: true,
539 stl: "none",
540 nocrt: true,
541 static_executable: true,
542 native_coverage: false,
543 system_shared_libs: [],
544 }
545
546 cc_genrule {
547 name: "host_bionic_linker_flags",
548 host_supported: true,
549 device_supported: false,
550 target: {
551 host: {
552 enabled: false,
553 },
554 linux_bionic: {
555 enabled: true,
556 },
557 },
558 out: ["linker.flags"],
559 }
560
561 cc_defaults {
562 name: "linux_bionic_supported",
563 host_supported: true,
564 target: {
565 host: {
566 enabled: false,
567 },
568 linux_bionic: {
569 enabled: true,
570 },
571 },
572 }
573 `
Paul Duffin02a3d652021-02-24 18:51:54 +0000574}
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100575
Paul Duffin02a3d652021-02-24 18:51:54 +0000576func withoutLinuxBionic() string {
577 return `
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100578 cc_defaults {
579 name: "linux_bionic_supported",
580 }
581 `
Inseob Kimc0907f12019-02-08 21:00:45 +0900582}
Colin Cross9a942872019-05-14 15:44:26 -0700583
Colin Crossf28329d2020-02-15 11:00:10 -0800584func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800585}
586
Paul Duffin02a3d652021-02-24 18:51:54 +0000587// The directory in which cc linux bionic default modules will be defined.
588//
589// Placing them here ensures that their location does not conflict with default test modules
590// defined by other packages.
591const linuxBionicDefaultsPath = "defaults/cc/linux-bionic/Android.bp"
592
593// The directory in which the default cc common test modules will be defined.
594//
595// Placing them here ensures that their location does not conflict with default test modules
596// defined by other packages.
597const DefaultCcCommonTestModulesDir = "defaults/cc/common/"
598
599// Test fixture preparer that will register most cc build components.
600//
601// Singletons and mutators should only be added here if they are needed for a majority of cc
602// module types, otherwise they should be added under a separate preparer to allow them to be
603// selected only when needed to reduce test execution time.
604//
605// Module types do not have much of an overhead unless they are used so this should include as many
606// module types as possible. The exceptions are those module types that require mutators and/or
607// singletons in order to function in which case they should be kept together in a separate
608// preparer.
609var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers(
610 android.PrepareForTestWithAndroidBuildComponents,
611 android.FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest),
612 android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
613 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
614 ctx.RegisterModuleType("cc_test", TestFactory)
615 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
616 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
617 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
618 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
619
620 RegisterVndkLibraryTxtTypes(ctx)
621 }),
622)
623
624// Preparer that will define default cc modules, e.g. standard prebuilt modules.
625var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
626 PrepareForTestWithCcBuildComponents,
627 // Place the default cc test modules that are common to all platforms in a location that will not
628 // conflict with default test modules defined by other packages.
629 android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()),
630 // Disable linux bionic by default.
631 android.FixtureAddTextFile(linuxBionicDefaultsPath, withoutLinuxBionic()),
632)
633
634// Prepare a fixture to use all cc module types, mutators and singletons fully.
635//
636// This should only be used by tests that want to run with as much of the build enabled as possible.
637var PrepareForIntegrationTestWithCc = android.GroupFixturePreparers(
638 android.PrepareForIntegrationTestWithAndroid,
639 genrule.PrepareForIntegrationTestWithGenrule,
640 PrepareForTestWithCcDefaultModules,
641)
642
643// The preparer to include if running a cc related test for windows.
644var PrepareForTestOnWindows = android.GroupFixturePreparers(
645 // Place the default cc test modules for windows platforms in a location that will not conflict
646 // with default test modules defined by other packages.
647 android.FixtureAddTextFile("defaults/cc/windows/Android.bp", withWindowsModules()),
648)
649
650// The preparer to include if running a cc related test for linux bionic.
651var PrepareForTestOnLinuxBionic = android.GroupFixturePreparers(
652 // Enable linux bionic.
653 android.FixtureAddTextFile(linuxBionicDefaultsPath, withLinuxBionic()),
654)
655
656// This adds some additional modules and singletons which might negatively impact the performance
657// of tests so they are not included in the PrepareForIntegrationTestWithCc.
658var PrepareForTestWithCcIncludeVndk = android.GroupFixturePreparers(
659 PrepareForIntegrationTestWithCc,
660 android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
661 vendorSnapshotImageSingleton.init(ctx)
662 recoverySnapshotImageSingleton.init(ctx)
663 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
664 }),
665)
666
667// TestConfig is the legacy way of creating a test Config for testing cc modules.
668//
669// See testCc for an explanation as to how to stop using this deprecated method.
670//
671// deprecated
Colin Cross98be1bb2019-12-13 20:41:13 -0800672func TestConfig(buildDir string, os android.OsType, env map[string]string,
673 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700674
Colin Cross98be1bb2019-12-13 20:41:13 -0800675 // add some modules that are required by the compiler and/or linker
676 bp = bp + GatherRequiredDepsForTest(os)
677
Colin Cross2fce23a2020-06-07 17:02:48 -0700678 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800679
Colin Crossf28329d2020-02-15 11:00:10 -0800680 GatherRequiredFilesForTest(mockFS)
681
Colin Cross98be1bb2019-12-13 20:41:13 -0800682 for k, v := range fs {
683 mockFS[k] = v
684 }
685
686 var config android.Config
687 if os == android.Fuchsia {
688 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
689 } else {
690 config = android.TestArchConfig(buildDir, env, bp, mockFS)
691 }
692
693 return config
694}
695
Paul Duffin02a3d652021-02-24 18:51:54 +0000696// CreateTestContext is the legacy way of creating a TestContext for testing cc modules.
697//
698// See testCc for an explanation as to how to stop using this deprecated method.
699//
700// deprecated
Colin Crossae8600b2020-10-29 17:09:13 -0700701func CreateTestContext(config android.Config) *android.TestContext {
702 ctx := android.NewTestArchContext(config)
Paul Duffind6ceb862021-03-04 23:02:31 +0000703 genrule.RegisterGenruleBuildComponents(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -0800704 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800705 ctx.RegisterModuleType("cc_test", TestFactory)
Chris Parsons79d66a52020-06-05 17:26:16 -0400706 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800707 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
708 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800709 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
710 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
Paul Duffin02a3d652021-02-24 18:51:54 +0000711
Colin Crosse0edaf92021-01-11 17:31:17 -0800712 vendorSnapshotImageSingleton.init(ctx)
713 recoverySnapshotImageSingleton.init(ctx)
Paul Duffin02a3d652021-02-24 18:51:54 +0000714 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Colin Crosse4e44bc2020-12-28 13:50:21 -0800715 RegisterVndkLibraryTxtTypes(ctx)
Paul Duffin02a3d652021-02-24 18:51:54 +0000716
Colin Crosse1bb5d02019-09-24 14:55:04 -0700717 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Paul Duffin021f4e52020-07-30 16:04:17 +0100718 android.RegisterPrebuiltMutators(ctx)
Paul Duffinc988c8e2020-04-29 18:27:14 +0100719 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross9a942872019-05-14 15:44:26 -0700720
Colin Cross9a942872019-05-14 15:44:26 -0700721 return ctx
722}