blob: df66e370cdd85385b59ddb7ed35c8a53a4e9ad65 [file] [log] [blame]
Roland Levillaind56de912019-06-20 20:55:26 +01001// This Blueprint file loosely follows the logic of cpu_features'
Roland Levillain18318b62019-06-21 19:56:28 +01002// CMakeLists.txt and test/CMakeLists.txt files.
Roland Levillaind56de912019-06-20 20:55:26 +01003
4cc_defaults {
5 name: "cpu_features-defaults",
6 host_supported: true,
7 local_include_dirs: [
8 "include",
Roland Levillaind56de912019-06-20 20:55:26 +01009 ],
10 cflags: [
11 // Reserve 1024 bytes on the stack when reading from `/proc/cpuinfo`.
12 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
Haibo Huang2519d752019-07-12 18:21:31 -070013 "-Wno-gnu-designator",
Roland Levillaind56de912019-06-20 20:55:26 +010014 ],
15}
16
17cc_library {
18 name: "libcpu_features-utils",
19 defaults: ["cpu_features-defaults"],
20 srcs: [
21 "src/filesystem.c",
22 "src/stack_line_reader.c",
23 "src/string_view.c",
24 ],
Elliott Hughese39557c2019-08-05 12:23:07 -070025 target: {
26 windows: {
27 enabled: true,
28 },
29 },
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +000030 apex_available: [
31 "com.android.art.release",
32 "com.android.art.debug",
33 ],
Roland Levillaind56de912019-06-20 20:55:26 +010034}
35
36cc_library {
37 name: "libcpu_features-unix_based_hardware_detection",
38 defaults: ["cpu_features-defaults"],
39 srcs: [
40 "src/hwcaps.c",
41 "src/unix_features_aggregator.c",
42 ],
43 cflags: [
44 "-DHAVE_DLFCN_H",
45 ],
46 target: {
47 bionic: {
48 cflags: [
49 "-DHAVE_STRONG_GETAUXVAL",
50 ],
51 },
52 },
53 static_libs: [
54 "libcpu_features-utils",
55 ],
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +000056 apex_available: [
57 "com.android.art.release",
58 "com.android.art.debug",
59 ],
Roland Levillaind56de912019-06-20 20:55:26 +010060}
61
62cc_library {
63 name: "libcpu_features",
64 defaults: [
65 "cpu_features-defaults",
66 ],
Elliott Hughes7f8ace62019-08-05 11:58:18 -070067 export_include_dirs: ["include"],
Roland Levillaind56de912019-06-20 20:55:26 +010068 whole_static_libs: [
69 "libcpu_features-utils",
70 ],
71 arch: {
72 arm: {
73 srcs: [
74 "src/cpuinfo_arm.c",
75 ],
76 whole_static_libs: [
77 "libcpu_features-unix_based_hardware_detection",
78 ],
79 },
80 arm64: {
81 srcs: [
82 "src/cpuinfo_aarch64.c",
83 ],
84 whole_static_libs: [
85 "libcpu_features-unix_based_hardware_detection",
86 ],
Haibo Huang2519d752019-07-12 18:21:31 -070087 cflags: [
88 "-Wno-gnu-designator",
89 ],
Roland Levillaind56de912019-06-20 20:55:26 +010090 },
91 x86: {
92 srcs: [
93 "src/cpuinfo_x86.c",
94 ],
Haibo Huang2519d752019-07-12 18:21:31 -070095 cflags: [
96 "-Wno-unused-variable",
97 ],
Roland Levillaind56de912019-06-20 20:55:26 +010098 },
99 x86_64: {
100 srcs: [
101 "src/cpuinfo_x86.c",
102 ],
Haibo Huang2519d752019-07-12 18:21:31 -0700103 cflags: [
104 "-Wno-unused-variable",
105 ],
Roland Levillaind56de912019-06-20 20:55:26 +0100106 },
107 },
Elliott Hughese39557c2019-08-05 12:23:07 -0700108 target: {
109 windows: {
110 enabled: true,
111 },
112 },
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +0000113 apex_available: [
114 "com.android.art.release",
115 "com.android.art.debug",
116 ],
Roland Levillaind56de912019-06-20 20:55:26 +0100117}
118
119cc_binary {
120 name: "list_cpu_features",
121 defaults: [
122 "cpu_features-defaults",
123 ],
124 srcs: [
125 "src/utils/list_cpu_features.c",
126 ],
127 static_libs: [
128 "libcpu_features",
129 ],
Roland Levillain61cf9ac2020-09-22 10:52:15 +0100130 arch: {
131 // Function `AddCacheInfo` in `src/utils/list_cpu_features.c` is only used on x86/x86_64 and
132 // triggers an error with `-Werror and `-Wunused-function` on other architectures; disable
133 // the latter flag to avoid compilation errors on those architectures.
134 arm: {
135 cflags: [
136 "-Wno-unused-function",
137 ],
138 },
139 arm64: {
140 cflags: [
141 "-Wno-unused-function",
142 ],
143 },
144 },
Roland Levillaind56de912019-06-20 20:55:26 +0100145}
Roland Levillain18318b62019-06-21 19:56:28 +0100146
Roland Levillain18318b62019-06-21 19:56:28 +0100147// Tests.
148
149cc_defaults {
150 name: "cpu_features-test-defaults",
Roland Levillaindf048ae2019-07-23 18:02:33 +0100151 test_suites: ["device-tests"],
Roland Levillain18318b62019-06-21 19:56:28 +0100152 host_supported: true,
Roland Levillain9ae23c42019-07-24 19:25:53 +0100153 compile_multilib: "both",
Roland Levillain18318b62019-06-21 19:56:28 +0100154 local_include_dirs: [
155 "include",
156 ],
157 cflags: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100158 "-DCPU_FEATURES_TEST",
Roland Levillain18318b62019-06-21 19:56:28 +0100159 ],
160}
161
162cc_test_library {
163 name: "libcpu_features-string_view",
164 defaults: ["cpu_features-test-defaults"],
165 srcs: [
166 "src/string_view.c",
167 ],
168}
169
170cc_test_library {
171 name: "libcpu_features-filesystem_for_testing",
172 defaults: ["cpu_features-test-defaults"],
173 cflags: [
174 "-DCPU_FEATURES_MOCK_FILESYSTEM",
175 // TODO: Handle unused parameters in
176 // test/filesystem_for_testing.cc and remove this flag.
177 "-Wno-unused-parameter",
178 ],
179 srcs: [
180 "test/filesystem_for_testing.cc",
181 ],
182}
183
184cc_test_library {
185 name: "libcpu_features-hwcaps_for_testing",
186 defaults: ["cpu_features-test-defaults"],
187 cflags: [
188 "-DCPU_FEATURES_MOCK_GET_ELF_HWCAP_FROM_GETAUXVAL",
189 ],
190 srcs: [
191 "test/hwcaps_for_testing.cc",
192 ],
193 static_libs: [
194 "libcpu_features-string_view",
195 "libcpu_features-filesystem_for_testing",
196 ],
197}
198
199cc_defaults {
200 name: "stack_line_reader-defaults",
201 cflags: [
202 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
203 ],
204}
205
206cc_test_library {
207 name: "libcpu_features-stack_line_reader",
208 defaults: [
209 "cpu_features-test-defaults",
210 "stack_line_reader-defaults",
211 ],
212 srcs: [
213 "src/stack_line_reader.c",
214 ],
215 static_libs: [
216 "libcpu_features-filesystem_for_testing",
217 "libcpu_features-string_view",
218 ],
219}
220
221cc_test_library {
222 name: "libcpu_features-stack_line_reader_for_test",
223 defaults: ["cpu_features-test-defaults"],
224 cflags: [
225 "-DSTACK_LINE_READER_BUFFER_SIZE=16",
226 ],
227 srcs: [
228 "src/stack_line_reader.c",
229 ],
230 whole_static_libs: [
231 "libcpu_features-filesystem_for_testing",
232 "libcpu_features-string_view",
233 ],
234}
235
236cc_test_library {
237 name: "libcpu_features-all_libraries",
238 defaults: [
239 "cpu_features-test-defaults",
240 "stack_line_reader-defaults",
241 ],
242 srcs: [
243 "src/unix_features_aggregator.c",
244 ],
245 whole_static_libs: [
246 "libcpu_features-filesystem_for_testing",
247 "libcpu_features-hwcaps_for_testing",
248 "libcpu_features-stack_line_reader",
249 "libcpu_features-string_view",
250 ],
251}
252
253cc_test {
254 name: "cpu_features-bit_utils_test",
255 defaults: ["cpu_features-test-defaults"],
256 srcs: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100257 "test/bit_utils_test.cc",
Roland Levillain18318b62019-06-21 19:56:28 +0100258 ],
259}
260
261cc_test {
262 name: "cpu_features-string_view_test",
263 defaults: ["cpu_features-test-defaults"],
264 srcs: [
265 "test/string_view_test.cc",
266 "src/string_view.c",
267 ],
268 static_libs: [
269 "libcpu_features-string_view",
270 ],
271}
272
273cc_test {
274 name: "cpu_features-stack_line_reader_test",
275 defaults: [
276 "cpu_features-test-defaults",
277 "stack_line_reader-defaults",
278 ],
279 cflags: [
280 // TODO: Handle unused funtions in
281 // test/stack_line_reader_test.cc and remove this flag.
282 "-Wno-unused-function",
283 ],
284 srcs: [
285 "test/stack_line_reader_test.cc",
286 ],
287 static_libs: [
288 "libcpu_features-stack_line_reader_for_test",
289 ],
290}
291
292cc_test {
293 name: "cpu_features-unix_features_aggregator_test",
294 defaults: ["cpu_features-test-defaults"],
295 srcs: [
296 "test/unix_features_aggregator_test.cc",
297 ],
298 static_libs: [
299 "libcpu_features-all_libraries",
300 ],
301}
302
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100303cc_test {
304 name: "cpu_features-cpuinfo_test",
305 defaults: [
Roland Levillaind4628f12019-07-24 19:40:34 +0100306 "cpu_features-test-defaults",
307 ],
308 static_libs: [
309 "libcpu_features-all_libraries",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100310 ],
311 arch: {
312 x86: {
313 cflags: [
314 "-DCPU_FEATURES_MOCK_CPUID_X86",
315 "-Wno-unused-variable",
316 ],
317 srcs: [
318 "test/cpuinfo_x86_test.cc",
319 "src/cpuinfo_x86.c",
320 ],
321 },
322 x86_64: {
323 cflags: [
324 "-DCPU_FEATURES_MOCK_CPUID_X86",
325 "-Wno-unused-variable",
326 ],
327 srcs: [
328 "test/cpuinfo_x86_test.cc",
329 "src/cpuinfo_x86.c",
330 ],
331 },
332 arm: {
333 cflags: [
334 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
335 ],
336 srcs: [
337 "test/cpuinfo_arm_test.cc",
338 "src/cpuinfo_arm.c",
339 ],
340 },
341 arm64: {
342 cflags: [
343 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
344 "-Wno-gnu-designator",
345 ],
346 srcs: [
347 "test/cpuinfo_aarch64_test.cc",
348 "src/cpuinfo_aarch64.c",
349 ],
Roland Levillainaa4fc412019-07-24 19:51:11 +0100350 },
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100351 },
352}