1# Copyright © 2017 Intel Corporation 2 3# Permission is hereby granted, free of charge, to any person obtaining a copy 4# of this software and associated documentation files (the "Software"), to deal 5# in the Software without restriction, including without limitation the rights 6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7# copies of the Software, and to permit persons to whom the Software is 8# furnished to do so, subject to the following conditions: 9 10# The above copyright notice and this permission notice shall be included in 11# all copies or substantial portions of the Software. 12 13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19# SOFTWARE. 20 21inc_util = include_directories('.') 22 23subdir('format') 24 25files_mesa_util = files( 26 'anon_file.h', 27 'anon_file.c', 28 'bigmath.h', 29 'bitscan.c', 30 'bitscan.h', 31 'bitset.h', 32 'blob.c', 33 'blob.h', 34 'build_id.c', 35 'build_id.h', 36 'cnd_monotonic.h', 37 'compiler.h', 38 'compress.c', 39 'compress.h', 40 'crc32.c', 41 'crc32.h', 42 'dag.c', 43 'debug.c', 44 'debug.h', 45 'disk_cache.c', 46 'disk_cache.h', 47 'disk_cache_os.c', 48 'disk_cache_os.h', 49 'double.c', 50 'double.h', 51 'enum_operators.h', 52 'fast_idiv_by_const.c', 53 'fast_idiv_by_const.h', 54 'format_r11g11b10f.h', 55 'format_rgb9e5.h', 56 'format_srgb.h', 57 'fossilize_db.c', 58 'fossilize_db.h', 59 'futex.h', 60 'half_float.c', 61 'half_float.h', 62 'hash_table.c', 63 'hash_table.h', 64 'u_idalloc.c', 65 'u_idalloc.h', 66 'list.h', 67 'log.c', 68 'macros.h', 69 'memstream.c', 70 'memstream.h', 71 'mesa-sha1.c', 72 'mesa-sha1.h', 73 'os_time.c', 74 'os_time.h', 75 'os_file.c', 76 'os_memory_fd.c', 77 'os_misc.c', 78 'os_misc.h', 79 'os_socket.c', 80 'os_socket.h', 81 'perf/u_trace.h', 82 'perf/u_trace.c', 83 'perf/u_trace_priv.h', 84 'u_process.c', 85 'u_process.h', 86 'u_qsort.cpp', 87 'u_qsort.h', 88 'rwlock.h', 89 'sha1/sha1.c', 90 'sha1/sha1.h', 91 'ralloc.c', 92 'ralloc.h', 93 'rand_xor.c', 94 'rand_xor.h', 95 'rb_tree.c', 96 'rb_tree.h', 97 'register_allocate.c', 98 'register_allocate.h', 99 'rgtc.c', 100 'rgtc.h', 101 'rounding.h', 102 'set.c', 103 'set.h', 104 'simple_list.h', 105 'simple_mtx.h', 106 'slab.c', 107 'slab.h', 108 'softfloat.c', 109 'softfloat.h', 110 'sparse_array.c', 111 'sparse_array.h', 112 'string_buffer.c', 113 'string_buffer.h', 114 'strndup.h', 115 'strtod.c', 116 'strtod.h', 117 'texcompress_rgtc_tmp.h', 118 'timespec.h', 119 'u_atomic.c', 120 'u_atomic.h', 121 'u_debug_describe.c', 122 'u_debug_describe.h', 123 'u_debug_refcnt.c', 124 'u_debug_refcnt.h', 125 'u_dynarray.h', 126 'u_endian.h', 127 'u_fifo.h', 128 'u_hash_table.c', 129 'u_hash_table.h', 130 'u_queue.c', 131 'u_queue.h', 132 'u_string.h', 133 'u_thread.h', 134 'u_vector.c', 135 'u_vector.h', 136 'u_math.c', 137 'u_math.h', 138 'u_memset.h', 139 'u_mm.c', 140 'u_mm.h', 141 'u_debug.c', 142 'u_debug.h', 143 'u_debug_memory.c', 144 'u_cpu_detect.c', 145 'u_cpu_detect.h', 146 'u_printf.cpp', 147 'u_printf.h', 148 'vma.c', 149 'vma.h', 150 'xxhash.h', 151) 152 153files_drirc = files('00-mesa-defaults.conf') 154 155install_data(files_drirc, install_dir : join_paths(get_option('datadir'), 'drirc.d')) 156 157if with_tests 158 prog_xmllint = find_program('xmllint', required : false, native : true) 159 if prog_xmllint.found() 160 test( 161 'drirc xml validation', 162 prog_xmllint, 163 args : ['--noout', '--valid', files_drirc], 164 suite : ['util'], 165 ) 166 endif 167endif 168 169files_xmlconfig = files( 170 'xmlconfig.c', 171 'xmlconfig.h', 172) 173 174files_xmlconfig += custom_target( 175 'driconf_static.h', 176 input: ['driconf_static.py', '00-mesa-defaults.conf'], 177 output: 'driconf_static.h', 178 command: [ 179 prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@' 180 ], 181) 182 183format_srgb = custom_target( 184 'format_srgb', 185 input : ['format_srgb.py'], 186 output : 'format_srgb.c', 187 command : [prog_python, '@INPUT0@'], 188 capture : true, 189) 190 191deps_for_libmesa_util = [ 192 dep_zlib, 193 dep_clock, 194 dep_thread, 195 dep_atomic, 196 dep_m, 197 dep_valgrind, 198 dep_zstd, 199 dep_dl, 200 dep_unwind, 201] 202 203if with_platform_android 204 deps_for_libmesa_util += dep_android 205 files_debug_stack = files('u_debug_stack_android.cpp') 206 else 207 files_debug_stack = files( 208 'u_debug_stack.c', 209 'u_debug_symbol.c', 210 'u_debug_symbol.h', 211 ) 212endif 213 214if with_platform_haiku 215 deps_for_libmesa_util += dep_network 216endif 217 218if with_perfetto 219 files_mesa_util += files( 220 'u_perfetto.cc', 221 'u_perfetto.h', 222 ) 223 deps_for_libmesa_util += dep_perfetto 224endif 225 226u_trace_py = files('perf/u_trace.py') 227 228_libmesa_util = static_library( 229 'mesa_util', 230 [files_mesa_util, files_debug_stack, format_srgb], 231 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 232 dependencies : deps_for_libmesa_util, 233 link_with: libmesa_format, 234 c_args : [c_msvc_compat_args], 235 gnu_symbol_visibility : 'hidden', 236 build_by_default : false 237) 238 239idep_mesautil = declare_dependency( 240 link_with : _libmesa_util, 241 include_directories : [inc_util, inc_gallium], 242 dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m, dep_valgrind], 243) 244 245xmlconfig_deps = [] 246if not (with_platform_android or with_platform_windows) 247 xmlconfig_deps += dep_expat 248endif 249xmlconfig_deps += dep_regex 250 251_libxmlconfig = static_library( 252 'xmlconfig', 253 files_xmlconfig, 254 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 255 dependencies : [idep_mesautil, dep_m, xmlconfig_deps], 256 c_args : [ 257 c_msvc_compat_args, 258 '-DSYSCONFDIR="@0@"'.format( 259 join_paths(get_option('prefix'), get_option('sysconfdir')) 260 ), 261 '-DDATADIR="@0@"'.format( 262 join_paths(get_option('prefix'), get_option('datadir')) 263 ), 264 ], 265 gnu_symbol_visibility : 'hidden', 266 build_by_default : false, 267) 268 269idep_xmlconfig = declare_dependency( 270 dependencies : xmlconfig_deps, 271 link_with : _libxmlconfig, 272) 273 274files_xxd = files('xxd.py') 275 276if with_tests 277 # DRI_CONF macros use designated initializers (required for union 278 # initializaiton), so we need c++2a since gtest forces us to use c++ 279 if host_machine.system() != 'windows' and cpp.has_argument('-std=c++2a') 280 test('xmlconfig', 281 executable('xmlconfig_test', 282 files('tests/xmlconfig.cpp'), 283 include_directories : [inc_include, inc_src], 284 dependencies : [idep_mesautil, idep_xmlconfig, idep_gtest], 285 override_options : ['cpp_std=c++2a'], 286 cpp_args: ['-Wno-write-strings'] 287 ), 288 suite : ['util'], 289 env: ['HOME=' + join_paths(meson.current_source_dir(), 290 'tests', 'drirc_home'), 291 'DRIRC_CONFIGDIR=' + join_paths(meson.current_source_dir(), 292 'tests', 'drirc_configdir')] 293 ) 294 endif 295 296 test( 297 'u_atomic', 298 executable( 299 'u_atomic_test', 300 files('u_atomic_test.c'), 301 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 302 dependencies : idep_mesautil, 303 c_args : [c_msvc_compat_args], 304 ), 305 suite : ['util'], 306 ) 307 308 test( 309 'blob', 310 executable( 311 'blob_test', 312 files('blob_test.c'), 313 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 314 dependencies : idep_mesautil, 315 c_args : [c_msvc_compat_args], 316 ), 317 suite : ['util'], 318 ) 319 320 test( 321 'rb_tree', 322 executable( 323 'rb_tree_test', 324 files('rb_tree_test.c'), 325 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 326 dependencies : idep_mesautil, 327 c_args : [c_msvc_compat_args], 328 ), 329 suite : ['util'], 330 ) 331 332 test( 333 'roundeven', 334 executable( 335 'roundeven_test', 336 files('roundeven_test.c'), 337 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 338 c_args : [c_msvc_compat_args], 339 dependencies : [dep_m], 340 ), 341 suite : ['util'], 342 should_fail : meson.get_cross_property('xfail', '').contains('roundeven'), 343 ) 344 345 # FIXME: this test crashes on windows 346 if host_machine.system() != 'windows' 347 test( 348 'mesa-sha1', 349 executable( 350 'mesa-sha1_test', 351 files('mesa-sha1_test.c'), 352 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 353 link_with : _libmesa_util, 354 c_args : [c_msvc_compat_args], 355 ), 356 suite : ['util'], 357 ) 358 endif 359 360 foreach t: ['bitset', 'register_allocate', 'u_debug_stack', 'u_qsort'] 361 test( 362 t, 363 executable( 364 t + '_test', 365 files(t + '_test.cpp'), 366 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 367 dependencies : [idep_mesautil, idep_gtest], 368 ), 369 suite : ['util'], 370 ) 371 endforeach 372 373 process_test_exe = executable( 374 'process_test', 375 files('process_test.c'), 376 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 377 dependencies : idep_mesautil, 378 c_args : [c_msvc_compat_args], 379 ) 380 if (host_machine.system() == 'windows' and build_machine.system() != 'windows') 381 # This conversion is only required on mingw crosscompilers, otherwise we hit at least one of these issues 382 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2690 383 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2788 384 prog_winepath = find_program('winepath') 385 process_test_exe_full_path = run_command( 386 prog_winepath, '-w', process_test_exe.full_path() 387 ).stdout().strip() 388 else 389 process_test_exe_full_path = process_test_exe.full_path() 390 endif 391 392 test( 393 'process', 394 process_test_exe, 395 suite : ['util'], 396 env: ['BUILD_FULL_PATH='+process_test_exe_full_path] 397 ) 398 399 test('int_min_max', 400 executable('int_min_max_test', 401 files('tests/int_min_max.cpp'), 402 include_directories : [inc_include, inc_src], 403 dependencies : [idep_mesautil, idep_gtest], 404 ), 405 suite : ['util'], 406 ) 407 408 test( 409 'dag', 410 executable( 411 'dag_test', 412 'tests/dag_test.cpp', 413 dependencies : [idep_mesautil, idep_gtest], 414 include_directories : [inc_include, inc_src], 415 ), 416 suite : ['util'], 417 ) 418 419 subdir('tests/cache') 420 subdir('tests/fast_idiv_by_const') 421 subdir('tests/fast_urem_by_const') 422 subdir('tests/hash_table') 423 if not (host_machine.system() == 'windows' and cc.get_id() == 'gcc') 424 # FIXME: These tests fail with mingw, but not with msvc. 425 subdir('tests/string_buffer') 426 endif 427 if cc.has_header('sys/time.h') # MinGW has this, but Vanilla windows doesn't 428 subdir('tests/timespec') 429 endif 430 subdir('tests/vma') 431 subdir('tests/set') 432 subdir('tests/sparse_array') 433 subdir('tests/format') 434 subdir('tests/vector') 435endif 436