blob: bf806bc5a41566b063d09035df5d36f05e217888 [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 {
170 name: "libunwind_llvm",
Yi Konge7fe9912019-06-02 00:53:50 -0700171 no_libcrt: true,
Inseob Kimc0907f12019-02-08 21:00:45 +0900172 nocrt: true,
173 system_shared_libs: [],
174 stl: "none",
175 vendor_available: true,
176 recovery_available: true,
177 }
178
179 cc_object {
180 name: "crtbegin_so",
181 recovery_available: true,
182 vendor_available: true,
183 }
184
185 cc_object {
Colin Cross815daf92019-05-14 16:05:20 -0700186 name: "crtbegin_dynamic",
187 recovery_available: true,
188 vendor_available: true,
189 }
190
191 cc_object {
Inseob Kimc0907f12019-02-08 21:00:45 +0900192 name: "crtbegin_static",
193 recovery_available: true,
194 vendor_available: true,
195 }
196
197 cc_object {
198 name: "crtend_so",
199 recovery_available: true,
200 vendor_available: true,
201 }
202
203 cc_object {
204 name: "crtend_android",
205 recovery_available: true,
206 vendor_available: true,
207 }
208
209 cc_library {
210 name: "libprotobuf-cpp-lite",
211 }
212 `
213 if os == android.Fuchsia {
214 ret += `
215 cc_library {
216 name: "libbioniccompat",
217 stl: "none",
218 }
219 cc_library {
220 name: "libcompiler_rt",
221 stl: "none",
222 }
223 `
224 }
225 return ret
226}
Colin Cross9a942872019-05-14 15:44:26 -0700227
228func CreateTestContext(bp string, fs map[string][]byte,
229 os android.OsType) *android.TestContext {
230
231 ctx := android.NewTestArchContext()
232 ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory))
233 ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory))
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700234 ctx.RegisterModuleType("cc_fuzz", android.ModuleFactoryAdaptor(FuzzFactory))
Colin Cross9a942872019-05-14 15:44:26 -0700235 ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory))
236 ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory))
237 ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory))
238 ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory))
Colin Cross815daf92019-05-14 16:05:20 -0700239 ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(TestFactory))
Colin Cross9a942872019-05-14 15:44:26 -0700240 ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory))
241 ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory))
242 ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory))
243 ctx.RegisterModuleType("vendor_public_library", android.ModuleFactoryAdaptor(vendorPublicLibraryFactory))
244 ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(ObjectFactory))
245 ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory))
Jooyung Han38002912019-05-16 04:01:54 +0900246 ctx.RegisterModuleType("vndk_prebuilt_shared", android.ModuleFactoryAdaptor(vndkPrebuiltSharedFactory))
Colin Cross9a942872019-05-14 15:44:26 -0700247 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
248 ctx.BottomUp("image", ImageMutator).Parallel()
249 ctx.BottomUp("link", LinkageMutator).Parallel()
250 ctx.BottomUp("vndk", VndkMutator).Parallel()
251 ctx.BottomUp("version", VersionMutator).Parallel()
252 ctx.BottomUp("begin", BeginMutator).Parallel()
253 })
254 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
255 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
256 })
257 ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton))
258
259 // add some modules that are required by the compiler and/or linker
260 bp = bp + GatherRequiredDepsForTest(os)
261
262 mockFS := map[string][]byte{
263 "Android.bp": []byte(bp),
264 "foo.c": nil,
265 "bar.c": nil,
266 "a.proto": nil,
267 "b.aidl": nil,
268 "my_include": nil,
269 "foo.map.txt": nil,
270 "liba.so": nil,
271 }
272
273 for k, v := range fs {
274 mockFS[k] = v
275 }
276
277 ctx.MockFileSystem(mockFS)
278
279 return ctx
280}