blob: 905d037da542555ec042082c52dc1af3aae6a0d8 [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) {
22 ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
23 ctx.RegisterModuleType("cc_library", LibraryFactory)
24 ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
25 ctx.RegisterModuleType("cc_object", ObjectFactory)
26
27 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
28 ctx.BottomUp("vndk", VndkMutator).Parallel()
29 ctx.BottomUp("link", LinkageMutator).Parallel()
30 ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
31 ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
32 ctx.BottomUp("version", VersionMutator).Parallel()
33 ctx.BottomUp("begin", BeginMutator).Parallel()
34 ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
35 })
36}
37
Inseob Kimc0907f12019-02-08 21:00:45 +090038func GatherRequiredDepsForTest(os android.OsType) string {
39 ret := `
40 toolchain_library {
41 name: "libatomic",
42 vendor_available: true,
43 recovery_available: true,
44 src: "",
45 }
46
47 toolchain_library {
48 name: "libcompiler_rt-extras",
49 vendor_available: true,
50 recovery_available: true,
51 src: "",
52 }
53
54 toolchain_library {
55 name: "libclang_rt.builtins-arm-android",
56 vendor_available: true,
57 recovery_available: true,
58 src: "",
59 }
60
61 toolchain_library {
62 name: "libclang_rt.builtins-aarch64-android",
63 vendor_available: true,
64 recovery_available: true,
65 src: "",
66 }
67
68 toolchain_library {
69 name: "libclang_rt.builtins-i686-android",
70 vendor_available: true,
71 recovery_available: true,
72 src: "",
73 }
74
75 toolchain_library {
76 name: "libclang_rt.builtins-x86_64-android",
77 vendor_available: true,
78 recovery_available: true,
79 src: "",
80 }
81
82 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -070083 name: "libclang_rt.fuzzer-arm-android",
84 vendor_available: true,
85 recovery_available: true,
86 src: "",
87 }
88
89 toolchain_library {
90 name: "libclang_rt.fuzzer-aarch64-android",
91 vendor_available: true,
92 recovery_available: true,
93 src: "",
94 }
95
96 toolchain_library {
97 name: "libclang_rt.fuzzer-i686-android",
98 vendor_available: true,
99 recovery_available: true,
100 src: "",
101 }
102
103 toolchain_library {
104 name: "libclang_rt.fuzzer-x86_64-android",
105 vendor_available: true,
106 recovery_available: true,
107 src: "",
108 }
109
110 toolchain_library {
111 name: "libclang_rt.fuzzer-x86_64",
112 vendor_available: true,
113 recovery_available: true,
114 src: "",
115 }
116
117 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900118 name: "libgcc",
119 vendor_available: true,
120 recovery_available: true,
121 src: "",
122 }
123
Yi Kongacee27c2019-03-29 20:05:14 -0700124 toolchain_library {
125 name: "libgcc_stripped",
126 vendor_available: true,
127 recovery_available: true,
128 src: "",
129 }
130
Inseob Kimc0907f12019-02-08 21:00:45 +0900131 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900132 name: "libc",
Yi Konge7fe9912019-06-02 00:53:50 -0700133 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900134 nocrt: true,
135 system_shared_libs: [],
136 recovery_available: true,
137 }
138 llndk_library {
139 name: "libc",
140 symbol_file: "",
141 }
142 cc_library {
143 name: "libm",
Yi Konge7fe9912019-06-02 00:53:50 -0700144 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900145 nocrt: true,
146 system_shared_libs: [],
147 recovery_available: true,
148 }
149 llndk_library {
150 name: "libm",
151 symbol_file: "",
152 }
153 cc_library {
154 name: "libdl",
Yi Konge7fe9912019-06-02 00:53:50 -0700155 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900156 nocrt: true,
157 system_shared_libs: [],
158 recovery_available: true,
159 }
160 llndk_library {
161 name: "libdl",
162 symbol_file: "",
163 }
164 cc_library {
Jooyung Han097087b2019-10-22 19:32:18 +0900165 name: "libft2",
166 no_libcrt: true,
167 nocrt: true,
168 system_shared_libs: [],
169 recovery_available: true,
170 }
171 llndk_library {
172 name: "libft2",
173 symbol_file: "",
174 vendor_available: false,
175 }
176 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900177 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700178 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900179 nocrt: true,
180 system_shared_libs: [],
181 stl: "none",
182 vendor_available: true,
183 recovery_available: true,
184 }
185 cc_library {
186 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700187 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900188 nocrt: true,
189 system_shared_libs: [],
190 stl: "none",
191 vendor_available: true,
192 recovery_available: true,
193 vndk: {
194 enabled: true,
195 support_system_process: true,
196 },
197 }
198 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700199 name: "libc++demangle",
200 no_libcrt: true,
201 nocrt: true,
202 system_shared_libs: [],
203 stl: "none",
204 host_supported: false,
205 vendor_available: true,
206 recovery_available: true,
207 }
208 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900209 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700210 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900211 nocrt: true,
212 system_shared_libs: [],
213 stl: "none",
214 vendor_available: true,
215 recovery_available: true,
216 }
217
218 cc_object {
219 name: "crtbegin_so",
220 recovery_available: true,
221 vendor_available: true,
Jiyong Parka7bc8ad2019-10-15 15:20:07 +0900222 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900223 }
224
225 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700226 name: "crtbegin_dynamic",
227 recovery_available: true,
228 vendor_available: true,
229 }
230
231 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900232 name: "crtbegin_static",
233 recovery_available: true,
234 vendor_available: true,
235 }
236
237 cc_object {
238 name: "crtend_so",
239 recovery_available: true,
240 vendor_available: true,
Jiyong Parka7bc8ad2019-10-15 15:20:07 +0900241 stl: "none",
Inseob Kimc0907f12019-02-08 21:00:45 +0900242 }
243
244 cc_object {
245 name: "crtend_android",
246 recovery_available: true,
247 vendor_available: true,
248 }
249
250 cc_library {
251 name: "libprotobuf-cpp-lite",
252 }
253 `
254 if os == android.Fuchsia {
255 ret += `
256 cc_library {
257 name: "libbioniccompat",
258 stl: "none",
259 }
260 cc_library {
261 name: "libcompiler_rt",
262 stl: "none",
263 }
264 `
265 }
266 return ret
267}
Colin Cross9a942872019-05-14 15:44:26 -0700268
Colin Cross98be1bb2019-12-13 20:41:13 -0800269func TestConfig(buildDir string, os android.OsType, env map[string]string,
270 bp string, fs map[string][]byte) android.Config {
Colin Cross9a942872019-05-14 15:44:26 -0700271
Colin Cross98be1bb2019-12-13 20:41:13 -0800272 // add some modules that are required by the compiler and/or linker
273 bp = bp + GatherRequiredDepsForTest(os)
274
275 mockFS := map[string][]byte{
276 "foo.c": nil,
277 "foo.lds": nil,
278 "bar.c": nil,
279 "baz.c": nil,
280 "baz.o": nil,
281 "a.proto": nil,
282 "b.aidl": nil,
283 "sub/c.aidl": nil,
284 "my_include": nil,
285 "foo.map.txt": nil,
286 "liba.so": nil,
287 }
288
289 for k, v := range fs {
290 mockFS[k] = v
291 }
292
293 var config android.Config
294 if os == android.Fuchsia {
295 config = android.TestArchConfigFuchsia(buildDir, env, bp, mockFS)
296 } else {
297 config = android.TestArchConfig(buildDir, env, bp, mockFS)
298 }
299
300 return config
301}
302
303func CreateTestContext() *android.TestContext {
Colin Cross9a942872019-05-14 15:44:26 -0700304 ctx := android.NewTestArchContext()
Colin Cross4b49b762019-11-22 15:25:03 -0800305 ctx.RegisterModuleType("cc_defaults", defaultsFactory)
306 ctx.RegisterModuleType("cc_binary", BinaryFactory)
307 ctx.RegisterModuleType("cc_binary_host", binaryHostFactory)
308 ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800309 ctx.RegisterModuleType("cc_library_shared", LibrarySharedFactory)
310 ctx.RegisterModuleType("cc_library_static", LibraryStaticFactory)
311 ctx.RegisterModuleType("cc_library_headers", LibraryHeaderFactory)
312 ctx.RegisterModuleType("cc_test", TestFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800313 ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
Jooyung Hanb90e4912019-12-09 18:21:48 +0900314 ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800315 ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
Colin Cross4b49b762019-11-22 15:25:03 -0800316 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
317 ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
318 ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
Paul Duffin77980a82019-12-19 16:01:36 +0000319 RegisterRequiredBuildComponentsForTest(ctx)
Colin Cross9a942872019-05-14 15:44:26 -0700320 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
321 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
322 })
Colin Crosse1bb5d02019-09-24 14:55:04 -0700323 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Colin Cross4b49b762019-11-22 15:25:03 -0800324 ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Colin Cross9a942872019-05-14 15:44:26 -0700325
Colin Cross9a942872019-05-14 15:44:26 -0700326 return ctx
327}