blob: 903f76c4ad4cdb43856947b0f6a8d43ba58a705c [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 {
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700113 name: "libclang_rt.fuzzer-arm-android",
114 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900115 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700116 recovery_available: true,
117 src: "",
118 }
119
120 toolchain_library {
121 name: "libclang_rt.fuzzer-aarch64-android",
122 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900123 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700124 recovery_available: true,
125 src: "",
126 }
127
128 toolchain_library {
129 name: "libclang_rt.fuzzer-i686-android",
130 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900131 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700132 recovery_available: true,
133 src: "",
134 }
135
136 toolchain_library {
137 name: "libclang_rt.fuzzer-x86_64-android",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100138 defaults: ["linux_bionic_supported"],
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700139 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900140 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700141 recovery_available: true,
142 src: "",
143 }
144
145 toolchain_library {
146 name: "libclang_rt.fuzzer-x86_64",
147 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900148 product_available: true,
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700149 recovery_available: true,
150 src: "",
151 }
152
Paul Duffind6867912019-12-19 14:38:36 +0000153 // Needed for sanitizer
154 cc_prebuilt_library_shared {
155 name: "libclang_rt.ubsan_standalone-aarch64-android",
156 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900157 product_available: true,
Paul Duffind6867912019-12-19 14:38:36 +0000158 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800159 system_shared_libs: [],
Paul Duffind6867912019-12-19 14:38:36 +0000160 srcs: [""],
161 }
162
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700163 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900164 name: "libgcc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100165 defaults: ["linux_bionic_supported"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900166 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900167 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900168 recovery_available: true,
169 src: "",
Jiyong Park99644e92020-11-17 22:21:02 +0900170 apex_available: [
171 "//apex_available:platform",
172 "//apex_available:anyapex",
173 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900174 }
175
Yi Kongacee27c2019-03-29 20:05:14 -0700176 toolchain_library {
177 name: "libgcc_stripped",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100178 defaults: ["linux_bionic_supported"],
Yi Kongacee27c2019-03-29 20:05:14 -0700179 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900180 product_available: true,
Yi Kongacee27c2019-03-29 20:05:14 -0700181 recovery_available: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000182 sdk_version: "current",
Yi Kongacee27c2019-03-29 20:05:14 -0700183 src: "",
184 }
185
Inseob Kimc0907f12019-02-08 21:00:45 +0900186 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900187 name: "libc",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100188 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700189 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900190 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800191 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900192 system_shared_libs: [],
193 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800194 stubs: {
195 versions: ["27", "28", "29"],
196 },
Colin Cross0477b422020-10-13 18:43:54 -0700197 llndk_stubs: "libc.llndk",
Justin Yun63e9ec72020-10-29 16:49:43 +0900198 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900199 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700200 name: "libc.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900201 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000202 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900203 }
204 cc_library {
205 name: "libm",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100206 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700207 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900208 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800209 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900210 system_shared_libs: [],
211 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800212 stubs: {
213 versions: ["27", "28", "29"],
214 },
215 apex_available: [
216 "//apex_available:platform",
217 "myapex"
218 ],
Colin Cross0477b422020-10-13 18:43:54 -0700219 llndk_stubs: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900220 }
221 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700222 name: "libm.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900223 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000224 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900225 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400226
227 // Coverage libraries
228 cc_library {
229 name: "libprofile-extras",
230 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900231 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400232 recovery_available: true,
233 native_coverage: false,
234 system_shared_libs: [],
235 stl: "none",
236 notice: "custom_notice",
237 }
238 cc_library {
239 name: "libprofile-clang-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-extras_ndk",
250 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900251 product_available: true,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400252 native_coverage: false,
253 system_shared_libs: [],
254 stl: "none",
255 notice: "custom_notice",
256 sdk_version: "current",
257 }
258 cc_library {
259 name: "libprofile-clang-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
Inseob Kimc0907f12019-02-08 21:00:45 +0900269 cc_library {
270 name: "libdl",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100271 defaults: ["linux_bionic_supported"],
Yi Konge7fe9912019-06-02 00:53:50 -0700272 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900273 nocrt: true,
Peter Collingbournee5ba2862019-12-10 18:37:45 -0800274 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900275 system_shared_libs: [],
276 recovery_available: true,
Colin Crossf9aabd72020-02-15 11:29:50 -0800277 stubs: {
278 versions: ["27", "28", "29"],
279 },
280 apex_available: [
281 "//apex_available:platform",
282 "myapex"
283 ],
Colin Cross0477b422020-10-13 18:43:54 -0700284 llndk_stubs: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900285 }
286 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700287 name: "libdl.llndk",
Inseob Kimc0907f12019-02-08 21:00:45 +0900288 symbol_file: "",
Colin Crossc511bc52020-04-07 16:50:32 +0000289 sdk_version: "current",
Inseob Kimc0907f12019-02-08 21:00:45 +0900290 }
291 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900292 name: "libft2",
293 no_libcrt: true,
294 nocrt: true,
295 system_shared_libs: [],
296 recovery_available: true,
Colin Cross0477b422020-10-13 18:43:54 -0700297 llndk_stubs: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900298 }
299 llndk_library {
Colin Cross0477b422020-10-13 18:43:54 -0700300 name: "libft2.llndk",
Jooyung Han097087b2019-10-22 19:32:18 +0900301 symbol_file: "",
Justin Yunc0d8c492021-01-07 17:45:31 +0900302 private: true,
Colin Crossc511bc52020-04-07 16:50:32 +0000303 sdk_version: "current",
Jooyung Han097087b2019-10-22 19:32:18 +0900304 }
305 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900306 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700307 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900308 nocrt: true,
309 system_shared_libs: [],
310 stl: "none",
311 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900312 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900313 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900314 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900315 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900316 apex_available: [
317 "//apex_available:platform",
318 "//apex_available:anyapex",
319 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900320 }
321 cc_library {
322 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700323 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900324 nocrt: true,
325 system_shared_libs: [],
326 stl: "none",
327 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900328 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900329 recovery_available: true,
Inseob Kim89db15d2020-02-03 18:06:46 +0900330 host_supported: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900331 min_sdk_version: "29",
Inseob Kimc0907f12019-02-08 21:00:45 +0900332 vndk: {
333 enabled: true,
334 support_system_process: true,
335 },
Colin Crossf9aabd72020-02-15 11:29:50 -0800336 apex_available: [
337 "//apex_available:platform",
Ivan Lozano3e9f9e42020-12-04 15:05:43 -0500338 "//apex_available:anyapex",
Colin Crossf9aabd72020-02-15 11:29:50 -0800339 ],
Inseob Kimc0907f12019-02-08 21:00:45 +0900340 }
341 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700342 name: "libc++demangle",
343 no_libcrt: true,
344 nocrt: true,
345 system_shared_libs: [],
346 stl: "none",
347 host_supported: false,
348 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900349 product_available: true,
Dan Albert2da19cb2019-07-24 12:17:40 -0700350 recovery_available: true,
Jooyung Han749dc692020-04-15 11:03:39 +0900351 min_sdk_version: "29",
Jiyong Park541142c2020-03-07 16:35:46 +0900352 apex_available: [
353 "//apex_available:platform",
354 "//apex_available:anyapex",
355 ],
Dan Albert2da19cb2019-07-24 12:17:40 -0700356 }
357 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900358 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700359 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900360 nocrt: true,
361 system_shared_libs: [],
362 stl: "none",
363 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900364 product_available: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900365 recovery_available: true,
366 }
367
Jiyong Park541142c2020-03-07 16:35:46 +0900368 cc_defaults {
369 name: "crt_defaults",
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100370 defaults: ["linux_bionic_supported"],
Jiyong Park541142c2020-03-07 16:35:46 +0900371 recovery_available: true,
372 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +0900373 product_available: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900374 native_bridge_supported: true,
375 stl: "none",
Dan Albert92fe7402020-07-15 13:33:30 -0700376 min_sdk_version: "16",
377 crt: true,
Jiyong Park541142c2020-03-07 16:35:46 +0900378 apex_available: [
379 "//apex_available:platform",
380 "//apex_available:anyapex",
381 ],
382 }
383
Inseob Kimc0907f12019-02-08 21:00:45 +0900384 cc_object {
385 name: "crtbegin_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900386 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900387 }
388
389 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700390 name: "crtbegin_dynamic",
Jiyong Park541142c2020-03-07 16:35:46 +0900391 defaults: ["crt_defaults"],
Colin Cross815daf92019-05-14 16:05:20 -0700392 }
393
394 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900395 name: "crtbegin_static",
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_so",
Jiyong Park541142c2020-03-07 16:35:46 +0900401 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900402 }
403
404 cc_object {
405 name: "crtend_android",
Jiyong Park541142c2020-03-07 16:35:46 +0900406 defaults: ["crt_defaults"],
Inseob Kimc0907f12019-02-08 21:00:45 +0900407 }
408
409 cc_library {
410 name: "libprotobuf-cpp-lite",
411 }
Colin Crossf28329d2020-02-15 11:00:10 -0800412
413 cc_library {
414 name: "ndk_libunwind",
415 sdk_version: "current",
416 stl: "none",
417 system_shared_libs: [],
418 }
419
Dan Albertde5aade2020-06-30 12:32:51 -0700420 ndk_library {
421 name: "libc",
422 first_version: "minimum",
423 symbol_file: "libc.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800424 }
425
Dan Albertde5aade2020-06-30 12:32:51 -0700426 ndk_library {
427 name: "libm",
428 first_version: "minimum",
429 symbol_file: "libm.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800430 }
431
Dan Albertde5aade2020-06-30 12:32:51 -0700432 ndk_library {
433 name: "libdl",
434 first_version: "minimum",
435 symbol_file: "libdl.map.txt",
Colin Crossf28329d2020-02-15 11:00:10 -0800436 }
437
Colin Crossf28329d2020-02-15 11:00:10 -0800438 ndk_prebuilt_shared_stl {
439 name: "ndk_libc++_shared",
440 }
Jiyong Park46a512f2020-12-04 18:02:13 +0900441
442 cc_library_static {
443 name: "libgoogle-benchmark",
444 sdk_version: "current",
445 stl: "none",
446 system_shared_libs: [],
447 }
Evgenii Stepanov193ac2e2020-04-28 15:09:12 -0700448
449 cc_library_static {
450 name: "note_memtag_heap_async",
451 }
452
453 cc_library_static {
454 name: "note_memtag_heap_sync",
455 }
Colin Crossf28329d2020-02-15 11:00:10 -0800456 `
457
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100458 supportLinuxBionic := false
Paul Duffina04c1072020-03-02 10:16:35 +0000459 for _, os := range oses {
460 if os == android.Fuchsia {
461 ret += `
Inseob Kimc0907f12019-02-08 21:00:45 +0900462 cc_library {
463 name: "libbioniccompat",
464 stl: "none",
465 }
466 cc_library {
467 name: "libcompiler_rt",
468 stl: "none",
469 }
470 `
Paul Duffina04c1072020-03-02 10:16:35 +0000471 }
472 if os == android.Windows {
473 ret += `
474 toolchain_library {
475 name: "libwinpthread",
476 host_supported: true,
477 enabled: false,
478 target: {
479 windows: {
480 enabled: true,
481 },
482 },
483 src: "",
484 }
485 `
486 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100487 if os == android.LinuxBionic {
488 supportLinuxBionic = true
489 ret += `
490 cc_binary {
491 name: "linker",
492 defaults: ["linux_bionic_supported"],
493 recovery_available: true,
494 stl: "none",
495 nocrt: true,
496 static_executable: true,
497 native_coverage: false,
498 system_shared_libs: [],
499 }
500
501 cc_genrule {
502 name: "host_bionic_linker_flags",
503 host_supported: true,
504 device_supported: false,
505 target: {
506 host: {
507 enabled: false,
508 },
509 linux_bionic: {
510 enabled: true,
511 },
512 },
513 out: ["linker.flags"],
514 }
515
516 cc_defaults {
517 name: "linux_bionic_supported",
518 host_supported: true,
519 target: {
520 host: {
521 enabled: false,
522 },
523 linux_bionic: {
524 enabled: true,
525 },
526 },
527 }
528 `
529 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900530 }
Martin Stjernholm7feceb22020-07-11 04:33:29 +0100531
532 if !supportLinuxBionic {
533 ret += `
534 cc_defaults {
535 name: "linux_bionic_supported",
536 }
537 `
538 }
539
Inseob Kimc0907f12019-02-08 21:00:45 +0900540 return ret
541}
Colin Cross9a942872019-05-14 15:44:26 -0700542
Colin Crossf28329d2020-02-15 11:00:10 -0800543func GatherRequiredFilesForTest(fs map[string][]byte) {
Colin Crossf28329d2020-02-15 11:00:10 -0800544}
545
Colin Cross98be1bb2019-12-13 20:41:13 -0800546func TestConfig(buildDir string, os android.OsType, env map[string]string,
547 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700548
Colin Cross98be1bb2019-12-13 20:41:13 -0800549 // add some modules that are required by the compiler and/or linker
550 bp = bp + GatherRequiredDepsForTest(os)
551
Colin Cross2fce23a2020-06-07 17:02:48 -0700552 mockFS := map[string][]byte{}
Colin Cross98be1bb2019-12-13 20:41:13 -0800553
Colin Crossf28329d2020-02-15 11:00:10 -0800554 GatherRequiredFilesForTest(mockFS)
555
Colin Cross98be1bb2019-12-13 20:41:13 -0800556 for k, v := range fs {
557 mockFS[k] = v
558 }
559
560 var config android.Config
561 if os == android.Fuchsia {
562 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
563 } else {
564 config = android.TestArchConfig(buildDir, env, bp, mockFS)
565 }
566
567 return config
568}
569
Colin Crossae8600b2020-10-29 17:09:13 -0700570func CreateTestContext(config android.Config) *android.TestContext {
571 ctx := android.NewTestArchContext(config)
Colin Cross4b49b762019-11-22 15:25:03 -0800572 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800573 ctx.RegisterModuleType("cc_test", TestFactory)
Chris Parsons79d66a52020-06-05 17:26:16 -0400574 ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800575 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
576 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800577 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
578 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900579 ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
Inseob Kimc42f2f22020-07-29 20:32:10 +0900580 ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
Inseob Kim5f58ff72020-09-07 19:53:31 +0900581 ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
Colin Crosse4e44bc2020-12-28 13:50:21 -0800582 RegisterVndkLibraryTxtTypes(ctx)
Colin Crosse1bb5d02019-09-24 14:55:04 -0700583 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Paul Duffin021f4e52020-07-30 16:04:17 +0100584 android.RegisterPrebuiltMutators(ctx)
Paul Duffinc988c8e2020-04-29 18:27:14 +0100585 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross4b49b762019-11-22 15:25:03 -0800586 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Inseob Kim8471cda2019-11-15 09:59:12 +0900587 ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
Inseob Kime9aec6a2021-01-05 20:03:22 +0900588 ctx.RegisterSingletonType("vendor-fake-snapshot", VendorFakeSnapshotSingleton)
Jose Galmesf7294582020-11-13 12:07:36 -0800589 ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
Colin Cross9a942872019-05-14 15:44:26 -0700590
Colin Cross9a942872019-05-14 15:44:26 -0700591 return ctx
592}