blob: 79a3a29e58986d5a1207aa9f508686db9c6d20c2 [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",
9 "include/internal",
10 ],
11 cflags: [
12 // Reserve 1024 bytes on the stack when reading from `/proc/cpuinfo`.
13 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
Haibo Huang2519d752019-07-12 18:21:31 -070014 "-Wno-gnu-designator",
Roland Levillaind56de912019-06-20 20:55:26 +010015 ],
16}
17
18cc_library {
19 name: "libcpu_features-utils",
20 defaults: ["cpu_features-defaults"],
21 srcs: [
22 "src/filesystem.c",
23 "src/stack_line_reader.c",
24 "src/string_view.c",
25 ],
26}
27
28cc_library {
29 name: "libcpu_features-unix_based_hardware_detection",
30 defaults: ["cpu_features-defaults"],
31 srcs: [
32 "src/hwcaps.c",
33 "src/unix_features_aggregator.c",
34 ],
35 cflags: [
36 "-DHAVE_DLFCN_H",
37 ],
38 target: {
39 bionic: {
40 cflags: [
41 "-DHAVE_STRONG_GETAUXVAL",
42 ],
43 },
44 },
45 static_libs: [
46 "libcpu_features-utils",
47 ],
48}
49
50cc_library {
51 name: "libcpu_features",
52 defaults: [
53 "cpu_features-defaults",
54 ],
55 whole_static_libs: [
56 "libcpu_features-utils",
57 ],
58 arch: {
59 arm: {
60 srcs: [
61 "src/cpuinfo_arm.c",
62 ],
63 whole_static_libs: [
64 "libcpu_features-unix_based_hardware_detection",
65 ],
66 },
67 arm64: {
68 srcs: [
69 "src/cpuinfo_aarch64.c",
70 ],
71 whole_static_libs: [
72 "libcpu_features-unix_based_hardware_detection",
73 ],
Haibo Huang2519d752019-07-12 18:21:31 -070074 cflags: [
75 "-Wno-gnu-designator",
76 ],
Roland Levillaind56de912019-06-20 20:55:26 +010077 },
78 x86: {
79 srcs: [
80 "src/cpuinfo_x86.c",
81 ],
Haibo Huang2519d752019-07-12 18:21:31 -070082 cflags: [
83 "-Wno-unused-variable",
84 ],
Roland Levillaind56de912019-06-20 20:55:26 +010085 },
86 x86_64: {
87 srcs: [
88 "src/cpuinfo_x86.c",
89 ],
Haibo Huang2519d752019-07-12 18:21:31 -070090 cflags: [
91 "-Wno-unused-variable",
92 ],
Roland Levillaind56de912019-06-20 20:55:26 +010093 },
94 },
95}
96
97cc_binary {
98 name: "list_cpu_features",
99 defaults: [
100 "cpu_features-defaults",
101 ],
102 srcs: [
103 "src/utils/list_cpu_features.c",
104 ],
105 static_libs: [
106 "libcpu_features",
107 ],
108}
Roland Levillain18318b62019-06-21 19:56:28 +0100109
Roland Levillain18318b62019-06-21 19:56:28 +0100110// Tests.
111
112cc_defaults {
113 name: "cpu_features-test-defaults",
Roland Levillaindf048ae2019-07-23 18:02:33 +0100114 test_suites: ["device-tests"],
Roland Levillain18318b62019-06-21 19:56:28 +0100115 host_supported: true,
Roland Levillain9ae23c42019-07-24 19:25:53 +0100116 compile_multilib: "both",
Roland Levillain18318b62019-06-21 19:56:28 +0100117 local_include_dirs: [
118 "include",
119 ],
120 cflags: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100121 "-DCPU_FEATURES_TEST",
Roland Levillain18318b62019-06-21 19:56:28 +0100122 ],
123}
124
125cc_test_library {
126 name: "libcpu_features-string_view",
127 defaults: ["cpu_features-test-defaults"],
128 srcs: [
129 "src/string_view.c",
130 ],
131}
132
133cc_test_library {
134 name: "libcpu_features-filesystem_for_testing",
135 defaults: ["cpu_features-test-defaults"],
136 cflags: [
137 "-DCPU_FEATURES_MOCK_FILESYSTEM",
138 // TODO: Handle unused parameters in
139 // test/filesystem_for_testing.cc and remove this flag.
140 "-Wno-unused-parameter",
141 ],
142 srcs: [
143 "test/filesystem_for_testing.cc",
144 ],
145}
146
147cc_test_library {
148 name: "libcpu_features-hwcaps_for_testing",
149 defaults: ["cpu_features-test-defaults"],
150 cflags: [
151 "-DCPU_FEATURES_MOCK_GET_ELF_HWCAP_FROM_GETAUXVAL",
152 ],
153 srcs: [
154 "test/hwcaps_for_testing.cc",
155 ],
156 static_libs: [
157 "libcpu_features-string_view",
158 "libcpu_features-filesystem_for_testing",
159 ],
160}
161
162cc_defaults {
163 name: "stack_line_reader-defaults",
164 cflags: [
165 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
166 ],
167}
168
169cc_test_library {
170 name: "libcpu_features-stack_line_reader",
171 defaults: [
172 "cpu_features-test-defaults",
173 "stack_line_reader-defaults",
174 ],
175 srcs: [
176 "src/stack_line_reader.c",
177 ],
178 static_libs: [
179 "libcpu_features-filesystem_for_testing",
180 "libcpu_features-string_view",
181 ],
182}
183
184cc_test_library {
185 name: "libcpu_features-stack_line_reader_for_test",
186 defaults: ["cpu_features-test-defaults"],
187 cflags: [
188 "-DSTACK_LINE_READER_BUFFER_SIZE=16",
189 ],
190 srcs: [
191 "src/stack_line_reader.c",
192 ],
193 whole_static_libs: [
194 "libcpu_features-filesystem_for_testing",
195 "libcpu_features-string_view",
196 ],
197}
198
199cc_test_library {
200 name: "libcpu_features-all_libraries",
201 defaults: [
202 "cpu_features-test-defaults",
203 "stack_line_reader-defaults",
204 ],
205 srcs: [
206 "src/unix_features_aggregator.c",
207 ],
208 whole_static_libs: [
209 "libcpu_features-filesystem_for_testing",
210 "libcpu_features-hwcaps_for_testing",
211 "libcpu_features-stack_line_reader",
212 "libcpu_features-string_view",
213 ],
214}
215
216cc_test {
217 name: "cpu_features-bit_utils_test",
218 defaults: ["cpu_features-test-defaults"],
219 srcs: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100220 "test/bit_utils_test.cc",
Roland Levillain18318b62019-06-21 19:56:28 +0100221 ],
222}
223
224cc_test {
225 name: "cpu_features-string_view_test",
226 defaults: ["cpu_features-test-defaults"],
227 srcs: [
228 "test/string_view_test.cc",
229 "src/string_view.c",
230 ],
231 static_libs: [
232 "libcpu_features-string_view",
233 ],
234}
235
236cc_test {
237 name: "cpu_features-stack_line_reader_test",
238 defaults: [
239 "cpu_features-test-defaults",
240 "stack_line_reader-defaults",
241 ],
242 cflags: [
243 // TODO: Handle unused funtions in
244 // test/stack_line_reader_test.cc and remove this flag.
245 "-Wno-unused-function",
246 ],
247 srcs: [
248 "test/stack_line_reader_test.cc",
249 ],
250 static_libs: [
251 "libcpu_features-stack_line_reader_for_test",
252 ],
253}
254
255cc_test {
256 name: "cpu_features-unix_features_aggregator_test",
257 defaults: ["cpu_features-test-defaults"],
258 srcs: [
259 "test/unix_features_aggregator_test.cc",
260 ],
261 static_libs: [
262 "libcpu_features-all_libraries",
263 ],
264}
265
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100266cc_test {
267 name: "cpu_features-cpuinfo_test",
268 defaults: [
Roland Levillaind4628f12019-07-24 19:40:34 +0100269 "cpu_features-test-defaults",
270 ],
271 static_libs: [
272 "libcpu_features-all_libraries",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100273 ],
274 arch: {
275 x86: {
276 cflags: [
277 "-DCPU_FEATURES_MOCK_CPUID_X86",
278 "-Wno-unused-variable",
279 ],
280 srcs: [
281 "test/cpuinfo_x86_test.cc",
282 "src/cpuinfo_x86.c",
283 ],
284 },
285 x86_64: {
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 arm: {
296 cflags: [
297 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
298 ],
299 srcs: [
300 "test/cpuinfo_arm_test.cc",
301 "src/cpuinfo_arm.c",
302 ],
303 },
304 arm64: {
305 cflags: [
306 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
307 "-Wno-gnu-designator",
308 ],
309 srcs: [
310 "test/cpuinfo_aarch64_test.cc",
311 "src/cpuinfo_aarch64.c",
312 ],
Roland Levillainaa4fc412019-07-24 19:51:11 +0100313 },
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100314 },
315}