Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 1 | // This Blueprint file loosely follows the logic of cpu_features' |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 2 | // CMakeLists.txt and test/CMakeLists.txt files. |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 3 | |
Bob Badour | a4f5346 | 2021-02-12 20:13:04 -0800 | [diff] [blame] | 4 | package { |
| 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 |
| 22 | license { |
| 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 Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 34 | cc_defaults { |
| 35 | name: "cpu_features-defaults", |
| 36 | host_supported: true, |
| 37 | local_include_dirs: [ |
| 38 | "include", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 39 | ], |
| 40 | cflags: [ |
| 41 | // Reserve 1024 bytes on the stack when reading from `/proc/cpuinfo`. |
| 42 | "-DSTACK_LINE_READER_BUFFER_SIZE=1024", |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 43 | "-Wno-gnu-designator", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 44 | ], |
Nicolas Geoffray | 428dbe5 | 2021-03-03 22:03:16 +0000 | [diff] [blame] | 45 | min_sdk_version: "S", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | cc_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 Hughes | e39557c | 2019-08-05 12:23:07 -0700 | [diff] [blame] | 56 | target: { |
| 57 | windows: { |
| 58 | enabled: true, |
| 59 | }, |
| 60 | }, |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame] | 61 | apex_available: [ |
Martin Stjernholm | 4da49af | 2020-10-12 15:10:40 +0100 | [diff] [blame] | 62 | "com.android.art", |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame] | 63 | "com.android.art.debug", |
| 64 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | cc_library { |
Roland Levillain | 1fb67bc | 2020-10-15 11:39:30 +0100 | [diff] [blame] | 68 | name: "libcpu_features-hwcaps", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 69 | defaults: ["cpu_features-defaults"], |
| 70 | srcs: [ |
| 71 | "src/hwcaps.c", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 72 | ], |
| 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 Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame] | 86 | apex_available: [ |
Martin Stjernholm | 4da49af | 2020-10-12 15:10:40 +0100 | [diff] [blame] | 87 | "com.android.art", |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame] | 88 | "com.android.art.debug", |
| 89 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | cc_library { |
| 93 | name: "libcpu_features", |
| 94 | defaults: [ |
| 95 | "cpu_features-defaults", |
| 96 | ], |
Elliott Hughes | 7f8ace6 | 2019-08-05 11:58:18 -0700 | [diff] [blame] | 97 | export_include_dirs: ["include"], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 98 | whole_static_libs: [ |
| 99 | "libcpu_features-utils", |
| 100 | ], |
| 101 | arch: { |
| 102 | arm: { |
| 103 | srcs: [ |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 104 | "src/impl_arm_linux_or_android.c", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 105 | ], |
| 106 | whole_static_libs: [ |
Roland Levillain | 1fb67bc | 2020-10-15 11:39:30 +0100 | [diff] [blame] | 107 | "libcpu_features-hwcaps", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 108 | ], |
| 109 | }, |
| 110 | arm64: { |
| 111 | srcs: [ |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 112 | "src/impl_aarch64_linux_or_android.c", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 113 | ], |
| 114 | whole_static_libs: [ |
Roland Levillain | 1fb67bc | 2020-10-15 11:39:30 +0100 | [diff] [blame] | 115 | "libcpu_features-hwcaps", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 116 | ], |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 117 | cflags: [ |
| 118 | "-Wno-gnu-designator", |
| 119 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 120 | }, |
| 121 | x86: { |
| 122 | srcs: [ |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 123 | "src/impl_x86_linux_or_android.c", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 124 | ], |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 125 | cflags: [ |
| 126 | "-Wno-unused-variable", |
| 127 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 128 | }, |
| 129 | x86_64: { |
| 130 | srcs: [ |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 131 | "src/impl_x86_linux_or_android.c", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 132 | ], |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 133 | cflags: [ |
| 134 | "-Wno-unused-variable", |
| 135 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 136 | }, |
| 137 | }, |
Elliott Hughes | e39557c | 2019-08-05 12:23:07 -0700 | [diff] [blame] | 138 | target: { |
| 139 | windows: { |
| 140 | enabled: true, |
| 141 | }, |
| 142 | }, |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame] | 143 | apex_available: [ |
Martin Stjernholm | 4da49af | 2020-10-12 15:10:40 +0100 | [diff] [blame] | 144 | "com.android.art", |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame] | 145 | "com.android.art.debug", |
| 146 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | cc_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 Levillain | 61cf9ac | 2020-09-22 10:52:15 +0100 | [diff] [blame] | 160 | 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 Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 174 | x86: { |
| 175 | cflags: [ |
| 176 | "-Wno-deprecated-declarations", |
| 177 | ], |
| 178 | }, |
| 179 | x86_64: { |
| 180 | cflags: [ |
| 181 | "-Wno-deprecated-declarations", |
| 182 | ], |
| 183 | }, |
Roland Levillain | 61cf9ac | 2020-09-22 10:52:15 +0100 | [diff] [blame] | 184 | }, |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 185 | } |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 186 | |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 187 | // Tests. |
| 188 | |
| 189 | cc_defaults { |
| 190 | name: "cpu_features-test-defaults", |
Roland Levillain | df048ae | 2019-07-23 18:02:33 +0100 | [diff] [blame] | 191 | test_suites: ["device-tests"], |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 192 | host_supported: true, |
Roland Levillain | 9ae23c4 | 2019-07-24 19:25:53 +0100 | [diff] [blame] | 193 | compile_multilib: "both", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 194 | local_include_dirs: [ |
| 195 | "include", |
| 196 | ], |
| 197 | cflags: [ |
Roland Levillain | aa4fc41 | 2019-07-24 19:51:11 +0100 | [diff] [blame] | 198 | "-DCPU_FEATURES_TEST", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 199 | ], |
| 200 | } |
| 201 | |
| 202 | cc_test_library { |
| 203 | name: "libcpu_features-string_view", |
| 204 | defaults: ["cpu_features-test-defaults"], |
| 205 | srcs: [ |
| 206 | "src/string_view.c", |
| 207 | ], |
| 208 | } |
| 209 | |
| 210 | cc_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 | |
| 224 | cc_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 Levillain | 1fb67bc | 2020-10-15 11:39:30 +0100 | [diff] [blame] | 229 | "-DCPU_FEATURES_TEST", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 230 | ], |
| 231 | srcs: [ |
Roland Levillain | 1fb67bc | 2020-10-15 11:39:30 +0100 | [diff] [blame] | 232 | "src/hwcaps.c", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 233 | "test/hwcaps_for_testing.cc", |
| 234 | ], |
| 235 | static_libs: [ |
| 236 | "libcpu_features-string_view", |
| 237 | "libcpu_features-filesystem_for_testing", |
| 238 | ], |
| 239 | } |
| 240 | |
| 241 | cc_defaults { |
| 242 | name: "stack_line_reader-defaults", |
| 243 | cflags: [ |
| 244 | "-DSTACK_LINE_READER_BUFFER_SIZE=1024", |
| 245 | ], |
| 246 | } |
| 247 | |
| 248 | cc_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 | |
| 263 | cc_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 | |
| 278 | cc_test_library { |
| 279 | name: "libcpu_features-all_libraries", |
| 280 | defaults: [ |
| 281 | "cpu_features-test-defaults", |
| 282 | "stack_line_reader-defaults", |
| 283 | ], |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 284 | 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 | |
| 292 | cc_test { |
| 293 | name: "cpu_features-bit_utils_test", |
| 294 | defaults: ["cpu_features-test-defaults"], |
| 295 | srcs: [ |
Roland Levillain | aa4fc41 | 2019-07-24 19:51:11 +0100 | [diff] [blame] | 296 | "test/bit_utils_test.cc", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 297 | ], |
| 298 | } |
| 299 | |
| 300 | cc_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 | |
| 312 | cc_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 | |
| 331 | cc_test { |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 332 | name: "cpu_features-cpuinfo_test", |
| 333 | defaults: [ |
Roland Levillain | d4628f1 | 2019-07-24 19:40:34 +0100 | [diff] [blame] | 334 | "cpu_features-test-defaults", |
| 335 | ], |
| 336 | static_libs: [ |
| 337 | "libcpu_features-all_libraries", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 338 | ], |
Roland Levillain | 1fb67bc | 2020-10-15 11:39:30 +0100 | [diff] [blame] | 339 | cflags: [ |
| 340 | "-DSTACK_LINE_READER_BUFFER_SIZE=1024", |
| 341 | ], |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 342 | arch: { |
| 343 | x86: { |
| 344 | cflags: [ |
| 345 | "-DCPU_FEATURES_MOCK_CPUID_X86", |
| 346 | "-Wno-unused-variable", |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 347 | "-Wno-deprecated-declarations", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 348 | ], |
| 349 | srcs: [ |
| 350 | "test/cpuinfo_x86_test.cc", |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 351 | "src/impl_x86_linux_or_android.c", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 352 | ], |
| 353 | }, |
| 354 | x86_64: { |
| 355 | cflags: [ |
| 356 | "-DCPU_FEATURES_MOCK_CPUID_X86", |
| 357 | "-Wno-unused-variable", |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 358 | "-Wno-deprecated-declarations", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 359 | ], |
| 360 | srcs: [ |
| 361 | "test/cpuinfo_x86_test.cc", |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 362 | "src/impl_x86_linux_or_android.c", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 363 | ], |
| 364 | }, |
| 365 | arm: { |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 366 | srcs: [ |
| 367 | "test/cpuinfo_arm_test.cc", |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 368 | "src/impl_arm_linux_or_android.c", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 369 | ], |
| 370 | }, |
| 371 | arm64: { |
| 372 | cflags: [ |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 373 | "-Wno-gnu-designator", |
| 374 | ], |
| 375 | srcs: [ |
| 376 | "test/cpuinfo_aarch64_test.cc", |
Roland Levillain | 47bd186 | 2022-07-19 13:22:06 +0100 | [diff] [blame] | 377 | "src/impl_aarch64_linux_or_android.c", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 378 | ], |
Roland Levillain | aa4fc41 | 2019-07-24 19:51:11 +0100 | [diff] [blame] | 379 | }, |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 380 | }, |
| 381 | } |