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 | |
| 4 | cc_defaults { |
| 5 | name: "cpu_features-defaults", |
| 6 | host_supported: true, |
| 7 | local_include_dirs: [ |
| 8 | "include", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 9 | ], |
| 10 | cflags: [ |
| 11 | // Reserve 1024 bytes on the stack when reading from `/proc/cpuinfo`. |
| 12 | "-DSTACK_LINE_READER_BUFFER_SIZE=1024", |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 13 | "-Wno-gnu-designator", |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 14 | ], |
| 15 | } |
| 16 | |
| 17 | cc_library { |
| 18 | name: "libcpu_features-utils", |
| 19 | defaults: ["cpu_features-defaults"], |
| 20 | srcs: [ |
| 21 | "src/filesystem.c", |
| 22 | "src/stack_line_reader.c", |
| 23 | "src/string_view.c", |
| 24 | ], |
Elliott Hughes | e39557c | 2019-08-05 12:23:07 -0700 | [diff] [blame] | 25 | target: { |
| 26 | windows: { |
| 27 | enabled: true, |
| 28 | }, |
| 29 | }, |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame^] | 30 | apex_available: [ |
| 31 | "com.android.art.release", |
| 32 | "com.android.art.debug", |
| 33 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | cc_library { |
| 37 | name: "libcpu_features-unix_based_hardware_detection", |
| 38 | defaults: ["cpu_features-defaults"], |
| 39 | srcs: [ |
| 40 | "src/hwcaps.c", |
| 41 | "src/unix_features_aggregator.c", |
| 42 | ], |
| 43 | cflags: [ |
| 44 | "-DHAVE_DLFCN_H", |
| 45 | ], |
| 46 | target: { |
| 47 | bionic: { |
| 48 | cflags: [ |
| 49 | "-DHAVE_STRONG_GETAUXVAL", |
| 50 | ], |
| 51 | }, |
| 52 | }, |
| 53 | static_libs: [ |
| 54 | "libcpu_features-utils", |
| 55 | ], |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame^] | 56 | apex_available: [ |
| 57 | "com.android.art.release", |
| 58 | "com.android.art.debug", |
| 59 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | cc_library { |
| 63 | name: "libcpu_features", |
| 64 | defaults: [ |
| 65 | "cpu_features-defaults", |
| 66 | ], |
Elliott Hughes | 7f8ace6 | 2019-08-05 11:58:18 -0700 | [diff] [blame] | 67 | export_include_dirs: ["include"], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 68 | whole_static_libs: [ |
| 69 | "libcpu_features-utils", |
| 70 | ], |
| 71 | arch: { |
| 72 | arm: { |
| 73 | srcs: [ |
| 74 | "src/cpuinfo_arm.c", |
| 75 | ], |
| 76 | whole_static_libs: [ |
| 77 | "libcpu_features-unix_based_hardware_detection", |
| 78 | ], |
| 79 | }, |
| 80 | arm64: { |
| 81 | srcs: [ |
| 82 | "src/cpuinfo_aarch64.c", |
| 83 | ], |
| 84 | whole_static_libs: [ |
| 85 | "libcpu_features-unix_based_hardware_detection", |
| 86 | ], |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 87 | cflags: [ |
| 88 | "-Wno-gnu-designator", |
| 89 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 90 | }, |
| 91 | x86: { |
| 92 | srcs: [ |
| 93 | "src/cpuinfo_x86.c", |
| 94 | ], |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 95 | cflags: [ |
| 96 | "-Wno-unused-variable", |
| 97 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 98 | }, |
| 99 | x86_64: { |
| 100 | srcs: [ |
| 101 | "src/cpuinfo_x86.c", |
| 102 | ], |
Haibo Huang | 2519d75 | 2019-07-12 18:21:31 -0700 | [diff] [blame] | 103 | cflags: [ |
| 104 | "-Wno-unused-variable", |
| 105 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 106 | }, |
| 107 | }, |
Elliott Hughes | e39557c | 2019-08-05 12:23:07 -0700 | [diff] [blame] | 108 | target: { |
| 109 | windows: { |
| 110 | enabled: true, |
| 111 | }, |
| 112 | }, |
Daniil Riazanovskiy | 4ffcbab | 2020-09-16 09:55:32 +0000 | [diff] [blame^] | 113 | apex_available: [ |
| 114 | "com.android.art.release", |
| 115 | "com.android.art.debug", |
| 116 | ], |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | cc_binary { |
| 120 | name: "list_cpu_features", |
| 121 | defaults: [ |
| 122 | "cpu_features-defaults", |
| 123 | ], |
| 124 | srcs: [ |
| 125 | "src/utils/list_cpu_features.c", |
| 126 | ], |
| 127 | static_libs: [ |
| 128 | "libcpu_features", |
| 129 | ], |
Roland Levillain | 61cf9ac | 2020-09-22 10:52:15 +0100 | [diff] [blame] | 130 | arch: { |
| 131 | // Function `AddCacheInfo` in `src/utils/list_cpu_features.c` is only used on x86/x86_64 and |
| 132 | // triggers an error with `-Werror and `-Wunused-function` on other architectures; disable |
| 133 | // the latter flag to avoid compilation errors on those architectures. |
| 134 | arm: { |
| 135 | cflags: [ |
| 136 | "-Wno-unused-function", |
| 137 | ], |
| 138 | }, |
| 139 | arm64: { |
| 140 | cflags: [ |
| 141 | "-Wno-unused-function", |
| 142 | ], |
| 143 | }, |
| 144 | }, |
Roland Levillain | d56de91 | 2019-06-20 20:55:26 +0100 | [diff] [blame] | 145 | } |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 146 | |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 147 | // Tests. |
| 148 | |
| 149 | cc_defaults { |
| 150 | name: "cpu_features-test-defaults", |
Roland Levillain | df048ae | 2019-07-23 18:02:33 +0100 | [diff] [blame] | 151 | test_suites: ["device-tests"], |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 152 | host_supported: true, |
Roland Levillain | 9ae23c4 | 2019-07-24 19:25:53 +0100 | [diff] [blame] | 153 | compile_multilib: "both", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 154 | local_include_dirs: [ |
| 155 | "include", |
| 156 | ], |
| 157 | cflags: [ |
Roland Levillain | aa4fc41 | 2019-07-24 19:51:11 +0100 | [diff] [blame] | 158 | "-DCPU_FEATURES_TEST", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 159 | ], |
| 160 | } |
| 161 | |
| 162 | cc_test_library { |
| 163 | name: "libcpu_features-string_view", |
| 164 | defaults: ["cpu_features-test-defaults"], |
| 165 | srcs: [ |
| 166 | "src/string_view.c", |
| 167 | ], |
| 168 | } |
| 169 | |
| 170 | cc_test_library { |
| 171 | name: "libcpu_features-filesystem_for_testing", |
| 172 | defaults: ["cpu_features-test-defaults"], |
| 173 | cflags: [ |
| 174 | "-DCPU_FEATURES_MOCK_FILESYSTEM", |
| 175 | // TODO: Handle unused parameters in |
| 176 | // test/filesystem_for_testing.cc and remove this flag. |
| 177 | "-Wno-unused-parameter", |
| 178 | ], |
| 179 | srcs: [ |
| 180 | "test/filesystem_for_testing.cc", |
| 181 | ], |
| 182 | } |
| 183 | |
| 184 | cc_test_library { |
| 185 | name: "libcpu_features-hwcaps_for_testing", |
| 186 | defaults: ["cpu_features-test-defaults"], |
| 187 | cflags: [ |
| 188 | "-DCPU_FEATURES_MOCK_GET_ELF_HWCAP_FROM_GETAUXVAL", |
| 189 | ], |
| 190 | srcs: [ |
| 191 | "test/hwcaps_for_testing.cc", |
| 192 | ], |
| 193 | static_libs: [ |
| 194 | "libcpu_features-string_view", |
| 195 | "libcpu_features-filesystem_for_testing", |
| 196 | ], |
| 197 | } |
| 198 | |
| 199 | cc_defaults { |
| 200 | name: "stack_line_reader-defaults", |
| 201 | cflags: [ |
| 202 | "-DSTACK_LINE_READER_BUFFER_SIZE=1024", |
| 203 | ], |
| 204 | } |
| 205 | |
| 206 | cc_test_library { |
| 207 | name: "libcpu_features-stack_line_reader", |
| 208 | defaults: [ |
| 209 | "cpu_features-test-defaults", |
| 210 | "stack_line_reader-defaults", |
| 211 | ], |
| 212 | srcs: [ |
| 213 | "src/stack_line_reader.c", |
| 214 | ], |
| 215 | static_libs: [ |
| 216 | "libcpu_features-filesystem_for_testing", |
| 217 | "libcpu_features-string_view", |
| 218 | ], |
| 219 | } |
| 220 | |
| 221 | cc_test_library { |
| 222 | name: "libcpu_features-stack_line_reader_for_test", |
| 223 | defaults: ["cpu_features-test-defaults"], |
| 224 | cflags: [ |
| 225 | "-DSTACK_LINE_READER_BUFFER_SIZE=16", |
| 226 | ], |
| 227 | srcs: [ |
| 228 | "src/stack_line_reader.c", |
| 229 | ], |
| 230 | whole_static_libs: [ |
| 231 | "libcpu_features-filesystem_for_testing", |
| 232 | "libcpu_features-string_view", |
| 233 | ], |
| 234 | } |
| 235 | |
| 236 | cc_test_library { |
| 237 | name: "libcpu_features-all_libraries", |
| 238 | defaults: [ |
| 239 | "cpu_features-test-defaults", |
| 240 | "stack_line_reader-defaults", |
| 241 | ], |
| 242 | srcs: [ |
| 243 | "src/unix_features_aggregator.c", |
| 244 | ], |
| 245 | whole_static_libs: [ |
| 246 | "libcpu_features-filesystem_for_testing", |
| 247 | "libcpu_features-hwcaps_for_testing", |
| 248 | "libcpu_features-stack_line_reader", |
| 249 | "libcpu_features-string_view", |
| 250 | ], |
| 251 | } |
| 252 | |
| 253 | cc_test { |
| 254 | name: "cpu_features-bit_utils_test", |
| 255 | defaults: ["cpu_features-test-defaults"], |
| 256 | srcs: [ |
Roland Levillain | aa4fc41 | 2019-07-24 19:51:11 +0100 | [diff] [blame] | 257 | "test/bit_utils_test.cc", |
Roland Levillain | 18318b6 | 2019-06-21 19:56:28 +0100 | [diff] [blame] | 258 | ], |
| 259 | } |
| 260 | |
| 261 | cc_test { |
| 262 | name: "cpu_features-string_view_test", |
| 263 | defaults: ["cpu_features-test-defaults"], |
| 264 | srcs: [ |
| 265 | "test/string_view_test.cc", |
| 266 | "src/string_view.c", |
| 267 | ], |
| 268 | static_libs: [ |
| 269 | "libcpu_features-string_view", |
| 270 | ], |
| 271 | } |
| 272 | |
| 273 | cc_test { |
| 274 | name: "cpu_features-stack_line_reader_test", |
| 275 | defaults: [ |
| 276 | "cpu_features-test-defaults", |
| 277 | "stack_line_reader-defaults", |
| 278 | ], |
| 279 | cflags: [ |
| 280 | // TODO: Handle unused funtions in |
| 281 | // test/stack_line_reader_test.cc and remove this flag. |
| 282 | "-Wno-unused-function", |
| 283 | ], |
| 284 | srcs: [ |
| 285 | "test/stack_line_reader_test.cc", |
| 286 | ], |
| 287 | static_libs: [ |
| 288 | "libcpu_features-stack_line_reader_for_test", |
| 289 | ], |
| 290 | } |
| 291 | |
| 292 | cc_test { |
| 293 | name: "cpu_features-unix_features_aggregator_test", |
| 294 | defaults: ["cpu_features-test-defaults"], |
| 295 | srcs: [ |
| 296 | "test/unix_features_aggregator_test.cc", |
| 297 | ], |
| 298 | static_libs: [ |
| 299 | "libcpu_features-all_libraries", |
| 300 | ], |
| 301 | } |
| 302 | |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 303 | cc_test { |
| 304 | name: "cpu_features-cpuinfo_test", |
| 305 | defaults: [ |
Roland Levillain | d4628f1 | 2019-07-24 19:40:34 +0100 | [diff] [blame] | 306 | "cpu_features-test-defaults", |
| 307 | ], |
| 308 | static_libs: [ |
| 309 | "libcpu_features-all_libraries", |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 310 | ], |
| 311 | arch: { |
| 312 | x86: { |
| 313 | cflags: [ |
| 314 | "-DCPU_FEATURES_MOCK_CPUID_X86", |
| 315 | "-Wno-unused-variable", |
| 316 | ], |
| 317 | srcs: [ |
| 318 | "test/cpuinfo_x86_test.cc", |
| 319 | "src/cpuinfo_x86.c", |
| 320 | ], |
| 321 | }, |
| 322 | x86_64: { |
| 323 | cflags: [ |
| 324 | "-DCPU_FEATURES_MOCK_CPUID_X86", |
| 325 | "-Wno-unused-variable", |
| 326 | ], |
| 327 | srcs: [ |
| 328 | "test/cpuinfo_x86_test.cc", |
| 329 | "src/cpuinfo_x86.c", |
| 330 | ], |
| 331 | }, |
| 332 | arm: { |
| 333 | cflags: [ |
| 334 | "-DSTACK_LINE_READER_BUFFER_SIZE=1024", |
| 335 | ], |
| 336 | srcs: [ |
| 337 | "test/cpuinfo_arm_test.cc", |
| 338 | "src/cpuinfo_arm.c", |
| 339 | ], |
| 340 | }, |
| 341 | arm64: { |
| 342 | cflags: [ |
| 343 | "-DSTACK_LINE_READER_BUFFER_SIZE=1024", |
| 344 | "-Wno-gnu-designator", |
| 345 | ], |
| 346 | srcs: [ |
| 347 | "test/cpuinfo_aarch64_test.cc", |
| 348 | "src/cpuinfo_aarch64.c", |
| 349 | ], |
Roland Levillain | aa4fc41 | 2019-07-24 19:51:11 +0100 | [diff] [blame] | 350 | }, |
Roland Levillain | 9f7c24e | 2019-07-11 20:10:02 +0100 | [diff] [blame] | 351 | }, |
| 352 | } |