blob: 45e53120837a9322f3021dd574967718252f7e88 [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)
Colin Crosse9fe2942020-11-10 18:12:15 -080028 genrule.RegisterGenruleBuildComponents(ctx)
Paul Duffin6c26dc72019-12-19 15:02:40 +000029
30 ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
31 ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
Jiyong Park46a512f2020-12-04 18:02:13 +090032 ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory)
Paul Duffin6c26dc72019-12-19 15:02:40 +000033 ctx.RegisterModuleType("cc_object", ObjectFactory)
Martin Stjernholm7feceb22020-07-11 04:33:29 +010034 ctx.RegisterModuleType("cc_genrule", genRuleFactory)
Colin Crossf28329d2020-02-15 11:00:10 -080035 ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
36 ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
Dan Albertde5aade2020-06-30 12:32:51 -070037 ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
Paul Duffin77980a82019-12-19 16:01:36 +000038}
39
Paul Duffina04c1072020-03-02 10:16:35 +000040func GatherRequiredDepsForTest(oses ...android.OsType) string {
Inseob Kimc0907f12019-02-08 21:00:45 +090041 ret := `
42 toolchain_library {
43 name: "libatomic",
Martin Stjernholm7feceb22020-07-11 04:33:29 +010044 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +090045 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050046 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090047 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090048 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080049 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090050 src: "",
51 }
52
53 toolchain_library {
54 name: "libcompiler_rt-extras",
55 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050056 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090057 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090058 recovery_available: true,
59 src: "",
60 }
61
62 toolchain_library {
63 name: "libclang_rt.builtins-arm-android",
64 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050065 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090066 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090067 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080068 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090069 src: "",
70 }
71
72 toolchain_library {
73 name: "libclang_rt.builtins-aarch64-android",
74 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050075 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090076 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090077 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080078 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090079 src: "",
80 }
81
Jooyung Han75568392020-03-20 04:29:24 +090082 cc_prebuilt_library_shared {
83 name: "libclang_rt.hwasan-aarch64-android",
84 nocrt: true,
85 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090086 product_available: true,
Jooyung Han75568392020-03-20 04:29:24 +090087 recovery_available: true,
88 system_shared_libs: [],
89 stl: "none",
90 srcs: [""],
91 check_elf_files: false,
92 sanitize: {
93 never: true,
94 },
95 }
96
Inseob Kimc0907f12019-02-08 21:00:45 +090097 toolchain_library {
98 name: "libclang_rt.builtins-i686-android",
99 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500100 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900101 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900102 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800103 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900104 src: "",
105 }
106
107 toolchain_library {
108 name: "libclang_rt.builtins-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100109 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900110 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500111 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900112 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900113 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800114 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900115 src: "",
116 }
117
118 toolchain_library {
Ryan Prichardb35a85e2021-01-13 19:18:53 -0800119 name: "libunwind",
120 defaults: ["linux_bionic_supported"],
121 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500122 vendor_ramdisk_available: true,
Ryan Prichardb35a85e2021-01-13 19:18:53 -0800123 product_available: true,
124 recovery_available: true,
125 native_bridge_supported: true,
126 src: "",
127 }
128
129 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700130 name: "libclang_rt.fuzzer-arm-android",
131 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900132 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700133 recovery_available: true,
134 src: "",
135 }
136
137 toolchain_library {
138 name: "libclang_rt.fuzzer-aarch64-android",
139 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900140 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700141 recovery_available: true,
142 src: "",
143 }
144
145 toolchain_library {
146 name: "libclang_rt.fuzzer-i686-android",
147 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900148 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700149 recovery_available: true,
150 src: "",
151 }
152
153 toolchain_library {
154 name: "libclang_rt.fuzzer-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100155 defaults: ["linux_bionic_supported"],
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700156 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900157 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700158 recovery_available: true,
159 src: "",
160 }
161
162 toolchain_library {
163 name: "libclang_rt.fuzzer-x86_64",
164 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900165 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700166 recovery_available: true,
167 src: "",
168 }
169
Paul Duffind6867912019-12-19 14:38:36 +0000170 // Needed for sanitizer
171 cc_prebuilt_library_shared {
172 name: "libclang_rt.ubsan_standalone-aarch64-android",
173 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900174 product_available: true,
Paul Duffind6867912019-12-19 14:38:36 +0000175 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800176 system_shared_libs: [],
Paul Duffind6867912019-12-19 14:38:36 +0000177 srcs: [""],
178 }
179
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700180 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900181 name: "libgcc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100182 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900183 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900184 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900185 recovery_available: true,
186 src: "",
Jiyong Park99644e92020-11-17 22:21:02 +0900187 apex_available: [
188 "//apex_available:platform",
189 "//apex_available:anyapex",
190 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900191 }
192
Yi Kongacee27c2019-03-29 20:05:14 -0700193 toolchain_library {
194 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100195 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700196 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900197 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700198 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000199 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700200 src: "",
201 }
202
Inseob Kimc0907f12019-02-08 21:00:45 +0900203 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900204 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100205 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700206 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900207 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800208 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900209 system_shared_libs: [],
210 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800211 stubs: {
212 versions: ["27", "28", "29"],
213 },
Colin Cross0477b422020-10-13 18:43:54 -0700214 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900215 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900216 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700217 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900218 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000219 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900220 }
221 cc_library {
222 name: "libm",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100223 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700224 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900225 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800226 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900227 system_shared_libs: [],
228 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800229 stubs: {
230 versions: ["27", "28", "29"],
231 },
232 apex_available: [
233 "//apex_available:platform",
234 "myapex"
235 ],
Colin Cross0477b422020-10-13 18:43:54 -0700236 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900237 }
238 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700239 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900240 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000241 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900242 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400243
244 // Coverage libraries
245 cc_library {
246 name: "libprofile-extras",
247 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500248 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900249 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400250 recovery_available: true,
251 native_coverage: false,
252 system_shared_libs: [],
253 stl: "none",
254 notice: "custom_notice",
255 }
256 cc_library {
257 name: "libprofile-clang-extras",
258 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500259 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900260 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400261 recovery_available: true,
262 native_coverage: false,
263 system_shared_libs: [],
264 stl: "none",
265 notice: "custom_notice",
266 }
267 cc_library {
268 name: "libprofile-extras_ndk",
269 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900270 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400271 native_coverage: false,
272 system_shared_libs: [],
273 stl: "none",
274 notice: "custom_notice",
275 sdk_version: "current",
276 }
277 cc_library {
278 name: "libprofile-clang-extras_ndk",
279 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900280 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400281 native_coverage: false,
282 system_shared_libs: [],
283 stl: "none",
284 notice: "custom_notice",
285 sdk_version: "current",
286 }
287
Inseob Kimc0907f12019-02-08 21:00:45 +0900288 cc_library {
289 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100290 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700291 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900292 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800293 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900294 system_shared_libs: [],
295 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800296 stubs: {
297 versions: ["27", "28", "29"],
298 },
299 apex_available: [
300 "//apex_available:platform",
301 "myapex"
302 ],
Colin Cross0477b422020-10-13 18:43:54 -0700303 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900304 }
305 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700306 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900307 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000308 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900309 }
310 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900311 name: "libft2",
312 no_libcrt: true,
313 nocrt: true,
314 system_shared_libs: [],
315 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700316 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900317 }
318 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700319 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900320 symbol_file: "",
Justin Yunc0d8c492021-01-07 17:45:31 +0900321 private: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000322 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900323 }
324 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900325 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700326 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900327 nocrt: true,
328 system_shared_libs: [],
329 stl: "none",
330 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500331 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900332 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900333 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900334 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900335 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900336 apex_available: [
337 "//apex_available:platform",
338 "//apex_available:anyapex",
339 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900340 }
341 cc_library {
342 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700343 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900344 nocrt: true,
345 system_shared_libs: [],
346 stl: "none",
347 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900348 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900349 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900350 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900351 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900352 vndk: {
353 enabled: true,
354 support_system_process: true,
355 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800356 apex_available: [
357 "//apex_available:platform",
Ivan Lozano3e9f9e42020-12-04 15:05:43 -0500358 "//apex_available:anyapex",
Colin Crossf9aabd72020-02-15 11:29:50 -0800359 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900360 }
361 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700362 name: "libc++demangle",
363 no_libcrt: true,
364 nocrt: true,
365 system_shared_libs: [],
366 stl: "none",
367 host_supported: false,
368 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500369 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900370 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700371 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900372 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900373 apex_available: [
374 "//apex_available:platform",
375 "//apex_available:anyapex",
376 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700377 }
378 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900379 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700380 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900381 nocrt: true,
382 system_shared_libs: [],
383 stl: "none",
384 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900385 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900386 recovery_available: true,
387 }
388
Jiyong Park541142c2020-03-07 16:35:46 +0900389 cc_defaults {
390 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100391 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900392 recovery_available: true,
393 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500394 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900395 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900396 native_bridge_supported: true,
397 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700398 min_sdk_version: "16",
399 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900400 apex_available: [
401 "//apex_available:platform",
402 "//apex_available:anyapex",
403 ],
404 }
405
Inseob Kimc0907f12019-02-08 21:00:45 +0900406 cc_object {
407 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900408 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900409 }
410
411 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700412 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900413 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700414 }
415
416 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900417 name: "crtbegin_static",
Jiyong Park541142c2020-03-07 16:35:46 +0900418 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900419 }
420
421 cc_object {
422 name: "crtend_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900423 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900424 }
425
426 cc_object {
427 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900428 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900429 }
430
431 cc_library {
432 name: "libprotobuf-cpp-lite",
433 }
Colin Crossf28329d2020-02-15 11:00:10 -0800434
435 cc_library {
436 name: "ndk_libunwind",
437 sdk_version: "current",
438 stl: "none",
439 system_shared_libs: [],
440 }
441
Dan Albertde5aade2020-06-30 12:32:51 -0700442 ndk_library {
443 name: "libc",
444 first_version: "minimum",
445 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800446 }
447
Dan Albertde5aade2020-06-30 12:32:51 -0700448 ndk_library {
449 name: "libm",
450 first_version: "minimum",
451 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800452 }
453
Dan Albertde5aade2020-06-30 12:32:51 -0700454 ndk_library {
455 name: "libdl",
456 first_version: "minimum",
457 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800458 }
459
Colin Crossf28329d2020-02-15 11:00:10 -0800460 ndk_prebuilt_shared_stl {
461 name: "ndk_libc++_shared",
462 }
Jiyong Park46a512f2020-12-04 18:02:13 +0900463
464 cc_library_static {
465 name: "libgoogle-benchmark",
466 sdk_version: "current",
467 stl: "none",
468 system_shared_libs: [],
469 }
Evgenii Stepanov193ac2e2020-04-28 15:09:12 -0700470
471 cc_library_static {
472 name: "note_memtag_heap_async",
473 }
474
475 cc_library_static {
476 name: "note_memtag_heap_sync",
477 }
Colin Crossf28329d2020-02-15 11:00:10 -0800478 `
479
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100480 supportLinuxBionic := false
Paul Duffina04c1072020-03-02 10:16:35 +0000481 for _, os := range oses {
482 if os == android.Fuchsia {
483 ret += `
Inseob Kimc0907f12019-02-08 21:00:45 +0900484 cc_library {
485 name: "libbioniccompat",
486 stl: "none",
487 }
488 cc_library {
489 name: "libcompiler_rt",
490 stl: "none",
491 }
492 `
Paul Duffina04c1072020-03-02 10:16:35 +0000493 }
494 if os == android.Windows {
495 ret += `
496 toolchain_library {
497 name: "libwinpthread",
498 host_supported: true,
499 enabled: false,
500 target: {
501 windows: {
502 enabled: true,
503 },
504 },
505 src: "",
506 }
507 `
508 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100509 if os == android.LinuxBionic {
510 supportLinuxBionic = true
511 ret += `
512 cc_binary {
513 name: "linker",
514 defaults: ["linux_bionic_supported"],
515 recovery_available: true,
516 stl: "none",
517 nocrt: true,
518 static_executable: true,
519 native_coverage: false,
520 system_shared_libs: [],
521 }
522
523 cc_genrule {
524 name: "host_bionic_linker_flags",
525 host_supported: true,
526 device_supported: false,
527 target: {
528 host: {
529 enabled: false,
530 },
531 linux_bionic: {
532 enabled: true,
533 },
534 },
535 out: ["linker.flags"],
536 }
537
538 cc_defaults {
539 name: "linux_bionic_supported",
540 host_supported: true,
541 target: {
542 host: {
543 enabled: false,
544 },
545 linux_bionic: {
546 enabled: true,
547 },
548 },
549 }
550 `
551 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900552 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100553
554 if !supportLinuxBionic {
555 ret += `
556 cc_defaults {
557 name: "linux_bionic_supported",
558 }
559 `
560 }
561
Inseob Kimc0907f12019-02-08 21:00:45 +0900562 return ret
563}
Colin Cross9a942872019-05-14 15:44:26 -0700564
Colin Crossf28329d2020-02-15 11:00:10 -0800565func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800566}
567
Colin Cross98be1bb2019-12-13 20:41:13 -0800568func TestConfig(buildDir string, os android.OsType, env map[string]string,
569 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700570
Colin Cross98be1bb2019-12-13 20:41:13 -0800571 // add some modules that are required by the compiler and/or linker
572 bp = bp + GatherRequiredDepsForTest(os)
573
Colin Cross2fce23a2020-06-07 17:02:48 -0700574 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800575
Colin Crossf28329d2020-02-15 11:00:10 -0800576 GatherRequiredFilesForTest(mockFS)
577
Colin Cross98be1bb2019-12-13 20:41:13 -0800578 for k, v := range fs {
579 mockFS[k] = v
580 }
581
582 var config android.Config
583 if os == android.Fuchsia {
584 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
585 } else {
586 config = android.TestArchConfig(buildDir, env, bp, mockFS)
587 }
588
589 return config
590}
591
Colin Crossae8600b2020-10-29 17:09:13 -0700592func CreateTestContext(config android.Config) *android.TestContext {
593 ctx := android.NewTestArchContext(config)
Colin Cross4b49b762019-11-22 15:25:03 -0800594 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800595 ctx.RegisterModuleType("cc_test", TestFactory)
Chris Parsons79d66a52020-06-05 17:26:16 -0400596 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800597 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
598 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800599 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
600 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
Colin Crosse0edaf92021-01-11 17:31:17 -0800601 vendorSnapshotImageSingleton.init(ctx)
602 recoverySnapshotImageSingleton.init(ctx)
Colin Crosse4e44bc2020-12-28 13:50:21 -0800603 RegisterVndkLibraryTxtTypes(ctx)
Colin Crosse1bb5d02019-09-24 14:55:04 -0700604 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Paul Duffin021f4e52020-07-30 16:04:17 +0100605 android.RegisterPrebuiltMutators(ctx)
Paul Duffinc988c8e2020-04-29 18:27:14 +0100606 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -0800607 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Colin Cross9a942872019-05-14 15:44:26 -0700608
Colin Cross9a942872019-05-14 15:44:26 -0700609 return ctx
610}