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