blob: e69b774fca4750ca4bf2a0b665d9f014644d7282 [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
21func GatherRequiredDepsForTest(os android.OsType) string {
22 ret := `
23 toolchain_library {
24 name: "libatomic",
25 vendor_available: true,
26 recovery_available: true,
27 src: "",
28 }
29
30 toolchain_library {
31 name: "libcompiler_rt-extras",
32 vendor_available: true,
33 recovery_available: true,
34 src: "",
35 }
36
37 toolchain_library {
38 name: "libclang_rt.builtins-arm-android",
39 vendor_available: true,
40 recovery_available: true,
41 src: "",
42 }
43
44 toolchain_library {
45 name: "libclang_rt.builtins-aarch64-android",
46 vendor_available: true,
47 recovery_available: true,
48 src: "",
49 }
50
51 toolchain_library {
52 name: "libclang_rt.builtins-i686-android",
53 vendor_available: true,
54 recovery_available: true,
55 src: "",
56 }
57
58 toolchain_library {
59 name: "libclang_rt.builtins-x86_64-android",
60 vendor_available: true,
61 recovery_available: true,
62 src: "",
63 }
64
65 toolchain_library {
Mitch Phillipsda9a4632019-07-15 09:34:09 -070066 name: "libclang_rt.fuzzer-arm-android",
67 vendor_available: true,
68 recovery_available: true,
69 src: "",
70 }
71
72 toolchain_library {
73 name: "libclang_rt.fuzzer-aarch64-android",
74 vendor_available: true,
75 recovery_available: true,
76 src: "",
77 }
78
79 toolchain_library {
80 name: "libclang_rt.fuzzer-i686-android",
81 vendor_available: true,
82 recovery_available: true,
83 src: "",
84 }
85
86 toolchain_library {
87 name: "libclang_rt.fuzzer-x86_64-android",
88 vendor_available: true,
89 recovery_available: true,
90 src: "",
91 }
92
93 toolchain_library {
94 name: "libclang_rt.fuzzer-x86_64",
95 vendor_available: true,
96 recovery_available: true,
97 src: "",
98 }
99
100 toolchain_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900101 name: "libgcc",
102 vendor_available: true,
103 recovery_available: true,
104 src: "",
105 }
106
Yi Kongacee27c2019-03-29 20:05:14 -0700107 toolchain_library {
108 name: "libgcc_stripped",
109 vendor_available: true,
110 recovery_available: true,
111 src: "",
112 }
113
Inseob Kimc0907f12019-02-08 21:00:45 +0900114 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900115 name: "libc",
Yi Konge7fe9912019-06-02 00:53:50 -0700116 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900117 nocrt: true,
118 system_shared_libs: [],
119 recovery_available: true,
120 }
121 llndk_library {
122 name: "libc",
123 symbol_file: "",
124 }
125 cc_library {
126 name: "libm",
Yi Konge7fe9912019-06-02 00:53:50 -0700127 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900128 nocrt: true,
129 system_shared_libs: [],
130 recovery_available: true,
131 }
132 llndk_library {
133 name: "libm",
134 symbol_file: "",
135 }
136 cc_library {
137 name: "libdl",
Yi Konge7fe9912019-06-02 00:53:50 -0700138 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900139 nocrt: true,
140 system_shared_libs: [],
141 recovery_available: true,
142 }
143 llndk_library {
144 name: "libdl",
145 symbol_file: "",
146 }
147 cc_library {
148 name: "libc++_static",
Yi Konge7fe9912019-06-02 00:53:50 -0700149 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900150 nocrt: true,
151 system_shared_libs: [],
152 stl: "none",
153 vendor_available: true,
154 recovery_available: true,
155 }
156 cc_library {
157 name: "libc++",
Yi Konge7fe9912019-06-02 00:53:50 -0700158 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900159 nocrt: true,
160 system_shared_libs: [],
161 stl: "none",
162 vendor_available: true,
163 recovery_available: true,
164 vndk: {
165 enabled: true,
166 support_system_process: true,
167 },
168 }
169 cc_library {
Dan Albert2da19cb2019-07-24 12:17:40 -0700170 name: "libc++demangle",
171 no_libcrt: true,
172 nocrt: true,
173 system_shared_libs: [],
174 stl: "none",
175 host_supported: false,
176 vendor_available: true,
177 recovery_available: true,
178 }
179 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +0900180 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700181 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900182 nocrt: true,
183 system_shared_libs: [],
184 stl: "none",
185 vendor_available: true,
186 recovery_available: true,
187 }
188
189 cc_object {
190 name: "crtbegin_so",
191 recovery_available: true,
192 vendor_available: true,
193 }
194
195 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700196 name: "crtbegin_dynamic",
197 recovery_available: true,
198 vendor_available: true,
199 }
200
201 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900202 name: "crtbegin_static",
203 recovery_available: true,
204 vendor_available: true,
205 }
206
207 cc_object {
208 name: "crtend_so",
209 recovery_available: true,
210 vendor_available: true,
211 }
212
213 cc_object {
214 name: "crtend_android",
215 recovery_available: true,
216 vendor_available: true,
217 }
218
219 cc_library {
220 name: "libprotobuf-cpp-lite",
221 }
222 `
223 if os == android.Fuchsia {
224 ret += `
225 cc_library {
226 name: "libbioniccompat",
227 stl: "none",
228 }
229 cc_library {
230 name: "libcompiler_rt",
231 stl: "none",
232 }
233 `
234 }
235 return ret
236}
Colin Cross9a942872019-05-14 15:44:26 -0700237
238func CreateTestContext(bp string, fs map[string][]byte,
239 os android.OsType) *android.TestContext {
240
241 ctx := android.NewTestArchContext()
242 ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory))
243 ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory))
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700244 ctx.RegisterModuleType("cc_fuzz", android.ModuleFactoryAdaptor(FuzzFactory))
Colin Cross9a942872019-05-14 15:44:26 -0700245 ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory))
246 ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory))
247 ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory))
248 ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory))
Colin Cross815daf92019-05-14 16:05:20 -0700249 ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(TestFactory))
Colin Cross9a942872019-05-14 15:44:26 -0700250 ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory))
251 ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory))
252 ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory))
253 ctx.RegisterModuleType("vendor_public_library", android.ModuleFactoryAdaptor(vendorPublicLibraryFactory))
254 ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(ObjectFactory))
255 ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory))
Jooyung Han38002912019-05-16 04:01:54 +0900256 ctx.RegisterModuleType("vndk_prebuilt_shared", android.ModuleFactoryAdaptor(vndkPrebuiltSharedFactory))
Colin Cross9a942872019-05-14 15:44:26 -0700257 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
258 ctx.BottomUp("image", ImageMutator).Parallel()
259 ctx.BottomUp("link", LinkageMutator).Parallel()
260 ctx.BottomUp("vndk", VndkMutator).Parallel()
261 ctx.BottomUp("version", VersionMutator).Parallel()
262 ctx.BottomUp("begin", BeginMutator).Parallel()
263 })
264 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
265 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
266 })
267 ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton))
268
269 // add some modules that are required by the compiler and/or linker
270 bp = bp + GatherRequiredDepsForTest(os)
271
272 mockFS := map[string][]byte{
273 "Android.bp": []byte(bp),
274 "foo.c": nil,
275 "bar.c": nil,
276 "a.proto": nil,
277 "b.aidl": nil,
Jiyong Park29074592019-07-07 16:27:47 +0900278 "sub/c.aidl": nil,
Colin Cross9a942872019-05-14 15:44:26 -0700279 "my_include": nil,
280 "foo.map.txt": nil,
281 "liba.so": nil,
282 }
283
284 for k, v := range fs {
285 mockFS[k] = v
286 }
287
288 ctx.MockFileSystem(mockFS)
289
290 return ctx
291}