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