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