blob: 3a5bd1762a369093bff25bbf03b98b24af95b394 [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,
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,
Justin Yun63e9ec72020-10-29 16:49:43 +090055 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090056 recovery_available: true,
57 src: "",
58 }
59
60 toolchain_library {
61 name: "libclang_rt.builtins-arm-android",
62 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090063 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090064 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080065 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090066 src: "",
67 }
68
69 toolchain_library {
70 name: "libclang_rt.builtins-aarch64-android",
71 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090072 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090073 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080074 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090075 src: "",
76 }
77
Jooyung Han75568392020-03-20 04:29:24 +090078 cc_prebuilt_library_shared {
79 name: "libclang_rt.hwasan-aarch64-android",
80 nocrt: true,
81 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090082 product_available: true,
Jooyung Han75568392020-03-20 04:29:24 +090083 recovery_available: true,
84 system_shared_libs: [],
85 stl: "none",
86 srcs: [""],
87 check_elf_files: false,
88 sanitize: {
89 never: true,
90 },
91 }
92
Inseob Kimc0907f12019-02-08 21:00:45 +090093 toolchain_library {
94 name: "libclang_rt.builtins-i686-android",
95 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090096 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090097 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080098 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090099 src: "",
100 }
101
102 toolchain_library {
103 name: "libclang_rt.builtins-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100104 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900105 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900106 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900107 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800108 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900109 src: "",
110 }
111
112 toolchain_library {
Ryan Prichardb35a85e2021-01-13 19:18:53 -0800113 name: "libunwind",
114 defaults: ["linux_bionic_supported"],
115 vendor_available: true,
116 product_available: true,
117 recovery_available: true,
118 native_bridge_supported: true,
119 src: "",
120 }
121
122 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700123 name: "libclang_rt.fuzzer-arm-android",
124 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900125 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700126 recovery_available: true,
127 src: "",
128 }
129
130 toolchain_library {
131 name: "libclang_rt.fuzzer-aarch64-android",
132 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900133 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700134 recovery_available: true,
135 src: "",
136 }
137
138 toolchain_library {
139 name: "libclang_rt.fuzzer-i686-android",
140 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900141 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700142 recovery_available: true,
143 src: "",
144 }
145
146 toolchain_library {
147 name: "libclang_rt.fuzzer-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100148 defaults: ["linux_bionic_supported"],
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700149 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900150 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700151 recovery_available: true,
152 src: "",
153 }
154
155 toolchain_library {
156 name: "libclang_rt.fuzzer-x86_64",
157 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900158 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700159 recovery_available: true,
160 src: "",
161 }
162
Paul Duffind6867912019-12-19 14:38:36 +0000163 // Needed for sanitizer
164 cc_prebuilt_library_shared {
165 name: "libclang_rt.ubsan_standalone-aarch64-android",
166 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900167 product_available: true,
Paul Duffind6867912019-12-19 14:38:36 +0000168 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800169 system_shared_libs: [],
Paul Duffind6867912019-12-19 14:38:36 +0000170 srcs: [""],
171 }
172
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700173 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900174 name: "libgcc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100175 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900176 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900177 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900178 recovery_available: true,
179 src: "",
Jiyong Park99644e92020-11-17 22:21:02 +0900180 apex_available: [
181 "//apex_available:platform",
182 "//apex_available:anyapex",
183 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900184 }
185
Yi Kongacee27c2019-03-29 20:05:14 -0700186 toolchain_library {
187 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100188 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700189 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900190 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700191 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000192 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700193 src: "",
194 }
195
Inseob Kimc0907f12019-02-08 21:00:45 +0900196 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900197 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100198 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700199 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900200 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800201 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900202 system_shared_libs: [],
203 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800204 stubs: {
205 versions: ["27", "28", "29"],
206 },
Colin Cross0477b422020-10-13 18:43:54 -0700207 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900208 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900209 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700210 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900211 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000212 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900213 }
214 cc_library {
215 name: "libm",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100216 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700217 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900218 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800219 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900220 system_shared_libs: [],
221 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800222 stubs: {
223 versions: ["27", "28", "29"],
224 },
225 apex_available: [
226 "//apex_available:platform",
227 "myapex"
228 ],
Colin Cross0477b422020-10-13 18:43:54 -0700229 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900230 }
231 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700232 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900233 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000234 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900235 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400236
237 // Coverage libraries
238 cc_library {
239 name: "libprofile-extras",
240 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900241 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400242 recovery_available: true,
243 native_coverage: false,
244 system_shared_libs: [],
245 stl: "none",
246 notice: "custom_notice",
247 }
248 cc_library {
249 name: "libprofile-clang-extras",
250 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900251 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400252 recovery_available: true,
253 native_coverage: false,
254 system_shared_libs: [],
255 stl: "none",
256 notice: "custom_notice",
257 }
258 cc_library {
259 name: "libprofile-extras_ndk",
260 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900261 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400262 native_coverage: false,
263 system_shared_libs: [],
264 stl: "none",
265 notice: "custom_notice",
266 sdk_version: "current",
267 }
268 cc_library {
269 name: "libprofile-clang-extras_ndk",
270 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900271 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400272 native_coverage: false,
273 system_shared_libs: [],
274 stl: "none",
275 notice: "custom_notice",
276 sdk_version: "current",
277 }
278
Inseob Kimc0907f12019-02-08 21:00:45 +0900279 cc_library {
280 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100281 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700282 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900283 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800284 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900285 system_shared_libs: [],
286 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800287 stubs: {
288 versions: ["27", "28", "29"],
289 },
290 apex_available: [
291 "//apex_available:platform",
292 "myapex"
293 ],
Colin Cross0477b422020-10-13 18:43:54 -0700294 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900295 }
296 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700297 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900298 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000299 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900300 }
301 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900302 name: "libft2",
303 no_libcrt: true,
304 nocrt: true,
305 system_shared_libs: [],
306 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700307 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900308 }
309 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700310 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900311 symbol_file: "",
Justin Yunc0d8c492021-01-07 17:45:31 +0900312 private: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000313 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900314 }
315 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900316 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700317 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900318 nocrt: true,
319 system_shared_libs: [],
320 stl: "none",
321 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900322 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900323 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900324 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900325 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900326 apex_available: [
327 "//apex_available:platform",
328 "//apex_available:anyapex",
329 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900330 }
331 cc_library {
332 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700333 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900334 nocrt: true,
335 system_shared_libs: [],
336 stl: "none",
337 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900338 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900339 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900340 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900341 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900342 vndk: {
343 enabled: true,
344 support_system_process: true,
345 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800346 apex_available: [
347 "//apex_available:platform",
Ivan Lozano3e9f9e42020-12-04 15:05:43 -0500348 "//apex_available:anyapex",
Colin Crossf9aabd72020-02-15 11:29:50 -0800349 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900350 }
351 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700352 name: "libc++demangle",
353 no_libcrt: true,
354 nocrt: true,
355 system_shared_libs: [],
356 stl: "none",
357 host_supported: false,
358 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900359 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700360 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900361 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900362 apex_available: [
363 "//apex_available:platform",
364 "//apex_available:anyapex",
365 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700366 }
367 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900368 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700369 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900370 nocrt: true,
371 system_shared_libs: [],
372 stl: "none",
373 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900374 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900375 recovery_available: true,
376 }
377
Jiyong Park541142c2020-03-07 16:35:46 +0900378 cc_defaults {
379 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100380 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900381 recovery_available: true,
382 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900383 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900384 native_bridge_supported: true,
385 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700386 min_sdk_version: "16",
387 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900388 apex_available: [
389 "//apex_available:platform",
390 "//apex_available:anyapex",
391 ],
392 }
393
Inseob Kimc0907f12019-02-08 21:00:45 +0900394 cc_object {
395 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900396 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900397 }
398
399 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700400 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900401 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700402 }
403
404 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900405 name: "crtbegin_static",
Jiyong Park541142c2020-03-07 16:35:46 +0900406 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900407 }
408
409 cc_object {
410 name: "crtend_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900411 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900412 }
413
414 cc_object {
415 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900416 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900417 }
418
419 cc_library {
420 name: "libprotobuf-cpp-lite",
421 }
Colin Crossf28329d2020-02-15 11:00:10 -0800422
423 cc_library {
424 name: "ndk_libunwind",
425 sdk_version: "current",
426 stl: "none",
427 system_shared_libs: [],
428 }
429
Dan Albertde5aade2020-06-30 12:32:51 -0700430 ndk_library {
431 name: "libc",
432 first_version: "minimum",
433 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800434 }
435
Dan Albertde5aade2020-06-30 12:32:51 -0700436 ndk_library {
437 name: "libm",
438 first_version: "minimum",
439 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800440 }
441
Dan Albertde5aade2020-06-30 12:32:51 -0700442 ndk_library {
443 name: "libdl",
444 first_version: "minimum",
445 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800446 }
447
Colin Crossf28329d2020-02-15 11:00:10 -0800448 ndk_prebuilt_shared_stl {
449 name: "ndk_libc++_shared",
450 }
Jiyong Park46a512f2020-12-04 18:02:13 +0900451
452 cc_library_static {
453 name: "libgoogle-benchmark",
454 sdk_version: "current",
455 stl: "none",
456 system_shared_libs: [],
457 }
Evgenii Stepanov193ac2e2020-04-28 15:09:12 -0700458
459 cc_library_static {
460 name: "note_memtag_heap_async",
461 }
462
463 cc_library_static {
464 name: "note_memtag_heap_sync",
465 }
Colin Crossf28329d2020-02-15 11:00:10 -0800466 `
467
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100468 supportLinuxBionic := false
Paul Duffina04c1072020-03-02 10:16:35 +0000469 for _, os := range oses {
470 if os == android.Fuchsia {
471 ret += `
Inseob Kimc0907f12019-02-08 21:00:45 +0900472 cc_library {
473 name: "libbioniccompat",
474 stl: "none",
475 }
476 cc_library {
477 name: "libcompiler_rt",
478 stl: "none",
479 }
480 `
Paul Duffina04c1072020-03-02 10:16:35 +0000481 }
482 if os == android.Windows {
483 ret += `
484 toolchain_library {
485 name: "libwinpthread",
486 host_supported: true,
487 enabled: false,
488 target: {
489 windows: {
490 enabled: true,
491 },
492 },
493 src: "",
494 }
495 `
496 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100497 if os == android.LinuxBionic {
498 supportLinuxBionic = true
499 ret += `
500 cc_binary {
501 name: "linker",
502 defaults: ["linux_bionic_supported"],
503 recovery_available: true,
504 stl: "none",
505 nocrt: true,
506 static_executable: true,
507 native_coverage: false,
508 system_shared_libs: [],
509 }
510
511 cc_genrule {
512 name: "host_bionic_linker_flags",
513 host_supported: true,
514 device_supported: false,
515 target: {
516 host: {
517 enabled: false,
518 },
519 linux_bionic: {
520 enabled: true,
521 },
522 },
523 out: ["linker.flags"],
524 }
525
526 cc_defaults {
527 name: "linux_bionic_supported",
528 host_supported: true,
529 target: {
530 host: {
531 enabled: false,
532 },
533 linux_bionic: {
534 enabled: true,
535 },
536 },
537 }
538 `
539 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900540 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100541
542 if !supportLinuxBionic {
543 ret += `
544 cc_defaults {
545 name: "linux_bionic_supported",
546 }
547 `
548 }
549
Inseob Kimc0907f12019-02-08 21:00:45 +0900550 return ret
551}
Colin Cross9a942872019-05-14 15:44:26 -0700552
Colin Crossf28329d2020-02-15 11:00:10 -0800553func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800554}
555
Colin Cross98be1bb2019-12-13 20:41:13 -0800556func TestConfig(buildDir string, os android.OsType, env map[string]string,
557 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700558
Colin Cross98be1bb2019-12-13 20:41:13 -0800559 // add some modules that are required by the compiler and/or linker
560 bp = bp + GatherRequiredDepsForTest(os)
561
Colin Cross2fce23a2020-06-07 17:02:48 -0700562 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800563
Colin Crossf28329d2020-02-15 11:00:10 -0800564 GatherRequiredFilesForTest(mockFS)
565
Colin Cross98be1bb2019-12-13 20:41:13 -0800566 for k, v := range fs {
567 mockFS[k] = v
568 }
569
570 var config android.Config
571 if os == android.Fuchsia {
572 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
573 } else {
574 config = android.TestArchConfig(buildDir, env, bp, mockFS)
575 }
576
577 return config
578}
579
Colin Crossae8600b2020-10-29 17:09:13 -0700580func CreateTestContext(config android.Config) *android.TestContext {
581 ctx := android.NewTestArchContext(config)
Colin Cross4b49b762019-11-22 15:25:03 -0800582 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800583 ctx.RegisterModuleType("cc_test", TestFactory)
Chris Parsons79d66a52020-06-05 17:26:16 -0400584 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800585 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
586 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800587 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
588 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
Colin Crosse0edaf92021-01-11 17:31:17 -0800589 vendorSnapshotImageSingleton.init(ctx)
590 recoverySnapshotImageSingleton.init(ctx)
Colin Crosse4e44bc2020-12-28 13:50:21 -0800591 RegisterVndkLibraryTxtTypes(ctx)
Colin Crosse1bb5d02019-09-24 14:55:04 -0700592 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Paul Duffin021f4e52020-07-30 16:04:17 +0100593 android.RegisterPrebuiltMutators(ctx)
Paul Duffinc988c8e2020-04-29 18:27:14 +0100594 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -0800595 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Colin Cross9a942872019-05-14 15:44:26 -0700596
Colin Cross9a942872019-05-14 15:44:26 -0700597 return ctx
598}