blob: 57e3804f7ea46625c1b467beef306a23fceffa99 [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
Bob Badoura4f53462021-02-12 20:13:04 -08004package {
5 default_applicable_licenses: ["external_cpu_features_license"],
6}
7
8// Added automatically by a large-scale-change that took the approach of
9// 'apply every license found to every target'. While this makes sure we respect
10// every license restriction, it may not be entirely correct.
11//
12// e.g. GPL in an MIT project might only apply to the contrib/ directory.
13//
14// Please consider splitting the single license below into multiple licenses,
15// taking care not to lose any license_kind information, and overriding the
16// default license using the 'licenses: [...]' property on targets as needed.
17//
18// For unused files, consider creating a 'fileGroup' with "//visibility:private"
19// to attach the license to, and including a comment whether the files may be
20// used in the current project.
21// See: http://go/android-license-faq
22license {
23 name: "external_cpu_features_license",
24 visibility: [":__subpackages__"],
25 license_kinds: [
26 "SPDX-license-identifier-Apache-2.0",
27 "SPDX-license-identifier-BSD",
28 ],
29 license_text: [
30 "LICENSE",
31 ],
32}
33
Roland Levillaind56de912019-06-20 20:55:26 +010034cc_defaults {
35 name: "cpu_features-defaults",
36 host_supported: true,
37 local_include_dirs: [
38 "include",
Roland Levillaind56de912019-06-20 20:55:26 +010039 ],
40 cflags: [
41 // Reserve 1024 bytes on the stack when reading from `/proc/cpuinfo`.
42 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
Haibo Huang2519d752019-07-12 18:21:31 -070043 "-Wno-gnu-designator",
Roland Levillaind56de912019-06-20 20:55:26 +010044 ],
Nicolas Geoffray428dbe52021-03-03 22:03:16 +000045 min_sdk_version: "S",
Roland Levillaind56de912019-06-20 20:55:26 +010046}
47
48cc_library {
49 name: "libcpu_features-utils",
50 defaults: ["cpu_features-defaults"],
51 srcs: [
52 "src/filesystem.c",
53 "src/stack_line_reader.c",
54 "src/string_view.c",
55 ],
Elliott Hughese39557c2019-08-05 12:23:07 -070056 target: {
57 windows: {
58 enabled: true,
59 },
60 },
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +000061 apex_available: [
Martin Stjernholm4da49af2020-10-12 15:10:40 +010062 "com.android.art",
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +000063 "com.android.art.debug",
64 ],
Roland Levillaind56de912019-06-20 20:55:26 +010065}
66
67cc_library {
Roland Levillain1fb67bc2020-10-15 11:39:30 +010068 name: "libcpu_features-hwcaps",
Roland Levillaind56de912019-06-20 20:55:26 +010069 defaults: ["cpu_features-defaults"],
70 srcs: [
71 "src/hwcaps.c",
Roland Levillaind56de912019-06-20 20:55:26 +010072 ],
73 cflags: [
74 "-DHAVE_DLFCN_H",
75 ],
76 target: {
77 bionic: {
78 cflags: [
79 "-DHAVE_STRONG_GETAUXVAL",
80 ],
81 },
82 },
83 static_libs: [
84 "libcpu_features-utils",
85 ],
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +000086 apex_available: [
Martin Stjernholm4da49af2020-10-12 15:10:40 +010087 "com.android.art",
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +000088 "com.android.art.debug",
89 ],
Roland Levillaind56de912019-06-20 20:55:26 +010090}
91
92cc_library {
93 name: "libcpu_features",
94 defaults: [
95 "cpu_features-defaults",
96 ],
Elliott Hughes7f8ace62019-08-05 11:58:18 -070097 export_include_dirs: ["include"],
Roland Levillaind56de912019-06-20 20:55:26 +010098 whole_static_libs: [
99 "libcpu_features-utils",
100 ],
101 arch: {
102 arm: {
103 srcs: [
Roland Levillain47bd1862022-07-19 13:22:06 +0100104 "src/impl_arm_linux_or_android.c",
Roland Levillaind56de912019-06-20 20:55:26 +0100105 ],
106 whole_static_libs: [
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100107 "libcpu_features-hwcaps",
Roland Levillaind56de912019-06-20 20:55:26 +0100108 ],
109 },
110 arm64: {
111 srcs: [
Roland Levillain47bd1862022-07-19 13:22:06 +0100112 "src/impl_aarch64_linux_or_android.c",
Roland Levillaind56de912019-06-20 20:55:26 +0100113 ],
114 whole_static_libs: [
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100115 "libcpu_features-hwcaps",
Roland Levillaind56de912019-06-20 20:55:26 +0100116 ],
Haibo Huang2519d752019-07-12 18:21:31 -0700117 cflags: [
118 "-Wno-gnu-designator",
119 ],
Roland Levillaind56de912019-06-20 20:55:26 +0100120 },
121 x86: {
122 srcs: [
Roland Levillain47bd1862022-07-19 13:22:06 +0100123 "src/impl_x86_linux_or_android.c",
Roland Levillaind56de912019-06-20 20:55:26 +0100124 ],
Haibo Huang2519d752019-07-12 18:21:31 -0700125 cflags: [
126 "-Wno-unused-variable",
127 ],
Roland Levillaind56de912019-06-20 20:55:26 +0100128 },
129 x86_64: {
130 srcs: [
Roland Levillain47bd1862022-07-19 13:22:06 +0100131 "src/impl_x86_linux_or_android.c",
Roland Levillaind56de912019-06-20 20:55:26 +0100132 ],
Haibo Huang2519d752019-07-12 18:21:31 -0700133 cflags: [
134 "-Wno-unused-variable",
135 ],
Roland Levillaind56de912019-06-20 20:55:26 +0100136 },
137 },
Elliott Hughese39557c2019-08-05 12:23:07 -0700138 target: {
139 windows: {
140 enabled: true,
141 },
142 },
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +0000143 apex_available: [
Martin Stjernholm4da49af2020-10-12 15:10:40 +0100144 "com.android.art",
Daniil Riazanovskiy4ffcbab2020-09-16 09:55:32 +0000145 "com.android.art.debug",
146 ],
Roland Levillaind56de912019-06-20 20:55:26 +0100147}
148
149cc_binary {
150 name: "list_cpu_features",
151 defaults: [
152 "cpu_features-defaults",
153 ],
154 srcs: [
155 "src/utils/list_cpu_features.c",
156 ],
157 static_libs: [
158 "libcpu_features",
159 ],
Roland Levillain61cf9ac2020-09-22 10:52:15 +0100160 arch: {
161 // Function `AddCacheInfo` in `src/utils/list_cpu_features.c` is only used on x86/x86_64 and
162 // triggers an error with `-Werror and `-Wunused-function` on other architectures; disable
163 // the latter flag to avoid compilation errors on those architectures.
164 arm: {
165 cflags: [
166 "-Wno-unused-function",
167 ],
168 },
169 arm64: {
170 cflags: [
171 "-Wno-unused-function",
172 ],
173 },
Roland Levillain47bd1862022-07-19 13:22:06 +0100174 x86: {
175 cflags: [
176 "-Wno-deprecated-declarations",
177 ],
178 },
179 x86_64: {
180 cflags: [
181 "-Wno-deprecated-declarations",
182 ],
183 },
Roland Levillain61cf9ac2020-09-22 10:52:15 +0100184 },
Roland Levillaind56de912019-06-20 20:55:26 +0100185}
Roland Levillain18318b62019-06-21 19:56:28 +0100186
Roland Levillain18318b62019-06-21 19:56:28 +0100187// Tests.
188
189cc_defaults {
190 name: "cpu_features-test-defaults",
Roland Levillaindf048ae2019-07-23 18:02:33 +0100191 test_suites: ["device-tests"],
Roland Levillain18318b62019-06-21 19:56:28 +0100192 host_supported: true,
Roland Levillain9ae23c42019-07-24 19:25:53 +0100193 compile_multilib: "both",
Roland Levillain18318b62019-06-21 19:56:28 +0100194 local_include_dirs: [
195 "include",
196 ],
197 cflags: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100198 "-DCPU_FEATURES_TEST",
Roland Levillain18318b62019-06-21 19:56:28 +0100199 ],
200}
201
202cc_test_library {
203 name: "libcpu_features-string_view",
204 defaults: ["cpu_features-test-defaults"],
205 srcs: [
206 "src/string_view.c",
207 ],
208}
209
210cc_test_library {
211 name: "libcpu_features-filesystem_for_testing",
212 defaults: ["cpu_features-test-defaults"],
213 cflags: [
214 "-DCPU_FEATURES_MOCK_FILESYSTEM",
215 // TODO: Handle unused parameters in
216 // test/filesystem_for_testing.cc and remove this flag.
217 "-Wno-unused-parameter",
218 ],
219 srcs: [
220 "test/filesystem_for_testing.cc",
221 ],
222}
223
224cc_test_library {
225 name: "libcpu_features-hwcaps_for_testing",
226 defaults: ["cpu_features-test-defaults"],
227 cflags: [
228 "-DCPU_FEATURES_MOCK_GET_ELF_HWCAP_FROM_GETAUXVAL",
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100229 "-DCPU_FEATURES_TEST",
Roland Levillain18318b62019-06-21 19:56:28 +0100230 ],
231 srcs: [
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100232 "src/hwcaps.c",
Roland Levillain18318b62019-06-21 19:56:28 +0100233 "test/hwcaps_for_testing.cc",
234 ],
235 static_libs: [
236 "libcpu_features-string_view",
237 "libcpu_features-filesystem_for_testing",
238 ],
239}
240
241cc_defaults {
242 name: "stack_line_reader-defaults",
243 cflags: [
244 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
245 ],
246}
247
248cc_test_library {
249 name: "libcpu_features-stack_line_reader",
250 defaults: [
251 "cpu_features-test-defaults",
252 "stack_line_reader-defaults",
253 ],
254 srcs: [
255 "src/stack_line_reader.c",
256 ],
257 static_libs: [
258 "libcpu_features-filesystem_for_testing",
259 "libcpu_features-string_view",
260 ],
261}
262
263cc_test_library {
264 name: "libcpu_features-stack_line_reader_for_test",
265 defaults: ["cpu_features-test-defaults"],
266 cflags: [
267 "-DSTACK_LINE_READER_BUFFER_SIZE=16",
268 ],
269 srcs: [
270 "src/stack_line_reader.c",
271 ],
272 whole_static_libs: [
273 "libcpu_features-filesystem_for_testing",
274 "libcpu_features-string_view",
275 ],
276}
277
278cc_test_library {
279 name: "libcpu_features-all_libraries",
280 defaults: [
281 "cpu_features-test-defaults",
282 "stack_line_reader-defaults",
283 ],
Roland Levillain18318b62019-06-21 19:56:28 +0100284 whole_static_libs: [
285 "libcpu_features-filesystem_for_testing",
286 "libcpu_features-hwcaps_for_testing",
287 "libcpu_features-stack_line_reader",
288 "libcpu_features-string_view",
289 ],
290}
291
292cc_test {
293 name: "cpu_features-bit_utils_test",
294 defaults: ["cpu_features-test-defaults"],
295 srcs: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100296 "test/bit_utils_test.cc",
Roland Levillain18318b62019-06-21 19:56:28 +0100297 ],
298}
299
300cc_test {
301 name: "cpu_features-string_view_test",
302 defaults: ["cpu_features-test-defaults"],
303 srcs: [
304 "test/string_view_test.cc",
305 "src/string_view.c",
306 ],
307 static_libs: [
308 "libcpu_features-string_view",
309 ],
310}
311
312cc_test {
313 name: "cpu_features-stack_line_reader_test",
314 defaults: [
315 "cpu_features-test-defaults",
316 "stack_line_reader-defaults",
317 ],
318 cflags: [
319 // TODO: Handle unused funtions in
320 // test/stack_line_reader_test.cc and remove this flag.
321 "-Wno-unused-function",
322 ],
323 srcs: [
324 "test/stack_line_reader_test.cc",
325 ],
326 static_libs: [
327 "libcpu_features-stack_line_reader_for_test",
328 ],
329}
330
331cc_test {
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100332 name: "cpu_features-cpuinfo_test",
333 defaults: [
Roland Levillaind4628f12019-07-24 19:40:34 +0100334 "cpu_features-test-defaults",
335 ],
336 static_libs: [
337 "libcpu_features-all_libraries",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100338 ],
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100339 cflags: [
340 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
341 ],
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100342 arch: {
343 x86: {
344 cflags: [
345 "-DCPU_FEATURES_MOCK_CPUID_X86",
346 "-Wno-unused-variable",
Roland Levillain47bd1862022-07-19 13:22:06 +0100347 "-Wno-deprecated-declarations",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100348 ],
349 srcs: [
350 "test/cpuinfo_x86_test.cc",
Roland Levillain47bd1862022-07-19 13:22:06 +0100351 "src/impl_x86_linux_or_android.c",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100352 ],
353 },
354 x86_64: {
355 cflags: [
356 "-DCPU_FEATURES_MOCK_CPUID_X86",
357 "-Wno-unused-variable",
Roland Levillain47bd1862022-07-19 13:22:06 +0100358 "-Wno-deprecated-declarations",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100359 ],
360 srcs: [
361 "test/cpuinfo_x86_test.cc",
Roland Levillain47bd1862022-07-19 13:22:06 +0100362 "src/impl_x86_linux_or_android.c",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100363 ],
364 },
365 arm: {
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100366 srcs: [
367 "test/cpuinfo_arm_test.cc",
Roland Levillain47bd1862022-07-19 13:22:06 +0100368 "src/impl_arm_linux_or_android.c",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100369 ],
370 },
371 arm64: {
372 cflags: [
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100373 "-Wno-gnu-designator",
374 ],
375 srcs: [
376 "test/cpuinfo_aarch64_test.cc",
Roland Levillain47bd1862022-07-19 13:22:06 +0100377 "src/impl_aarch64_linux_or_android.c",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100378 ],
Roland Levillainaa4fc412019-07-24 19:51:11 +0100379 },
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100380 },
381}