blob: 198764bfc5d25b8cba69e727b54640e65252f437 [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: "",
169 }
170
Yi Kongacee27c2019-03-29 20:05:14 -0700171 toolchain_library {
172 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100173 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700174 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900175 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700176 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000177 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700178 src: "",
179 }
180
Inseob Kimc0907f12019-02-08 21:00:45 +0900181 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900182 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100183 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700184 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900185 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800186 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900187 system_shared_libs: [],
188 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800189 stubs: {
190 versions: ["27", "28", "29"],
191 },
Colin Cross0477b422020-10-13 18:43:54 -0700192 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900193 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900194 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700195 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900196 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000197 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900198 }
199 cc_library {
200 name: "libm",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100201 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700202 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900203 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800204 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900205 system_shared_libs: [],
206 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800207 stubs: {
208 versions: ["27", "28", "29"],
209 },
210 apex_available: [
211 "//apex_available:platform",
212 "myapex"
213 ],
Colin Cross0477b422020-10-13 18:43:54 -0700214 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900215 }
216 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700217 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900218 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000219 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900220 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400221
222 // Coverage libraries
223 cc_library {
224 name: "libprofile-extras",
225 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900226 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400227 recovery_available: true,
228 native_coverage: false,
229 system_shared_libs: [],
230 stl: "none",
231 notice: "custom_notice",
232 }
233 cc_library {
234 name: "libprofile-clang-extras",
235 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900236 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400237 recovery_available: true,
238 native_coverage: false,
239 system_shared_libs: [],
240 stl: "none",
241 notice: "custom_notice",
242 }
243 cc_library {
244 name: "libprofile-extras_ndk",
245 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900246 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400247 native_coverage: false,
248 system_shared_libs: [],
249 stl: "none",
250 notice: "custom_notice",
251 sdk_version: "current",
252 }
253 cc_library {
254 name: "libprofile-clang-extras_ndk",
255 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900256 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400257 native_coverage: false,
258 system_shared_libs: [],
259 stl: "none",
260 notice: "custom_notice",
261 sdk_version: "current",
262 }
263
Inseob Kimc0907f12019-02-08 21:00:45 +0900264 cc_library {
265 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100266 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700267 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900268 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800269 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900270 system_shared_libs: [],
271 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800272 stubs: {
273 versions: ["27", "28", "29"],
274 },
275 apex_available: [
276 "//apex_available:platform",
277 "myapex"
278 ],
Colin Cross0477b422020-10-13 18:43:54 -0700279 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900280 }
281 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700282 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900283 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000284 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900285 }
286 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900287 name: "libft2",
288 no_libcrt: true,
289 nocrt: true,
290 system_shared_libs: [],
291 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700292 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900293 }
294 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700295 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900296 symbol_file: "",
297 vendor_available: false,
Colin Crossc511bc52020-04-07 16:50:32 +0000298 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900299 }
300 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900301 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700302 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900303 nocrt: true,
304 system_shared_libs: [],
305 stl: "none",
306 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900307 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900308 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900309 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900310 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900311 apex_available: [
312 "//apex_available:platform",
313 "//apex_available:anyapex",
314 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900315 }
316 cc_library {
317 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700318 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900319 nocrt: true,
320 system_shared_libs: [],
321 stl: "none",
322 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900323 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900324 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900325 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900326 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900327 vndk: {
328 enabled: true,
329 support_system_process: true,
330 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800331 apex_available: [
332 "//apex_available:platform",
333 "myapex"
334 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900335 }
336 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700337 name: "libc++demangle",
338 no_libcrt: true,
339 nocrt: true,
340 system_shared_libs: [],
341 stl: "none",
342 host_supported: false,
343 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900344 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700345 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900346 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900347 apex_available: [
348 "//apex_available:platform",
349 "//apex_available:anyapex",
350 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700351 }
352 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900353 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700354 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900355 nocrt: true,
356 system_shared_libs: [],
357 stl: "none",
358 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900359 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900360 recovery_available: true,
361 }
362
Jiyong Park541142c2020-03-07 16:35:46 +0900363 cc_defaults {
364 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100365 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900366 recovery_available: true,
367 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900368 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900369 native_bridge_supported: true,
370 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700371 min_sdk_version: "16",
372 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900373 apex_available: [
374 "//apex_available:platform",
375 "//apex_available:anyapex",
376 ],
377 }
378
Inseob Kimc0907f12019-02-08 21:00:45 +0900379 cc_object {
380 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900381 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900382 }
383
384 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700385 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900386 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700387 }
388
389 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900390 name: "crtbegin_static",
Jiyong Park541142c2020-03-07 16:35:46 +0900391 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900392 }
393
394 cc_object {
395 name: "crtend_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900396 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900397 }
398
399 cc_object {
400 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900401 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900402 }
403
404 cc_library {
405 name: "libprotobuf-cpp-lite",
406 }
Colin Crossf28329d2020-02-15 11:00:10 -0800407
408 cc_library {
409 name: "ndk_libunwind",
410 sdk_version: "current",
411 stl: "none",
412 system_shared_libs: [],
413 }
414
Dan Albertde5aade2020-06-30 12:32:51 -0700415 ndk_library {
416 name: "libc",
417 first_version: "minimum",
418 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800419 }
420
Dan Albertde5aade2020-06-30 12:32:51 -0700421 ndk_library {
422 name: "libm",
423 first_version: "minimum",
424 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800425 }
426
Dan Albertde5aade2020-06-30 12:32:51 -0700427 ndk_library {
428 name: "libdl",
429 first_version: "minimum",
430 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800431 }
432
Colin Crossf28329d2020-02-15 11:00:10 -0800433 ndk_prebuilt_shared_stl {
434 name: "ndk_libc++_shared",
435 }
436 `
437
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100438 supportLinuxBionic := false
Paul Duffina04c1072020-03-02 10:16:35 +0000439 for _, os := range oses {
440 if os == android.Fuchsia {
441 ret += `
Inseob Kimc0907f12019-02-08 21:00:45 +0900442 cc_library {
443 name: "libbioniccompat",
444 stl: "none",
445 }
446 cc_library {
447 name: "libcompiler_rt",
448 stl: "none",
449 }
450 `
Paul Duffina04c1072020-03-02 10:16:35 +0000451 }
452 if os == android.Windows {
453 ret += `
454 toolchain_library {
455 name: "libwinpthread",
456 host_supported: true,
457 enabled: false,
458 target: {
459 windows: {
460 enabled: true,
461 },
462 },
463 src: "",
464 }
465 `
466 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100467 if os == android.LinuxBionic {
468 supportLinuxBionic = true
469 ret += `
470 cc_binary {
471 name: "linker",
472 defaults: ["linux_bionic_supported"],
473 recovery_available: true,
474 stl: "none",
475 nocrt: true,
476 static_executable: true,
477 native_coverage: false,
478 system_shared_libs: [],
479 }
480
481 cc_genrule {
482 name: "host_bionic_linker_flags",
483 host_supported: true,
484 device_supported: false,
485 target: {
486 host: {
487 enabled: false,
488 },
489 linux_bionic: {
490 enabled: true,
491 },
492 },
493 out: ["linker.flags"],
494 }
495
496 cc_defaults {
497 name: "linux_bionic_supported",
498 host_supported: true,
499 target: {
500 host: {
501 enabled: false,
502 },
503 linux_bionic: {
504 enabled: true,
505 },
506 },
507 }
508 `
509 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900510 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100511
512 if !supportLinuxBionic {
513 ret += `
514 cc_defaults {
515 name: "linux_bionic_supported",
516 }
517 `
518 }
519
Inseob Kimc0907f12019-02-08 21:00:45 +0900520 return ret
521}
Colin Cross9a942872019-05-14 15:44:26 -0700522
Colin Crossf28329d2020-02-15 11:00:10 -0800523func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800524}
525
Colin Cross98be1bb2019-12-13 20:41:13 -0800526func TestConfig(buildDir string, os android.OsType, env map[string]string,
527 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700528
Colin Cross98be1bb2019-12-13 20:41:13 -0800529 // add some modules that are required by the compiler and/or linker
530 bp = bp + GatherRequiredDepsForTest(os)
531
Colin Cross2fce23a2020-06-07 17:02:48 -0700532 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800533
Colin Crossf28329d2020-02-15 11:00:10 -0800534 GatherRequiredFilesForTest(mockFS)
535
Colin Cross98be1bb2019-12-13 20:41:13 -0800536 for k, v := range fs {
537 mockFS[k] = v
538 }
539
540 var config android.Config
541 if os == android.Fuchsia {
542 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
543 } else {
544 config = android.TestArchConfig(buildDir, env, bp, mockFS)
545 }
546
547 return config
548}
549
Colin Crossae8600b2020-10-29 17:09:13 -0700550func CreateTestContext(config android.Config) *android.TestContext {
551 ctx := android.NewTestArchContext(config)
Colin Cross4b49b762019-11-22 15:25:03 -0800552 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800553 ctx.RegisterModuleType("cc_test", TestFactory)
Chris Parsons79d66a52020-06-05 17:26:16 -0400554 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800555 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
556 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800557 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
558 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
559 ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900560 ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
Inseob Kimc42f2f22020-07-29 20:32:10 +0900561 ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900562 ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
Colin Crosse1bb5d02019-09-24 14:55:04 -0700563 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Paul Duffin021f4e52020-07-30 16:04:17 +0100564 android.RegisterPrebuiltMutators(ctx)
Paul Duffinc988c8e2020-04-29 18:27:14 +0100565 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -0800566 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Inseob Kim8471cda2019-11-15 09:59:12 +0900567 ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
Jose Galmesf7294582020-11-13 12:07:36 -0800568 ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
Colin Cross9a942872019-05-14 15:44:26 -0700569
Colin Cross9a942872019-05-14 15:44:26 -0700570 return ctx
571}