1# Copyright © 2017 Intel Corporation 2# SPDX-License-Identifier: MIT 3 4# inc_util only depends inc_include, this folder and nothing else under src 5# so we use include_directories('..') instead of inc_src to tell the fact 6# util is self contained. 7inc_util = [inc_include, include_directories('..')] 8 9if with_platform_android 10subdir('u_gralloc') 11endif 12 13subdir('blake3') 14 15files_mesa_util = files( 16 'anon_file.h', 17 'anon_file.c', 18 'bigmath.h', 19 'bitscan.c', 20 'bitscan.h', 21 'bitset.h', 22 'blend.h', 23 'blob.c', 24 'blob.h', 25 'box.h', 26 'build_id.c', 27 'build_id.h', 28 'cnd_monotonic.c', 29 'cnd_monotonic.h', 30 'compiler.h', 31 'compress.c', 32 'compress.h', 33 'thread_sched.c', 34 'thread_sched.h', 35 'crc32.c', 36 'crc32.h', 37 'dag.c', 38 'disk_cache.c', 39 'disk_cache.h', 40 'disk_cache_os.c', 41 'disk_cache_os.h', 42 'double.c', 43 'double.h', 44 'enum_operators.h', 45 'fast_idiv_by_const.c', 46 'fast_idiv_by_const.h', 47 'format_r11g11b10f.h', 48 'format_rgb9e5.h', 49 'format_srgb.h', 50 'fossilize_db.c', 51 'fossilize_db.h', 52 'futex.c', 53 'futex.h', 54 'glheader.h', 55 'half_float.c', 56 'half_float.h', 57 'hash_table.c', 58 'hash_table.h', 59 'helpers.c', 60 'helpers.h', 61 'hex.h', 62 'u_idalloc.c', 63 'u_idalloc.h', 64 'list.h', 65 'log.c', 66 'macros.h', 67 'memstream.c', 68 'memstream.h', 69 'mesa-sha1.c', 70 'mesa-sha1.h', 71 'mesa-blake3.c', 72 'mesa-blake3.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 'ptralloc.h', 82 'perf/u_trace.h', 83 'perf/u_trace.c', 84 'perf/u_trace_priv.h', 85 'u_process.c', 86 'u_process.h', 87 'u_qsort.cpp', 88 'u_qsort.h', 89 'rwlock.c', 90 'rwlock.h', 91 'sha1/sha1.c', 92 'sha1/sha1.h', 93 'ralloc.c', 94 'ralloc.h', 95 'rand_xor.c', 96 'rand_xor.h', 97 'rb_tree.c', 98 'rb_tree.h', 99 'register_allocate.c', 100 'register_allocate.h', 101 'rgtc.c', 102 'rgtc.h', 103 'rounding.h', 104 'set.c', 105 'set.h', 106 'simple_mtx.c', 107 'simple_mtx.h', 108 'slab.c', 109 'slab.h', 110 'softfloat.c', 111 'softfloat.h', 112 'sparse_array.c', 113 'sparse_array.h', 114 'string_buffer.c', 115 'string_buffer.h', 116 'strndup.h', 117 'strtod.c', 118 'strtod.h', 119 'texcompress_astc_luts.cpp', 120 'texcompress_astc_luts.h', 121 'texcompress_astc_luts_wrap.cpp', 122 'texcompress_astc_luts_wrap.h', 123 'timespec.h', 124 'u_atomic.c', 125 'u_atomic.h', 126 'u_call_once.c', 127 'u_call_once.h', 128 'u_dl.c', 129 'u_dl.h', 130 'u_dynarray.c', 131 'u_dynarray.h', 132 'u_endian.h', 133 'u_hash_table.c', 134 'u_hash_table.h', 135 'u_pointer.h', 136 'u_queue.c', 137 'u_queue.h', 138 'u_string.h', 139 'u_thread.c', 140 'u_thread.h', 141 'u_vector.c', 142 'u_vector.h', 143 'u_math.c', 144 'u_math.h', 145 'u_memset.h', 146 'u_mm.c', 147 'u_mm.h', 148 'u_pack_color.h', 149 'u_debug.c', 150 'u_debug.h', 151 'u_debug_memory.c', 152 'u_cpu_detect.c', 153 'u_cpu_detect.h', 154 'u_printf.c', 155 'u_printf.h', 156 'u_worklist.c', 157 'u_worklist.h', 158 'vl_vlc.h', 159 'vl_rbsp.h', 160 'vl_zscan_data.h', 161 'vl_zscan_data.c', 162 'vma.c', 163 'vma.h', 164 'xxhash.h', 165 'mesa_cache_db.c', 166 'mesa_cache_db.h', 167 'mesa_cache_db_multipart.c', 168 'mesa_cache_db_multipart.h', 169) 170 171files_drirc = files('00-mesa-defaults.conf') 172 173if with_amd_vk 174 files_drirc += files('00-radv-defaults.conf') 175endif 176 177if with_tests 178 prog_xmllint = find_program('xmllint', required : false, native : true) 179 if prog_xmllint.found() 180 test( 181 'drirc xml validation', 182 prog_xmllint, 183 args : ['--noout', '--valid', files_drirc], 184 suite : ['util'], 185 ) 186 endif 187endif 188 189files_xmlconfig = files( 190 'xmlconfig.c', 191 'xmlconfig.h', 192) 193 194files_xmlconfig += custom_target( 195 'driconf_static.h', 196 input: ['driconf_static.py'] + files_drirc, 197 output: 'driconf_static.h', 198 command: [ 199 prog_python, '@INPUT@', '@OUTPUT@', 200 ], 201) 202 203format_srgb = custom_target( 204 'format_srgb', 205 input : ['format_srgb.py'], 206 output : 'format_srgb.c', 207 command : [prog_python, '@INPUT0@'], 208 capture : true, 209) 210 211# subdir format provide files_mesa_format 212subdir('format') 213files_mesa_util += files_mesa_format 214 215deps_for_libmesa_util = [ 216 dep_zlib, 217 dep_clock, 218 dep_thread, 219 dep_atomic, 220 dep_m, 221 dep_valgrind, 222 dep_zstd, 223 dep_dl, 224 dep_unwind, 225 dep_futex, 226 idep_blake3, 227 idep_mesautilc11, 228 idep_mesautilformat, 229] 230 231if with_platform_android 232 deps_for_libmesa_util += dep_android 233 files_debug_stack = files('u_debug_stack_android.cpp') 234else 235 files_debug_stack = files( 236 'dbghelp.h', 237 'u_debug_stack.c', 238 'u_debug_symbol.c', 239 'u_debug_symbol.h', 240 ) 241endif 242 243if with_platform_haiku 244 deps_for_libmesa_util += dep_network 245endif 246 247if with_perfetto 248 files_mesa_util += files( 249 'perf/u_perfetto.cc', 250 'perf/u_perfetto.h', 251 ) 252 deps_for_libmesa_util += dep_perfetto 253endif 254 255if with_gpuvis 256 files_mesa_util += files( 257 'perf/u_gpuvis.c', 258 'perf/u_gpuvis.h', 259 'perf/gpuvis_trace_utils.h', 260 ) 261endif 262 263u_trace_py = files('perf/u_trace.py') 264 265libmesa_util_sse41 = static_library( 266 'mesa_util_sse41', 267 files('streaming-load-memcpy.c'), 268 c_args : [c_msvc_compat_args, sse41_args], 269 include_directories : [inc_util], 270 gnu_symbol_visibility : 'hidden', 271) 272 273_libmesa_util = static_library( 274 'mesa_util', 275 [files_mesa_util, files_debug_stack, format_srgb], 276 include_directories : [inc_util, include_directories('format')], 277 dependencies : deps_for_libmesa_util, 278 link_with: [libmesa_util_sse41], 279 c_args : [c_msvc_compat_args], 280 gnu_symbol_visibility : 'hidden', 281 build_by_default : false 282) 283 284idep_mesautil = declare_dependency( 285 link_with : _libmesa_util, 286 include_directories : [inc_util], 287 dependencies : deps_for_libmesa_util, 288) 289 290# Only install the drirc file if we build with support for parsing drirc files 291if use_xmlconfig 292 install_data(files_drirc, install_dir : join_paths(get_option('datadir'), 'drirc.d'), install_tag : 'runtime') 293endif 294 295xmlconfig_deps = [] 296if use_xmlconfig 297 xmlconfig_deps += dep_expat 298endif 299xmlconfig_deps += dep_regex 300 301c_xmlconfig_arg = '-DWITH_XMLCONFIG=@0@'.format(use_xmlconfig.to_int()) 302 303_libxmlconfig = static_library( 304 'xmlconfig', 305 files_xmlconfig, 306 dependencies : [idep_mesautil, dep_m, xmlconfig_deps], 307 c_args : [ 308 c_msvc_compat_args, 309 c_xmlconfig_arg, 310 '-DSYSCONFDIR="@0@"'.format( 311 join_paths(get_option('prefix'), get_option('sysconfdir')) 312 ), 313 '-DDATADIR="@0@"'.format( 314 join_paths(get_option('prefix'), get_option('datadir')) 315 ), 316 ], 317 gnu_symbol_visibility : 'hidden', 318 build_by_default : false, 319) 320 321idep_xmlconfig = declare_dependency( 322 dependencies : xmlconfig_deps, 323 link_with : _libxmlconfig, 324) 325 326files_xxd = files('xxd.py') 327glsl2spirv = files('glsl2spirv.py') 328 329devenv.set('DRIRC_CONFIGDIR', meson.current_source_dir()) 330 331_libparson = static_library( 332 'parson', 333 ['parson.c', 'parson.h'], 334 gnu_symbol_visibility : 'hidden', 335 build_by_default : false, 336) 337 338idep_parson = declare_dependency( 339 link_with : _libparson, 340) 341 342if with_tests 343 # DRI_CONF macros use designated initializers (required for union 344 # initializaiton), so we need c++2a since gtest forces us to use c++ 345 if host_machine.system() != 'windows' and cpp.has_argument('-std=c++2a') 346 test('xmlconfig', 347 executable('xmlconfig_test', 348 files('tests/xmlconfig.cpp'), 349 dependencies : [idep_mesautil, idep_xmlconfig, idep_gtest], 350 override_options : ['cpp_std=c++2a'], 351 cpp_args: ['-Wno-write-strings', c_xmlconfig_arg] 352 ), 353 suite : ['util'], 354 env: ['HOME=' + join_paths(meson.current_source_dir(), 355 'tests', 'drirc_home'), 356 'DRIRC_CONFIGDIR=' + join_paths(meson.current_source_dir(), 357 'tests', 'drirc_configdir')], 358 protocol : 'gtest', 359 ) 360 endif 361 362 files_util_tests = files( 363 'tests/bitset_test.cpp', 364 'tests/blob_test.cpp', 365 'tests/dag_test.cpp', 366 'tests/fast_idiv_by_const_test.cpp', 367 'tests/fast_urem_by_const_test.cpp', 368 'tests/gc_alloc_tests.cpp', 369 'tests/half_float_test.cpp', 370 'tests/int_min_max.cpp', 371 'tests/linear_test.cpp', 372 'tests/mesa-sha1_test.cpp', 373 'tests/os_mman_test.cpp', 374 'tests/perf/u_trace_test.cpp', 375 'tests/rb_tree_test.cpp', 376 'tests/register_allocate_test.cpp', 377 'tests/roundeven_test.cpp', 378 'tests/set_test.cpp', 379 'tests/string_buffer_test.cpp', 380 'tests/timespec_test.cpp', 381 'tests/u_atomic_test.cpp', 382 'tests/u_call_once_test.cpp', 383 'tests/u_debug_stack_test.cpp', 384 'tests/u_debug_test.cpp', 385 'tests/u_printf_test.cpp', 386 'tests/u_qsort_test.cpp', 387 'tests/vector_test.cpp', 388 ) 389 390 # FIXME: this test cause a big timeout on MacOS 391 if host_machine.system() != 'darwin' 392 files_util_tests += files( 393 'tests/sparse_array_test.cpp', 394 ) 395 endif 396 397 if with_shader_cache 398 files_util_tests += files( 399 'tests/cache_test.cpp', 400 ) 401 endif 402 403 test( 404 'util_tests', 405 executable( 406 'util_tests', 407 files_util_tests, 408 dependencies : [idep_mesautil, idep_gtest], 409 ), 410 suite : ['util'], 411 protocol : 'gtest', 412 is_parallel : false, 413 timeout : 180, 414 ) 415 416 process_test_exe = executable( 417 'process_test', 418 files('tests/process_test.c'), 419 dependencies : idep_mesautil, 420 c_args : [c_msvc_compat_args], 421 ) 422 if (host_machine.system() == 'windows' and build_machine.system() != 'windows') 423 # This conversion is only required on mingw crosscompilers, otherwise we hit at least one of these issues 424 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2690 425 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2788 426 prog_winepath = find_program('winepath') 427 process_test_exe_full_path = run_command( 428 prog_winepath, '-w', process_test_exe.full_path(), 429 check : true 430 ).stdout().strip() 431 else 432 process_test_exe_full_path = process_test_exe.full_path() 433 endif 434 435 test( 436 'process', 437 process_test_exe, 438 suite : ['util'], 439 env: ['BUILD_FULL_PATH='+process_test_exe_full_path] 440 ) 441 442 test( 443 'process_with_overrides', 444 process_test_exe, 445 suite : ['util'], 446 env: [ 447 'BUILD_FULL_PATH='+process_test_exe_full_path, 448 'MESA_PROCESS_NAME=hello', 449 ] 450 ) 451 452 subdir('tests/hash_table') 453 subdir('tests/vma') 454 subdir('tests/format') 455endif 456