blob: 7f70060955ce01ad37f5c719eecbffd7d80e1f35 [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: [
104 "src/cpuinfo_arm.c",
105 ],
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: [
112 "src/cpuinfo_aarch64.c",
113 ],
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: [
123 "src/cpuinfo_x86.c",
124 ],
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: [
131 "src/cpuinfo_x86.c",
132 ],
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 },
174 },
Roland Levillaind56de912019-06-20 20:55:26 +0100175}
Roland Levillain18318b62019-06-21 19:56:28 +0100176
Roland Levillain18318b62019-06-21 19:56:28 +0100177// Tests.
178
179cc_defaults {
180 name: "cpu_features-test-defaults",
Roland Levillaindf048ae2019-07-23 18:02:33 +0100181 test_suites: ["device-tests"],
Roland Levillain18318b62019-06-21 19:56:28 +0100182 host_supported: true,
Roland Levillain9ae23c42019-07-24 19:25:53 +0100183 compile_multilib: "both",
Roland Levillain18318b62019-06-21 19:56:28 +0100184 local_include_dirs: [
185 "include",
186 ],
187 cflags: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100188 "-DCPU_FEATURES_TEST",
Roland Levillain18318b62019-06-21 19:56:28 +0100189 ],
190}
191
192cc_test_library {
193 name: "libcpu_features-string_view",
194 defaults: ["cpu_features-test-defaults"],
195 srcs: [
196 "src/string_view.c",
197 ],
198}
199
200cc_test_library {
201 name: "libcpu_features-filesystem_for_testing",
202 defaults: ["cpu_features-test-defaults"],
203 cflags: [
204 "-DCPU_FEATURES_MOCK_FILESYSTEM",
205 // TODO: Handle unused parameters in
206 // test/filesystem_for_testing.cc and remove this flag.
207 "-Wno-unused-parameter",
208 ],
209 srcs: [
210 "test/filesystem_for_testing.cc",
211 ],
212}
213
214cc_test_library {
215 name: "libcpu_features-hwcaps_for_testing",
216 defaults: ["cpu_features-test-defaults"],
217 cflags: [
218 "-DCPU_FEATURES_MOCK_GET_ELF_HWCAP_FROM_GETAUXVAL",
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100219 "-DCPU_FEATURES_TEST",
Roland Levillain18318b62019-06-21 19:56:28 +0100220 ],
221 srcs: [
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100222 "src/hwcaps.c",
Roland Levillain18318b62019-06-21 19:56:28 +0100223 "test/hwcaps_for_testing.cc",
224 ],
225 static_libs: [
226 "libcpu_features-string_view",
227 "libcpu_features-filesystem_for_testing",
228 ],
229}
230
231cc_defaults {
232 name: "stack_line_reader-defaults",
233 cflags: [
234 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
235 ],
236}
237
238cc_test_library {
239 name: "libcpu_features-stack_line_reader",
240 defaults: [
241 "cpu_features-test-defaults",
242 "stack_line_reader-defaults",
243 ],
244 srcs: [
245 "src/stack_line_reader.c",
246 ],
247 static_libs: [
248 "libcpu_features-filesystem_for_testing",
249 "libcpu_features-string_view",
250 ],
251}
252
253cc_test_library {
254 name: "libcpu_features-stack_line_reader_for_test",
255 defaults: ["cpu_features-test-defaults"],
256 cflags: [
257 "-DSTACK_LINE_READER_BUFFER_SIZE=16",
258 ],
259 srcs: [
260 "src/stack_line_reader.c",
261 ],
262 whole_static_libs: [
263 "libcpu_features-filesystem_for_testing",
264 "libcpu_features-string_view",
265 ],
266}
267
268cc_test_library {
269 name: "libcpu_features-all_libraries",
270 defaults: [
271 "cpu_features-test-defaults",
272 "stack_line_reader-defaults",
273 ],
Roland Levillain18318b62019-06-21 19:56:28 +0100274 whole_static_libs: [
275 "libcpu_features-filesystem_for_testing",
276 "libcpu_features-hwcaps_for_testing",
277 "libcpu_features-stack_line_reader",
278 "libcpu_features-string_view",
279 ],
280}
281
282cc_test {
283 name: "cpu_features-bit_utils_test",
284 defaults: ["cpu_features-test-defaults"],
285 srcs: [
Roland Levillainaa4fc412019-07-24 19:51:11 +0100286 "test/bit_utils_test.cc",
Roland Levillain18318b62019-06-21 19:56:28 +0100287 ],
288}
289
290cc_test {
291 name: "cpu_features-string_view_test",
292 defaults: ["cpu_features-test-defaults"],
293 srcs: [
294 "test/string_view_test.cc",
295 "src/string_view.c",
296 ],
297 static_libs: [
298 "libcpu_features-string_view",
299 ],
300}
301
302cc_test {
303 name: "cpu_features-stack_line_reader_test",
304 defaults: [
305 "cpu_features-test-defaults",
306 "stack_line_reader-defaults",
307 ],
308 cflags: [
309 // TODO: Handle unused funtions in
310 // test/stack_line_reader_test.cc and remove this flag.
311 "-Wno-unused-function",
312 ],
313 srcs: [
314 "test/stack_line_reader_test.cc",
315 ],
316 static_libs: [
317 "libcpu_features-stack_line_reader_for_test",
318 ],
319}
320
321cc_test {
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100322 name: "cpu_features-cpuinfo_test",
323 defaults: [
Roland Levillaind4628f12019-07-24 19:40:34 +0100324 "cpu_features-test-defaults",
325 ],
326 static_libs: [
327 "libcpu_features-all_libraries",
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100328 ],
Roland Levillain1fb67bc2020-10-15 11:39:30 +0100329 cflags: [
330 "-DSTACK_LINE_READER_BUFFER_SIZE=1024",
331 ],
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100332 arch: {
333 x86: {
334 cflags: [
335 "-DCPU_FEATURES_MOCK_CPUID_X86",
336 "-Wno-unused-variable",
337 ],
338 srcs: [
339 "test/cpuinfo_x86_test.cc",
340 "src/cpuinfo_x86.c",
341 ],
342 },
343 x86_64: {
344 cflags: [
345 "-DCPU_FEATURES_MOCK_CPUID_X86",
346 "-Wno-unused-variable",
347 ],
348 srcs: [
349 "test/cpuinfo_x86_test.cc",
350 "src/cpuinfo_x86.c",
351 ],
352 },
353 arm: {
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100354 srcs: [
355 "test/cpuinfo_arm_test.cc",
356 "src/cpuinfo_arm.c",
357 ],
358 },
359 arm64: {
360 cflags: [
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100361 "-Wno-gnu-designator",
362 ],
363 srcs: [
364 "test/cpuinfo_aarch64_test.cc",
365 "src/cpuinfo_aarch64.c",
366 ],
Roland Levillainaa4fc412019-07-24 19:51:11 +0100367 },
Roland Levillain9f7c24e2019-07-11 20:10:02 +0100368 },
369}