blob: f62c5f11496f2c8f2bd2b2f3e58a1ee2e1d11045 [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 {
Inseob Kimc0907f12019-02-08 21:00:45 +090040 ret := `
41 toolchain_library {
42 name: "libatomic",
Martin Stjernholm7feceb22020-07-11 04:33:29 +010043 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +090044 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050045 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090046 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090047 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080048 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090049 src: "",
50 }
51
52 toolchain_library {
53 name: "libcompiler_rt-extras",
54 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050055 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090056 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090057 recovery_available: true,
58 src: "",
59 }
60
61 toolchain_library {
62 name: "libclang_rt.builtins-arm-android",
63 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050064 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090065 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090066 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080067 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090068 src: "",
69 }
70
71 toolchain_library {
72 name: "libclang_rt.builtins-aarch64-android",
73 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050074 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090075 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090076 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080077 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090078 src: "",
79 }
80
Jooyung Han75568392020-03-20 04:29:24 +090081 cc_prebuilt_library_shared {
82 name: "libclang_rt.hwasan-aarch64-android",
83 nocrt: true,
84 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090085 product_available: true,
Jooyung Han75568392020-03-20 04:29:24 +090086 recovery_available: true,
87 system_shared_libs: [],
88 stl: "none",
89 srcs: [""],
90 check_elf_files: false,
91 sanitize: {
92 never: true,
93 },
94 }
95
Inseob Kimc0907f12019-02-08 21:00:45 +090096 toolchain_library {
97 name: "libclang_rt.builtins-i686-android",
98 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -050099 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900100 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900101 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800102 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900103 src: "",
104 }
105
106 toolchain_library {
107 name: "libclang_rt.builtins-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100108 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900109 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500110 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900111 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900112 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800113 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900114 src: "",
115 }
116
117 toolchain_library {
Ryan Prichardb35a85e2021-01-13 19:18:53 -0800118 name: "libunwind",
119 defaults: ["linux_bionic_supported"],
120 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500121 vendor_ramdisk_available: true,
Ryan Prichardb35a85e2021-01-13 19:18:53 -0800122 product_available: true,
123 recovery_available: true,
124 native_bridge_supported: true,
125 src: "",
126 }
127
128 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700129 name: "libclang_rt.fuzzer-arm-android",
130 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900131 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700132 recovery_available: true,
133 src: "",
134 }
135
136 toolchain_library {
137 name: "libclang_rt.fuzzer-aarch64-android",
138 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900139 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700140 recovery_available: true,
141 src: "",
142 }
143
144 toolchain_library {
145 name: "libclang_rt.fuzzer-i686-android",
146 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900147 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700148 recovery_available: true,
149 src: "",
150 }
151
152 toolchain_library {
153 name: "libclang_rt.fuzzer-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100154 defaults: ["linux_bionic_supported"],
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700155 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900156 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700157 recovery_available: true,
158 src: "",
159 }
160
161 toolchain_library {
162 name: "libclang_rt.fuzzer-x86_64",
163 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900164 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700165 recovery_available: true,
166 src: "",
167 }
168
Paul Duffind6867912019-12-19 14:38:36 +0000169 // Needed for sanitizer
170 cc_prebuilt_library_shared {
171 name: "libclang_rt.ubsan_standalone-aarch64-android",
172 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900173 product_available: true,
Paul Duffind6867912019-12-19 14:38:36 +0000174 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800175 system_shared_libs: [],
Paul Duffind6867912019-12-19 14:38:36 +0000176 srcs: [""],
177 }
178
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700179 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900180 name: "libgcc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100181 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900182 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900183 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900184 recovery_available: true,
185 src: "",
Jiyong Park99644e92020-11-17 22:21:02 +0900186 apex_available: [
187 "//apex_available:platform",
188 "//apex_available:anyapex",
189 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900190 }
191
Yi Kongacee27c2019-03-29 20:05:14 -0700192 toolchain_library {
193 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100194 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700195 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900196 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700197 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000198 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700199 src: "",
200 }
201
Inseob Kimc0907f12019-02-08 21:00:45 +0900202 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900203 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100204 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700205 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900206 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800207 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900208 system_shared_libs: [],
209 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800210 stubs: {
211 versions: ["27", "28", "29"],
212 },
Colin Cross0477b422020-10-13 18:43:54 -0700213 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900214 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900215 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700216 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900217 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000218 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900219 }
220 cc_library {
221 name: "libm",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100222 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700223 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900224 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800225 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900226 system_shared_libs: [],
227 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800228 stubs: {
229 versions: ["27", "28", "29"],
230 },
231 apex_available: [
232 "//apex_available:platform",
233 "myapex"
234 ],
Colin Cross0477b422020-10-13 18:43:54 -0700235 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900236 }
237 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700238 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900239 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000240 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900241 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400242
243 // Coverage libraries
244 cc_library {
245 name: "libprofile-extras",
246 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500247 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900248 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400249 recovery_available: true,
250 native_coverage: false,
251 system_shared_libs: [],
252 stl: "none",
253 notice: "custom_notice",
254 }
255 cc_library {
256 name: "libprofile-clang-extras",
257 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500258 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900259 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400260 recovery_available: true,
261 native_coverage: false,
262 system_shared_libs: [],
263 stl: "none",
264 notice: "custom_notice",
265 }
266 cc_library {
267 name: "libprofile-extras_ndk",
268 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900269 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400270 native_coverage: false,
271 system_shared_libs: [],
272 stl: "none",
273 notice: "custom_notice",
274 sdk_version: "current",
275 }
276 cc_library {
277 name: "libprofile-clang-extras_ndk",
278 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900279 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400280 native_coverage: false,
281 system_shared_libs: [],
282 stl: "none",
283 notice: "custom_notice",
284 sdk_version: "current",
285 }
286
Inseob Kimc0907f12019-02-08 21:00:45 +0900287 cc_library {
288 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100289 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700290 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900291 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800292 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900293 system_shared_libs: [],
294 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800295 stubs: {
296 versions: ["27", "28", "29"],
297 },
298 apex_available: [
299 "//apex_available:platform",
300 "myapex"
301 ],
Colin Cross0477b422020-10-13 18:43:54 -0700302 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900303 }
304 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700305 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900306 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000307 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900308 }
309 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900310 name: "libft2",
311 no_libcrt: true,
312 nocrt: true,
313 system_shared_libs: [],
314 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700315 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900316 }
317 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700318 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900319 symbol_file: "",
Justin Yunc0d8c492021-01-07 17:45:31 +0900320 private: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000321 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900322 }
323 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900324 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700325 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900326 nocrt: true,
327 system_shared_libs: [],
328 stl: "none",
329 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500330 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900331 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900332 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900333 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900334 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900335 apex_available: [
336 "//apex_available:platform",
337 "//apex_available:anyapex",
338 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900339 }
340 cc_library {
341 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700342 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900343 nocrt: true,
344 system_shared_libs: [],
345 stl: "none",
346 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900347 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900348 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900349 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900350 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900351 vndk: {
352 enabled: true,
353 support_system_process: true,
354 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800355 apex_available: [
356 "//apex_available:platform",
Ivan Lozano3e9f9e42020-12-04 15:05:43 -0500357 "//apex_available:anyapex",
Colin Crossf9aabd72020-02-15 11:29:50 -0800358 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900359 }
360 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700361 name: "libc++demangle",
362 no_libcrt: true,
363 nocrt: true,
364 system_shared_libs: [],
365 stl: "none",
366 host_supported: false,
367 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500368 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900369 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700370 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900371 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900372 apex_available: [
373 "//apex_available:platform",
374 "//apex_available:anyapex",
375 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700376 }
377 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900378 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700379 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900380 nocrt: true,
381 system_shared_libs: [],
382 stl: "none",
383 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900384 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900385 recovery_available: true,
386 }
387
Jiyong Park541142c2020-03-07 16:35:46 +0900388 cc_defaults {
389 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100390 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900391 recovery_available: true,
392 vendor_available: true,
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500393 vendor_ramdisk_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900394 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900395 native_bridge_supported: true,
396 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700397 min_sdk_version: "16",
398 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900399 apex_available: [
400 "//apex_available:platform",
401 "//apex_available:anyapex",
402 ],
403 }
404
Inseob Kimc0907f12019-02-08 21:00:45 +0900405 cc_object {
406 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900407 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900408 }
409
410 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700411 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900412 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700413 }
414
415 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900416 name: "crtbegin_static",
Jiyong Park541142c2020-03-07 16:35:46 +0900417 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900418 }
419
420 cc_object {
421 name: "crtend_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900422 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900423 }
424
425 cc_object {
426 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900427 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900428 }
429
430 cc_library {
431 name: "libprotobuf-cpp-lite",
432 }
Colin Crossf28329d2020-02-15 11:00:10 -0800433
434 cc_library {
435 name: "ndk_libunwind",
436 sdk_version: "current",
437 stl: "none",
438 system_shared_libs: [],
439 }
440
Dan Albertde5aade2020-06-30 12:32:51 -0700441 ndk_library {
442 name: "libc",
443 first_version: "minimum",
444 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800445 }
446
Dan Albertde5aade2020-06-30 12:32:51 -0700447 ndk_library {
448 name: "libm",
449 first_version: "minimum",
450 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800451 }
452
Dan Albertde5aade2020-06-30 12:32:51 -0700453 ndk_library {
454 name: "libdl",
455 first_version: "minimum",
456 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800457 }
458
Colin Crossf28329d2020-02-15 11:00:10 -0800459 ndk_prebuilt_shared_stl {
460 name: "ndk_libc++_shared",
461 }
Jiyong Park46a512f2020-12-04 18:02:13 +0900462
463 cc_library_static {
464 name: "libgoogle-benchmark",
465 sdk_version: "current",
466 stl: "none",
467 system_shared_libs: [],
468 }
Evgenii Stepanov193ac2e2020-04-28 15:09:12 -0700469
470 cc_library_static {
471 name: "note_memtag_heap_async",
472 }
473
474 cc_library_static {
475 name: "note_memtag_heap_sync",
476 }
Colin Crossf28329d2020-02-15 11:00:10 -0800477 `
478
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100479 supportLinuxBionic := false
Paul Duffina04c1072020-03-02 10:16:35 +0000480 for _, os := range oses {
481 if os == android.Fuchsia {
482 ret += `
Inseob Kimc0907f12019-02-08 21:00:45 +0900483 cc_library {
484 name: "libbioniccompat",
485 stl: "none",
486 }
487 cc_library {
488 name: "libcompiler_rt",
489 stl: "none",
490 }
491 `
Paul Duffina04c1072020-03-02 10:16:35 +0000492 }
493 if os == android.Windows {
494 ret += `
495 toolchain_library {
496 name: "libwinpthread",
497 host_supported: true,
498 enabled: false,
499 target: {
500 windows: {
501 enabled: true,
502 },
503 },
504 src: "",
505 }
506 `
507 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100508 if os == android.LinuxBionic {
509 supportLinuxBionic = true
510 ret += `
511 cc_binary {
512 name: "linker",
513 defaults: ["linux_bionic_supported"],
514 recovery_available: true,
515 stl: "none",
516 nocrt: true,
517 static_executable: true,
518 native_coverage: false,
519 system_shared_libs: [],
520 }
521
522 cc_genrule {
523 name: "host_bionic_linker_flags",
524 host_supported: true,
525 device_supported: false,
526 target: {
527 host: {
528 enabled: false,
529 },
530 linux_bionic: {
531 enabled: true,
532 },
533 },
534 out: ["linker.flags"],
535 }
536
537 cc_defaults {
538 name: "linux_bionic_supported",
539 host_supported: true,
540 target: {
541 host: {
542 enabled: false,
543 },
544 linux_bionic: {
545 enabled: true,
546 },
547 },
548 }
549 `
550 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900551 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100552
553 if !supportLinuxBionic {
554 ret += `
555 cc_defaults {
556 name: "linux_bionic_supported",
557 }
558 `
559 }
560
Inseob Kimc0907f12019-02-08 21:00:45 +0900561 return ret
562}
Colin Cross9a942872019-05-14 15:44:26 -0700563
Colin Crossf28329d2020-02-15 11:00:10 -0800564func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800565}
566
Colin Cross98be1bb2019-12-13 20:41:13 -0800567func TestConfig(buildDir string, os android.OsType, env map[string]string,
568 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700569
Colin Cross98be1bb2019-12-13 20:41:13 -0800570 // add some modules that are required by the compiler and/or linker
571 bp = bp + GatherRequiredDepsForTest(os)
572
Colin Cross2fce23a2020-06-07 17:02:48 -0700573 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800574
Colin Crossf28329d2020-02-15 11:00:10 -0800575 GatherRequiredFilesForTest(mockFS)
576
Colin Cross98be1bb2019-12-13 20:41:13 -0800577 for k, v := range fs {
578 mockFS[k] = v
579 }
580
581 var config android.Config
582 if os == android.Fuchsia {
583 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
584 } else {
585 config = android.TestArchConfig(buildDir, env, bp, mockFS)
586 }
587
588 return config
589}
590
Colin Crossae8600b2020-10-29 17:09:13 -0700591func CreateTestContext(config android.Config) *android.TestContext {
592 ctx := android.NewTestArchContext(config)
Paul Duffind6ceb862021-03-04 23:02:31 +0000593 genrule.RegisterGenruleBuildComponents(ctx)
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}