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