blob: c7569de206cdd0f352926e8b9d8f51dc09db1a4e [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 },
Roland Levillaind56de912019-06-20 20:55:26 +010030}
31
32cc_library {
33 name: "libcpu_features-unix_based_hardware_detection",
34 defaults: ["cpu_features-defaults"],
35 srcs: [
36 "src/hwcaps.c",
37 "src/unix_features_aggregator.c",
38 ],
39 cflags: [
40 "-DHAVE_DLFCN_H",
41 ],
42 target: {
43 bionic: {
44 cflags: [
45 "-DHAVE_STRONG_GETAUXVAL",
46 ],
47 },
48 },
49 static_libs: [
50 "libcpu_features-utils",
51 ],
52}
53
54cc_library {
55 name: "libcpu_features",
56 defaults: [
57 "cpu_features-defaults",
58 ],
Elliott Hughes7f8ace62019-08-05 11:58:18 -070059 export_include_dirs: ["include"],
Roland Levillaind56de912019-06-20 20:55:26 +010060 whole_static_libs: [
61 "libcpu_features-utils",
62 ],
63 arch: {
64 arm: {
65 srcs: [
66 "src/cpuinfo_arm.c",
67 ],
68 whole_static_libs: [
69 "libcpu_features-unix_based_hardware_detection",
70 ],
71 },
72 arm64: {
73 srcs: [
74 "src/cpuinfo_aarch64.c",
75 ],
76 whole_static_libs: [
77 "libcpu_features-unix_based_hardware_detection",
78 ],
Haibo Huang2519d752019-07-12 18:21:31 -070079 cflags: [
80 "-Wno-gnu-designator",
81 ],
Roland Levillaind56de912019-06-20 20:55:26 +010082 },
83 x86: {
84 srcs: [
85 "src/cpuinfo_x86.c",
86 ],
Haibo Huang2519d752019-07-12 18:21:31 -070087 cflags: [
88 "-Wno-unused-variable",
89 ],
Roland Levillaind56de912019-06-20 20:55:26 +010090 },
91 x86_64: {
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 },
Elliott Hughese39557c2019-08-05 12:23:07 -0700100 target: {
101 windows: {
102 enabled: true,
103 },
104 },
Roland Levillaind56de912019-06-20 20:55:26 +0100105}
106
107cc_binary {
108 name: "list_cpu_features",
109 defaults: [
110 "cpu_features-defaults",
111 ],
112 srcs: [
113 "src/utils/list_cpu_features.c",
114 ],
115 static_libs: [
116 "libcpu_features",
117 ],
118}
Roland Levillain18318b62019-06-21 19:56:28 +0100119
Roland Levillain18318b62019-06-21 19:56:28 +0100120// Tests.
121
122cc_defaults {
123 name: "cpu_features-test-defaults",
Roland Levillaindf048ae2019-07-23 18:02:33 +0100124 test_suites: ["device-tests"],
Roland Levillain18318b62019-06-21 19:56:28 +0100125 host_supported: true,
Roland Levillain9ae23c42019-07-24 19:25:53 +0100126 compile_multilib: "both",
Roland Levillain18318b62019-06-21 19:56:28 +0100127 local_include_dirs: [
128 "include",
129 ],
130 cflags: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100131 "-DCPU_FEATURES_TEST",
Roland Levillain18318b62019-06-21 19:56:28 +0100132 ],
133}
134
135cc_test_library {
136 name: "libcpu_features-string_view",
137 defaults: ["cpu_features-test-defaults"],
138 srcs: [
139 "src/string_view.c",
140 ],
141}
142
143cc_test_library {
144 name: "libcpu_features-filesystem_for_testing",
145 defaults: ["cpu_features-test-defaults"],
146 cflags: [
147 "-DCPU_FEATURES_MOCK_FILESYSTEM",
148 // TODO: Handle unused parameters in
149 // test/filesystem_for_testing.cc and remove this flag.
150 "-Wno-unused-parameter",
151 ],
152 srcs: [
153 "test/filesystem_for_testing.cc",
154 ],
155}
156
157cc_test_library {
158 name: "libcpu_features-hwcaps_for_testing",
159 defaults: ["cpu_features-test-defaults"],
160 cflags: [
161 "-DCPU_FEATURES_MOCK_GET_ELF_HWCAP_FROM_GETAUXVAL",
162 ],
163 srcs: [
164 "test/hwcaps_for_testing.cc",
165 ],
166 static_libs: [
167 "libcpu_features-string_view",
168 "libcpu_features-filesystem_for_testing",
169 ],
170}
171
172cc_defaults {
173 name: "stack_line_reader-defaults",
174 cflags: [
175 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
176 ],
177}
178
179cc_test_library {
180 name: "libcpu_features-stack_line_reader",
181 defaults: [
182 "cpu_features-test-defaults",
183 "stack_line_reader-defaults",
184 ],
185 srcs: [
186 "src/stack_line_reader.c",
187 ],
188 static_libs: [
189 "libcpu_features-filesystem_for_testing",
190 "libcpu_features-string_view",
191 ],
192}
193
194cc_test_library {
195 name: "libcpu_features-stack_line_reader_for_test",
196 defaults: ["cpu_features-test-defaults"],
197 cflags: [
198 "-DSTACK_LINE_READER_BUFFER_SIZE=16",
199 ],
200 srcs: [
201 "src/stack_line_reader.c",
202 ],
203 whole_static_libs: [
204 "libcpu_features-filesystem_for_testing",
205 "libcpu_features-string_view",
206 ],
207}
208
209cc_test_library {
210 name: "libcpu_features-all_libraries",
211 defaults: [
212 "cpu_features-test-defaults",
213 "stack_line_reader-defaults",
214 ],
215 srcs: [
216 "src/unix_features_aggregator.c",
217 ],
218 whole_static_libs: [
219 "libcpu_features-filesystem_for_testing",
220 "libcpu_features-hwcaps_for_testing",
221 "libcpu_features-stack_line_reader",
222 "libcpu_features-string_view",
223 ],
224}
225
226cc_test {
227 name: "cpu_features-bit_utils_test",
228 defaults: ["cpu_features-test-defaults"],
229 srcs: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100230 "test/bit_utils_test.cc",
Roland Levillain18318b62019-06-21 19:56:28 +0100231 ],
232}
233
234cc_test {
235 name: "cpu_features-string_view_test",
236 defaults: ["cpu_features-test-defaults"],
237 srcs: [
238 "test/string_view_test.cc",
239 "src/string_view.c",
240 ],
241 static_libs: [
242 "libcpu_features-string_view",
243 ],
244}
245
246cc_test {
247 name: "cpu_features-stack_line_reader_test",
248 defaults: [
249 "cpu_features-test-defaults",
250 "stack_line_reader-defaults",
251 ],
252 cflags: [
253 // TODO: Handle unused funtions in
254 // test/stack_line_reader_test.cc and remove this flag.
255 "-Wno-unused-function",
256 ],
257 srcs: [
258 "test/stack_line_reader_test.cc",
259 ],
260 static_libs: [
261 "libcpu_features-stack_line_reader_for_test",
262 ],
263}
264
265cc_test {
266 name: "cpu_features-unix_features_aggregator_test",
267 defaults: ["cpu_features-test-defaults"],
268 srcs: [
269 "test/unix_features_aggregator_test.cc",
270 ],
271 static_libs: [
272 "libcpu_features-all_libraries",
273 ],
274}
275
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100276cc_test {
277 name: "cpu_features-cpuinfo_test",
278 defaults: [
Roland Levillaind4628f12019-07-24 19:40:34 +0100279 "cpu_features-test-defaults",
280 ],
281 static_libs: [
282 "libcpu_features-all_libraries",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100283 ],
284 arch: {
285 x86: {
286 cflags: [
287 "-DCPU_FEATURES_MOCK_CPUID_X86",
288 "-Wno-unused-variable",
289 ],
290 srcs: [
291 "test/cpuinfo_x86_test.cc",
292 "src/cpuinfo_x86.c",
293 ],
294 },
295 x86_64: {
296 cflags: [
297 "-DCPU_FEATURES_MOCK_CPUID_X86",
298 "-Wno-unused-variable",
299 ],
300 srcs: [
301 "test/cpuinfo_x86_test.cc",
302 "src/cpuinfo_x86.c",
303 ],
304 },
305 arm: {
306 cflags: [
307 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
308 ],
309 srcs: [
310 "test/cpuinfo_arm_test.cc",
311 "src/cpuinfo_arm.c",
312 ],
313 },
314 arm64: {
315 cflags: [
316 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
317 "-Wno-gnu-designator",
318 ],
319 srcs: [
320 "test/cpuinfo_aarch64_test.cc",
321 "src/cpuinfo_aarch64.c",
322 ],
Roland Levillainaa4fc412019-07-24 19:51:11 +0100323 },
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100324 },
325}