blob: 3764fad99c2dd1540990b6e6a2df33e49cd730ca [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)
32 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,
Justin Yun63e9ec72020-10-29 16:49:43 +090045 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090046 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080047 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090048 src: "",
49 }
50
51 toolchain_library {
52 name: "libcompiler_rt-extras",
53 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090054 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090055 recovery_available: true,
56 src: "",
57 }
58
59 toolchain_library {
60 name: "libclang_rt.builtins-arm-android",
61 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090062 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090063 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080064 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090065 src: "",
66 }
67
68 toolchain_library {
69 name: "libclang_rt.builtins-aarch64-android",
70 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090071 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090072 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080073 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090074 src: "",
75 }
76
Jooyung Han75568392020-03-20 04:29:24 +090077 cc_prebuilt_library_shared {
78 name: "libclang_rt.hwasan-aarch64-android",
79 nocrt: true,
80 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090081 product_available: true,
Jooyung Han75568392020-03-20 04:29:24 +090082 recovery_available: true,
83 system_shared_libs: [],
84 stl: "none",
85 srcs: [""],
86 check_elf_files: false,
87 sanitize: {
88 never: true,
89 },
90 }
91
Inseob Kimc0907f12019-02-08 21:00:45 +090092 toolchain_library {
93 name: "libclang_rt.builtins-i686-android",
94 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090095 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090096 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -080097 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +090098 src: "",
99 }
100
101 toolchain_library {
102 name: "libclang_rt.builtins-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100103 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900104 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900105 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900106 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800107 native_bridge_supported: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900108 src: "",
109 }
110
111 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700112 name: "libclang_rt.fuzzer-arm-android",
113 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900114 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700115 recovery_available: true,
116 src: "",
117 }
118
119 toolchain_library {
120 name: "libclang_rt.fuzzer-aarch64-android",
121 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900122 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700123 recovery_available: true,
124 src: "",
125 }
126
127 toolchain_library {
128 name: "libclang_rt.fuzzer-i686-android",
129 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900130 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700131 recovery_available: true,
132 src: "",
133 }
134
135 toolchain_library {
136 name: "libclang_rt.fuzzer-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100137 defaults: ["linux_bionic_supported"],
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700138 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-x86_64",
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
Paul Duffind6867912019-12-19 14:38:36 +0000152 // Needed for sanitizer
153 cc_prebuilt_library_shared {
154 name: "libclang_rt.ubsan_standalone-aarch64-android",
155 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900156 product_available: true,
Paul Duffind6867912019-12-19 14:38:36 +0000157 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800158 system_shared_libs: [],
Paul Duffind6867912019-12-19 14:38:36 +0000159 srcs: [""],
160 }
161
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700162 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900163 name: "libgcc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100164 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900165 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900166 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900167 recovery_available: true,
168 src: "",
Jiyong Park99644e92020-11-17 22:21:02 +0900169 apex_available: [
170 "//apex_available:platform",
171 "//apex_available:anyapex",
172 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900173 }
174
Yi Kongacee27c2019-03-29 20:05:14 -0700175 toolchain_library {
176 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100177 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700178 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900179 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700180 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000181 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700182 src: "",
183 }
184
Inseob Kimc0907f12019-02-08 21:00:45 +0900185 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900186 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100187 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700188 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900189 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800190 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900191 system_shared_libs: [],
192 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800193 stubs: {
194 versions: ["27", "28", "29"],
195 },
Colin Cross0477b422020-10-13 18:43:54 -0700196 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900197 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900198 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700199 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900200 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000201 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900202 }
203 cc_library {
204 name: "libm",
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 },
214 apex_available: [
215 "//apex_available:platform",
216 "myapex"
217 ],
Colin Cross0477b422020-10-13 18:43:54 -0700218 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900219 }
220 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700221 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900222 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000223 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900224 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400225
226 // Coverage libraries
227 cc_library {
228 name: "libprofile-extras",
229 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900230 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400231 recovery_available: true,
232 native_coverage: false,
233 system_shared_libs: [],
234 stl: "none",
235 notice: "custom_notice",
236 }
237 cc_library {
238 name: "libprofile-clang-extras",
239 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900240 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400241 recovery_available: true,
242 native_coverage: false,
243 system_shared_libs: [],
244 stl: "none",
245 notice: "custom_notice",
246 }
247 cc_library {
248 name: "libprofile-extras_ndk",
249 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900250 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400251 native_coverage: false,
252 system_shared_libs: [],
253 stl: "none",
254 notice: "custom_notice",
255 sdk_version: "current",
256 }
257 cc_library {
258 name: "libprofile-clang-extras_ndk",
259 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900260 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400261 native_coverage: false,
262 system_shared_libs: [],
263 stl: "none",
264 notice: "custom_notice",
265 sdk_version: "current",
266 }
267
Inseob Kimc0907f12019-02-08 21:00:45 +0900268 cc_library {
269 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100270 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700271 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900272 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800273 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900274 system_shared_libs: [],
275 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800276 stubs: {
277 versions: ["27", "28", "29"],
278 },
279 apex_available: [
280 "//apex_available:platform",
281 "myapex"
282 ],
Colin Cross0477b422020-10-13 18:43:54 -0700283 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900284 }
285 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700286 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900287 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000288 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900289 }
290 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900291 name: "libft2",
292 no_libcrt: true,
293 nocrt: true,
294 system_shared_libs: [],
295 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700296 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900297 }
298 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700299 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900300 symbol_file: "",
301 vendor_available: false,
Colin Crossc511bc52020-04-07 16:50:32 +0000302 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900303 }
304 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900305 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700306 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900307 nocrt: true,
308 system_shared_libs: [],
309 stl: "none",
310 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900311 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900312 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900313 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900314 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900315 apex_available: [
316 "//apex_available:platform",
317 "//apex_available:anyapex",
318 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900319 }
320 cc_library {
321 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700322 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900323 nocrt: true,
324 system_shared_libs: [],
325 stl: "none",
326 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900327 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900328 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900329 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900330 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900331 vndk: {
332 enabled: true,
333 support_system_process: true,
334 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800335 apex_available: [
336 "//apex_available:platform",
Ivan Lozano3e9f9e42020-12-04 15:05:43 -0500337 "//apex_available:anyapex",
Colin Crossf9aabd72020-02-15 11:29:50 -0800338 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900339 }
340 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700341 name: "libc++demangle",
342 no_libcrt: true,
343 nocrt: true,
344 system_shared_libs: [],
345 stl: "none",
346 host_supported: false,
347 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900348 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700349 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900350 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900351 apex_available: [
352 "//apex_available:platform",
353 "//apex_available:anyapex",
354 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700355 }
356 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900357 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700358 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900359 nocrt: true,
360 system_shared_libs: [],
361 stl: "none",
362 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900363 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900364 recovery_available: true,
365 }
366
Jiyong Park541142c2020-03-07 16:35:46 +0900367 cc_defaults {
368 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100369 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900370 recovery_available: true,
371 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900372 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900373 native_bridge_supported: true,
374 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700375 min_sdk_version: "16",
376 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900377 apex_available: [
378 "//apex_available:platform",
379 "//apex_available:anyapex",
380 ],
381 }
382
Inseob Kimc0907f12019-02-08 21:00:45 +0900383 cc_object {
384 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900385 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900386 }
387
388 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700389 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900390 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700391 }
392
393 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900394 name: "crtbegin_static",
Jiyong Park541142c2020-03-07 16:35:46 +0900395 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900396 }
397
398 cc_object {
399 name: "crtend_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900400 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900401 }
402
403 cc_object {
404 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900405 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900406 }
407
408 cc_library {
409 name: "libprotobuf-cpp-lite",
410 }
Colin Crossf28329d2020-02-15 11:00:10 -0800411
412 cc_library {
413 name: "ndk_libunwind",
414 sdk_version: "current",
415 stl: "none",
416 system_shared_libs: [],
417 }
418
Dan Albertde5aade2020-06-30 12:32:51 -0700419 ndk_library {
420 name: "libc",
421 first_version: "minimum",
422 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800423 }
424
Dan Albertde5aade2020-06-30 12:32:51 -0700425 ndk_library {
426 name: "libm",
427 first_version: "minimum",
428 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800429 }
430
Dan Albertde5aade2020-06-30 12:32:51 -0700431 ndk_library {
432 name: "libdl",
433 first_version: "minimum",
434 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800435 }
436
Colin Crossf28329d2020-02-15 11:00:10 -0800437 ndk_prebuilt_shared_stl {
438 name: "ndk_libc++_shared",
439 }
440 `
441
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100442 supportLinuxBionic := false
Paul Duffina04c1072020-03-02 10:16:35 +0000443 for _, os := range oses {
444 if os == android.Fuchsia {
445 ret += `
Inseob Kimc0907f12019-02-08 21:00:45 +0900446 cc_library {
447 name: "libbioniccompat",
448 stl: "none",
449 }
450 cc_library {
451 name: "libcompiler_rt",
452 stl: "none",
453 }
454 `
Paul Duffina04c1072020-03-02 10:16:35 +0000455 }
456 if os == android.Windows {
457 ret += `
458 toolchain_library {
459 name: "libwinpthread",
460 host_supported: true,
461 enabled: false,
462 target: {
463 windows: {
464 enabled: true,
465 },
466 },
467 src: "",
468 }
469 `
470 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100471 if os == android.LinuxBionic {
472 supportLinuxBionic = true
473 ret += `
474 cc_binary {
475 name: "linker",
476 defaults: ["linux_bionic_supported"],
477 recovery_available: true,
478 stl: "none",
479 nocrt: true,
480 static_executable: true,
481 native_coverage: false,
482 system_shared_libs: [],
483 }
484
485 cc_genrule {
486 name: "host_bionic_linker_flags",
487 host_supported: true,
488 device_supported: false,
489 target: {
490 host: {
491 enabled: false,
492 },
493 linux_bionic: {
494 enabled: true,
495 },
496 },
497 out: ["linker.flags"],
498 }
499
500 cc_defaults {
501 name: "linux_bionic_supported",
502 host_supported: true,
503 target: {
504 host: {
505 enabled: false,
506 },
507 linux_bionic: {
508 enabled: true,
509 },
510 },
511 }
512 `
513 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900514 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100515
516 if !supportLinuxBionic {
517 ret += `
518 cc_defaults {
519 name: "linux_bionic_supported",
520 }
521 `
522 }
523
Inseob Kimc0907f12019-02-08 21:00:45 +0900524 return ret
525}
Colin Cross9a942872019-05-14 15:44:26 -0700526
Colin Crossf28329d2020-02-15 11:00:10 -0800527func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800528}
529
Colin Cross98be1bb2019-12-13 20:41:13 -0800530func TestConfig(buildDir string, os android.OsType, env map[string]string,
531 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700532
Colin Cross98be1bb2019-12-13 20:41:13 -0800533 // add some modules that are required by the compiler and/or linker
534 bp = bp + GatherRequiredDepsForTest(os)
535
Colin Cross2fce23a2020-06-07 17:02:48 -0700536 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800537
Colin Crossf28329d2020-02-15 11:00:10 -0800538 GatherRequiredFilesForTest(mockFS)
539
Colin Cross98be1bb2019-12-13 20:41:13 -0800540 for k, v := range fs {
541 mockFS[k] = v
542 }
543
544 var config android.Config
545 if os == android.Fuchsia {
546 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
547 } else {
548 config = android.TestArchConfig(buildDir, env, bp, mockFS)
549 }
550
551 return config
552}
553
Colin Crossae8600b2020-10-29 17:09:13 -0700554func CreateTestContext(config android.Config) *android.TestContext {
555 ctx := android.NewTestArchContext(config)
Colin Cross4b49b762019-11-22 15:25:03 -0800556 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800557 ctx.RegisterModuleType("cc_test", TestFactory)
Chris Parsons79d66a52020-06-05 17:26:16 -0400558 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800559 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
560 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800561 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
562 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
563 ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900564 ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
Inseob Kimc42f2f22020-07-29 20:32:10 +0900565 ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900566 ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
Colin Crosse1bb5d02019-09-24 14:55:04 -0700567 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Paul Duffin021f4e52020-07-30 16:04:17 +0100568 android.RegisterPrebuiltMutators(ctx)
Paul Duffinc988c8e2020-04-29 18:27:14 +0100569 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -0800570 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Inseob Kim8471cda2019-11-15 09:59:12 +0900571 ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
Jose Galmesf7294582020-11-13 12:07:36 -0800572 ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
Colin Cross9a942872019-05-14 15:44:26 -0700573
Colin Cross9a942872019-05-14 15:44:26 -0700574 return ctx
575}