blob: e99c6469461a2d77d5ce238c80e00426db3cada3 [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
110
111// Tests.
112
113cc_defaults {
114 name: "cpu_features-test-defaults",
Roland Levillaindf048ae2019-07-23 18:02:33 +0100115 test_suites: ["device-tests"],
Roland Levillain18318b62019-06-21 19:56:28 +0100116 host_supported: true,
117 local_include_dirs: [
118 "include",
119 ],
120 cflags: [
121 "-DCPU_FEATURES_TEST"
122 ],
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: [
220 "test/bit_utils_test.cc"
221 ],
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
266cc_defaults {
267 name: "cpu_features-cpuinfo-test-defaults",
268 defaults: ["cpu_features-test-defaults"],
269 enabled: false,
270 static_libs: [
271 "libcpu_features-all_libraries",
272 ],
273}
274
275cc_test {
276 name: "cpu_features-cpuinfo_x86_test",
277 defaults: ["cpu_features-cpuinfo-test-defaults"],
278 arch: {
279 x86: {
280 enabled: true,
281 },
282 x86_64: {
283 enabled: true,
284 },
285 },
286 target: {
287 windows: {
288 enabled: false,
289 },
290 },
291 cflags: [
292 "-DCPU_FEATURES_MOCK_CPUID_X86",
Haibo Huang2519d752019-07-12 18:21:31 -0700293 "-Wno-unused-variable",
Roland Levillain18318b62019-06-21 19:56:28 +0100294 ],
295 srcs: [
296 "test/cpuinfo_x86_test.cc",
297 "src/cpuinfo_x86.c",
298 ],
299}
300
301cc_test {
302 name: "cpu_features-cpuinfo_arm_test",
303 defaults: [
304 "cpu_features-cpuinfo-test-defaults",
305 "stack_line_reader-defaults",
306 ],
307 arch: {
308 arm: {
309 enabled: true,
310 },
311 },
312 srcs: [
313 "test/cpuinfo_arm_test.cc",
314 "src/cpuinfo_arm.c",
315 ],
316}
317
318cc_test {
319 name: "cpu_features-cpuinfo_aarch64_test",
320 defaults: [
321 "cpu_features-cpuinfo-test-defaults",
322 "stack_line_reader-defaults",
323 ],
324 arch: {
325 arm64: {
326 enabled: true,
327 },
328 },
Haibo Huang2519d752019-07-12 18:21:31 -0700329 cflags: [
330 "-Wno-gnu-designator",
331 ],
Roland Levillain18318b62019-06-21 19:56:28 +0100332 srcs: [
333 "test/cpuinfo_aarch64_test.cc",
334 "src/cpuinfo_aarch64.c",
335 ],
336}