blob: 5a311f4b97ac963365f96fea8cc08f80fbc52a8a [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"
19)
20
Paul Duffin77980a82019-12-19 16:01:36 +000021func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
Paul Duffind6867912019-12-19 14:38:36 +000022 RegisterPrebuiltBuildComponents(ctx)
Paul Duffin036e7002019-12-19 19:16:28 +000023 RegisterCCBuildComponents(ctx)
Paul Duffin2ee69792020-01-16 12:14:42 +000024 RegisterBinaryBuildComponents(ctx)
Paul Duffin6c26dc72019-12-19 15:02:40 +000025 RegisterLibraryBuildComponents(ctx)
Paul Duffin1c6c1c72020-02-21 10:28:43 +000026 RegisterLibraryHeadersBuildComponents(ctx)
Paul Duffin6c26dc72019-12-19 15:02:40 +000027
28 ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
29 ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
30 ctx.RegisterModuleType("cc_object", ObjectFactory)
Martin Stjernholm7feceb22020-07-11 04:33:29 +010031 ctx.RegisterModuleType("cc_genrule", genRuleFactory)
Colin Crossf28329d2020-02-15 11:00:10 -080032 ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
33 ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
Dan Albertde5aade2020-06-30 12:32:51 -070034 ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
Paul Duffin77980a82019-12-19 16:01:36 +000035}
36
Paul Duffina04c1072020-03-02 10:16:35 +000037func GatherRequiredDepsForTest(oses ...android.OsType) string {
Inseob Kimc0907f12019-02-08 21:00:45 +090038 ret := `
39 toolchain_library {
40 name: "libatomic",
Martin Stjernholm7feceb22020-07-11 04:33:29 +010041 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +090042 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090043 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090044 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080045 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090046 src: "",
47 }
48
49 toolchain_library {
50 name: "libcompiler_rt-extras",
51 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090052 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090053 recovery_available: true,
54 src: "",
55 }
56
57 toolchain_library {
58 name: "libclang_rt.builtins-arm-android",
59 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090060 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090061 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080062 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090063 src: "",
64 }
65
66 toolchain_library {
67 name: "libclang_rt.builtins-aarch64-android",
68 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090069 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090070 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080071 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090072 src: "",
73 }
74
Jooyung Han75568392020-03-20 04:29:24 +090075 cc_prebuilt_library_shared {
76 name: "libclang_rt.hwasan-aarch64-android",
77 nocrt: true,
78 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090079 product_available: true,
Jooyung Han75568392020-03-20 04:29:24 +090080 recovery_available: true,
81 system_shared_libs: [],
82 stl: "none",
83 srcs: [""],
84 check_elf_files: false,
85 sanitize: {
86 never: true,
87 },
88 }
89
Inseob Kimc0907f12019-02-08 21:00:45 +090090 toolchain_library {
91 name: "libclang_rt.builtins-i686-android",
92 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090093 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090094 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080095 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090096 src: "",
97 }
98
99 toolchain_library {
100 name: "libclang_rt.builtins-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100101 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900102 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900103 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900104 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800105 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900106 src: "",
107 }
108
109 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700110 name: "libclang_rt.fuzzer-arm-android",
111 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900112 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700113 recovery_available: true,
114 src: "",
115 }
116
117 toolchain_library {
118 name: "libclang_rt.fuzzer-aarch64-android",
119 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900120 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700121 recovery_available: true,
122 src: "",
123 }
124
125 toolchain_library {
126 name: "libclang_rt.fuzzer-i686-android",
127 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900128 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700129 recovery_available: true,
130 src: "",
131 }
132
133 toolchain_library {
134 name: "libclang_rt.fuzzer-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100135 defaults: ["linux_bionic_supported"],
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700136 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900137 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700138 recovery_available: true,
139 src: "",
140 }
141
142 toolchain_library {
143 name: "libclang_rt.fuzzer-x86_64",
144 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900145 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700146 recovery_available: true,
147 src: "",
148 }
149
Paul Duffind6867912019-12-19 14:38:36 +0000150 // Needed for sanitizer
151 cc_prebuilt_library_shared {
152 name: "libclang_rt.ubsan_standalone-aarch64-android",
153 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900154 product_available: true,
Paul Duffind6867912019-12-19 14:38:36 +0000155 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800156 system_shared_libs: [],
Paul Duffind6867912019-12-19 14:38:36 +0000157 srcs: [""],
158 }
159
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700160 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900161 name: "libgcc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100162 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900163 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900164 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900165 recovery_available: true,
166 src: "",
167 }
168
Yi Kongacee27c2019-03-29 20:05:14 -0700169 toolchain_library {
170 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100171 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700172 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900173 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700174 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000175 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700176 src: "",
177 }
178
Inseob Kimc0907f12019-02-08 21:00:45 +0900179 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900180 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100181 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700182 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900183 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800184 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900185 system_shared_libs: [],
186 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800187 stubs: {
188 versions: ["27", "28", "29"],
189 },
Colin Cross0477b422020-10-13 18:43:54 -0700190 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900191 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900192 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700193 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900194 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000195 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900196 }
197 cc_library {
198 name: "libm",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100199 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700200 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900201 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800202 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900203 system_shared_libs: [],
204 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800205 stubs: {
206 versions: ["27", "28", "29"],
207 },
208 apex_available: [
209 "//apex_available:platform",
210 "myapex"
211 ],
Colin Cross0477b422020-10-13 18:43:54 -0700212 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900213 }
214 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700215 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900216 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000217 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900218 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400219
220 // Coverage libraries
221 cc_library {
222 name: "libprofile-extras",
223 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900224 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400225 recovery_available: true,
226 native_coverage: false,
227 system_shared_libs: [],
228 stl: "none",
229 notice: "custom_notice",
230 }
231 cc_library {
232 name: "libprofile-clang-extras",
233 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900234 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400235 recovery_available: true,
236 native_coverage: false,
237 system_shared_libs: [],
238 stl: "none",
239 notice: "custom_notice",
240 }
241 cc_library {
242 name: "libprofile-extras_ndk",
243 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900244 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400245 native_coverage: false,
246 system_shared_libs: [],
247 stl: "none",
248 notice: "custom_notice",
249 sdk_version: "current",
250 }
251 cc_library {
252 name: "libprofile-clang-extras_ndk",
253 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900254 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400255 native_coverage: false,
256 system_shared_libs: [],
257 stl: "none",
258 notice: "custom_notice",
259 sdk_version: "current",
260 }
261
Inseob Kimc0907f12019-02-08 21:00:45 +0900262 cc_library {
263 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100264 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700265 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900266 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800267 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900268 system_shared_libs: [],
269 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800270 stubs: {
271 versions: ["27", "28", "29"],
272 },
273 apex_available: [
274 "//apex_available:platform",
275 "myapex"
276 ],
Colin Cross0477b422020-10-13 18:43:54 -0700277 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900278 }
279 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700280 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900281 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000282 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900283 }
284 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900285 name: "libft2",
286 no_libcrt: true,
287 nocrt: true,
288 system_shared_libs: [],
289 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700290 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900291 }
292 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700293 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900294 symbol_file: "",
295 vendor_available: false,
Colin Crossc511bc52020-04-07 16:50:32 +0000296 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900297 }
298 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900299 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700300 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900301 nocrt: true,
302 system_shared_libs: [],
303 stl: "none",
304 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900305 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900306 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900307 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900308 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900309 apex_available: [
310 "//apex_available:platform",
311 "//apex_available:anyapex",
312 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900313 }
314 cc_library {
315 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700316 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900317 nocrt: true,
318 system_shared_libs: [],
319 stl: "none",
320 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900321 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900322 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900323 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900324 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900325 vndk: {
326 enabled: true,
327 support_system_process: true,
328 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800329 apex_available: [
330 "//apex_available:platform",
331 "myapex"
332 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900333 }
334 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700335 name: "libc++demangle",
336 no_libcrt: true,
337 nocrt: true,
338 system_shared_libs: [],
339 stl: "none",
340 host_supported: false,
341 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900342 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700343 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900344 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900345 apex_available: [
346 "//apex_available:platform",
347 "//apex_available:anyapex",
348 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700349 }
350 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900351 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700352 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900353 nocrt: true,
354 system_shared_libs: [],
355 stl: "none",
356 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900357 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900358 recovery_available: true,
359 }
360
Jiyong Park541142c2020-03-07 16:35:46 +0900361 cc_defaults {
362 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100363 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900364 recovery_available: true,
365 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900366 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900367 native_bridge_supported: true,
368 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700369 min_sdk_version: "16",
370 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900371 apex_available: [
372 "//apex_available:platform",
373 "//apex_available:anyapex",
374 ],
375 }
376
Inseob Kimc0907f12019-02-08 21:00:45 +0900377 cc_object {
378 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900379 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900380 }
381
382 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700383 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900384 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700385 }
386
387 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900388 name: "crtbegin_static",
Jiyong Park541142c2020-03-07 16:35:46 +0900389 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900390 }
391
392 cc_object {
393 name: "crtend_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900394 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900395 }
396
397 cc_object {
398 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900399 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900400 }
401
402 cc_library {
403 name: "libprotobuf-cpp-lite",
404 }
Colin Crossf28329d2020-02-15 11:00:10 -0800405
406 cc_library {
407 name: "ndk_libunwind",
408 sdk_version: "current",
409 stl: "none",
410 system_shared_libs: [],
411 }
412
Dan Albertde5aade2020-06-30 12:32:51 -0700413 ndk_library {
414 name: "libc",
415 first_version: "minimum",
416 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800417 }
418
Dan Albertde5aade2020-06-30 12:32:51 -0700419 ndk_library {
420 name: "libm",
421 first_version: "minimum",
422 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800423 }
424
Dan Albertde5aade2020-06-30 12:32:51 -0700425 ndk_library {
426 name: "libdl",
427 first_version: "minimum",
428 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800429 }
430
Colin Crossf28329d2020-02-15 11:00:10 -0800431 ndk_prebuilt_shared_stl {
432 name: "ndk_libc++_shared",
433 }
434 `
435
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100436 supportLinuxBionic := false
Paul Duffina04c1072020-03-02 10:16:35 +0000437 for _, os := range oses {
438 if os == android.Fuchsia {
439 ret += `
Inseob Kimc0907f12019-02-08 21:00:45 +0900440 cc_library {
441 name: "libbioniccompat",
442 stl: "none",
443 }
444 cc_library {
445 name: "libcompiler_rt",
446 stl: "none",
447 }
448 `
Paul Duffina04c1072020-03-02 10:16:35 +0000449 }
450 if os == android.Windows {
451 ret += `
452 toolchain_library {
453 name: "libwinpthread",
454 host_supported: true,
455 enabled: false,
456 target: {
457 windows: {
458 enabled: true,
459 },
460 },
461 src: "",
462 }
463 `
464 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100465 if os == android.LinuxBionic {
466 supportLinuxBionic = true
467 ret += `
468 cc_binary {
469 name: "linker",
470 defaults: ["linux_bionic_supported"],
471 recovery_available: true,
472 stl: "none",
473 nocrt: true,
474 static_executable: true,
475 native_coverage: false,
476 system_shared_libs: [],
477 }
478
479 cc_genrule {
480 name: "host_bionic_linker_flags",
481 host_supported: true,
482 device_supported: false,
483 target: {
484 host: {
485 enabled: false,
486 },
487 linux_bionic: {
488 enabled: true,
489 },
490 },
491 out: ["linker.flags"],
492 }
493
494 cc_defaults {
495 name: "linux_bionic_supported",
496 host_supported: true,
497 target: {
498 host: {
499 enabled: false,
500 },
501 linux_bionic: {
502 enabled: true,
503 },
504 },
505 }
506 `
507 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900508 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100509
510 if !supportLinuxBionic {
511 ret += `
512 cc_defaults {
513 name: "linux_bionic_supported",
514 }
515 `
516 }
517
Inseob Kimc0907f12019-02-08 21:00:45 +0900518 return ret
519}
Colin Cross9a942872019-05-14 15:44:26 -0700520
Colin Crossf28329d2020-02-15 11:00:10 -0800521func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800522}
523
Colin Cross98be1bb2019-12-13 20:41:13 -0800524func TestConfig(buildDir string, os android.OsType, env map[string]string,
525 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700526
Colin Cross98be1bb2019-12-13 20:41:13 -0800527 // add some modules that are required by the compiler and/or linker
528 bp = bp + GatherRequiredDepsForTest(os)
529
Colin Cross2fce23a2020-06-07 17:02:48 -0700530 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800531
Colin Crossf28329d2020-02-15 11:00:10 -0800532 GatherRequiredFilesForTest(mockFS)
533
Colin Cross98be1bb2019-12-13 20:41:13 -0800534 for k, v := range fs {
535 mockFS[k] = v
536 }
537
538 var config android.Config
539 if os == android.Fuchsia {
540 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
541 } else {
542 config = android.TestArchConfig(buildDir, env, bp, mockFS)
543 }
544
545 return config
546}
547
Colin Crossae8600b2020-10-29 17:09:13 -0700548func CreateTestContext(config android.Config) *android.TestContext {
549 ctx := android.NewTestArchContext(config)
Colin Cross4b49b762019-11-22 15:25:03 -0800550 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800551 ctx.RegisterModuleType("cc_test", TestFactory)
Chris Parsons79d66a52020-06-05 17:26:16 -0400552 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800553 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
554 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800555 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
556 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
557 ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900558 ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
Inseob Kimc42f2f22020-07-29 20:32:10 +0900559 ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900560 ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
Colin Crosse1bb5d02019-09-24 14:55:04 -0700561 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Paul Duffin021f4e52020-07-30 16:04:17 +0100562 android.RegisterPrebuiltMutators(ctx)
Paul Duffinc988c8e2020-04-29 18:27:14 +0100563 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -0800564 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Inseob Kim8471cda2019-11-15 09:59:12 +0900565 ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
Colin Cross9a942872019-05-14 15:44:26 -0700566
Colin Cross9a942872019-05-14 15:44:26 -0700567 return ctx
568}