blob: 162a74600923350346d6cdfec15b215448b0aa72 [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 {
66 name: "libgcc",
67 vendor_available: true,
68 recovery_available: true,
69 src: "",
70 }
71
Yi Kongacee27c2019-03-29 20:05:14 -070072 toolchain_library {
73 name: "libgcc_stripped",
74 vendor_available: true,
75 recovery_available: true,
76 src: "",
77 }
78
Inseob Kimc0907f12019-02-08 21:00:45 +090079 cc_library {
Inseob Kimc0907f12019-02-08 21:00:45 +090080 name: "libc",
81 no_libgcc: true,
82 nocrt: true,
83 system_shared_libs: [],
84 recovery_available: true,
85 }
86 llndk_library {
87 name: "libc",
88 symbol_file: "",
89 }
90 cc_library {
91 name: "libm",
92 no_libgcc: true,
93 nocrt: true,
94 system_shared_libs: [],
95 recovery_available: true,
96 }
97 llndk_library {
98 name: "libm",
99 symbol_file: "",
100 }
101 cc_library {
102 name: "libdl",
103 no_libgcc: true,
104 nocrt: true,
105 system_shared_libs: [],
106 recovery_available: true,
107 }
108 llndk_library {
109 name: "libdl",
110 symbol_file: "",
111 }
112 cc_library {
113 name: "libc++_static",
114 no_libgcc: true,
115 nocrt: true,
116 system_shared_libs: [],
117 stl: "none",
118 vendor_available: true,
119 recovery_available: true,
120 }
121 cc_library {
122 name: "libc++",
123 no_libgcc: true,
124 nocrt: true,
125 system_shared_libs: [],
126 stl: "none",
127 vendor_available: true,
128 recovery_available: true,
129 vndk: {
130 enabled: true,
131 support_system_process: true,
132 },
133 }
134 cc_library {
135 name: "libunwind_llvm",
136 no_libgcc: true,
137 nocrt: true,
138 system_shared_libs: [],
139 stl: "none",
140 vendor_available: true,
141 recovery_available: true,
142 }
143
144 cc_object {
145 name: "crtbegin_so",
146 recovery_available: true,
147 vendor_available: true,
148 }
149
150 cc_object {
151 name: "crtbegin_static",
152 recovery_available: true,
153 vendor_available: true,
154 }
155
156 cc_object {
157 name: "crtend_so",
158 recovery_available: true,
159 vendor_available: true,
160 }
161
162 cc_object {
163 name: "crtend_android",
164 recovery_available: true,
165 vendor_available: true,
166 }
167
168 cc_library {
169 name: "libprotobuf-cpp-lite",
170 }
171 `
172 if os == android.Fuchsia {
173 ret += `
174 cc_library {
175 name: "libbioniccompat",
176 stl: "none",
177 }
178 cc_library {
179 name: "libcompiler_rt",
180 stl: "none",
181 }
182 `
183 }
184 return ret
185}
Colin Cross9a942872019-05-14 15:44:26 -0700186
187func CreateTestContext(bp string, fs map[string][]byte,
188 os android.OsType) *android.TestContext {
189
190 ctx := android.NewTestArchContext()
191 ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory))
192 ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory))
193 ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory))
194 ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory))
195 ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory))
196 ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory))
197 ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory))
198 ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory))
199 ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory))
200 ctx.RegisterModuleType("vendor_public_library", android.ModuleFactoryAdaptor(vendorPublicLibraryFactory))
201 ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(ObjectFactory))
202 ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory))
203 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
204 ctx.BottomUp("image", ImageMutator).Parallel()
205 ctx.BottomUp("link", LinkageMutator).Parallel()
206 ctx.BottomUp("vndk", VndkMutator).Parallel()
207 ctx.BottomUp("version", VersionMutator).Parallel()
208 ctx.BottomUp("begin", BeginMutator).Parallel()
209 })
210 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
211 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
212 })
213 ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton))
214
215 // add some modules that are required by the compiler and/or linker
216 bp = bp + GatherRequiredDepsForTest(os)
217
218 mockFS := map[string][]byte{
219 "Android.bp": []byte(bp),
220 "foo.c": nil,
221 "bar.c": nil,
222 "a.proto": nil,
223 "b.aidl": nil,
224 "my_include": nil,
225 "foo.map.txt": nil,
226 "liba.so": nil,
227 }
228
229 for k, v := range fs {
230 mockFS[k] = v
231 }
232
233 ctx.MockFileSystem(mockFS)
234
235 return ctx
236}