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 '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.h', 90 'sha1/sha1.c', 91 'sha1/sha1.h', 92 'ralloc.c', 93 'ralloc.h', 94 'rand_xor.c', 95 'rand_xor.h', 96 'rb_tree.c', 97 'rb_tree.h', 98 'register_allocate.c', 99 'register_allocate.h', 100 'rgtc.c', 101 'rgtc.h', 102 'rounding.h', 103 'set.c', 104 'set.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_dl.c', 126 'u_dl.h', 127 'u_dynarray.h', 128 'u_endian.h', 129 'u_fifo.h', 130 'u_hash_table.c', 131 'u_hash_table.h', 132 'u_pointer.h', 133 'u_queue.c', 134 'u_queue.h', 135 'u_string.h', 136 'u_thread.h', 137 'u_vector.c', 138 'u_vector.h', 139 'u_math.c', 140 'u_math.h', 141 'u_memset.h', 142 'u_mm.c', 143 'u_mm.h', 144 'u_debug.c', 145 'u_debug.h', 146 'u_debug_memory.c', 147 'u_cpu_detect.c', 148 'u_cpu_detect.h', 149 'u_printf.c', 150 'u_printf.h', 151 'u_worklist.c', 152 'u_worklist.h', 153 'vl_vlc.h', 154 'vl_rbsp.h', 155 'vma.c', 156 'vma.h', 157 'xxhash.h', 158 'indices/u_indices.h', 159 'indices/u_indices_priv.h', 160 'indices/u_primconvert.c', 161 'indices/u_primconvert.h', 162) 163 164files_drirc = files('00-mesa-defaults.conf') 165 166install_data(files_drirc, install_dir : join_paths(get_option('datadir'), 'drirc.d')) 167 168if with_tests 169 prog_xmllint = find_program('xmllint', required : false, native : true) 170 if prog_xmllint.found() 171 test( 172 'drirc xml validation', 173 prog_xmllint, 174 args : ['--noout', '--valid', files_drirc], 175 suite : ['util'], 176 ) 177 endif 178endif 179 180files_xmlconfig = files( 181 'xmlconfig.c', 182 'xmlconfig.h', 183) 184 185files_xmlconfig += custom_target( 186 'driconf_static.h', 187 input: ['driconf_static.py', '00-mesa-defaults.conf'], 188 output: 'driconf_static.h', 189 command: [ 190 prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@' 191 ], 192) 193 194format_srgb = custom_target( 195 'format_srgb', 196 input : ['format_srgb.py'], 197 output : 'format_srgb.c', 198 command : [prog_python, '@INPUT0@'], 199 capture : true, 200) 201 202deps_for_libmesa_util = [ 203 dep_zlib, 204 dep_clock, 205 dep_thread, 206 dep_atomic, 207 dep_m, 208 dep_valgrind, 209 dep_zstd, 210 dep_dl, 211 dep_unwind, 212 dep_futex, 213 idep_mesautilc11 214] 215 216if with_platform_android 217 deps_for_libmesa_util += dep_android 218 files_debug_stack = files('u_debug_stack_android.cpp') 219 else 220 files_debug_stack = files( 221 'u_debug_stack.c', 222 'u_debug_symbol.c', 223 'u_debug_symbol.h', 224 ) 225endif 226 227if with_platform_haiku 228 deps_for_libmesa_util += dep_network 229endif 230 231if with_perfetto 232 files_mesa_util += files( 233 'u_perfetto.cc', 234 'u_perfetto.h', 235 ) 236 deps_for_libmesa_util += dep_perfetto 237endif 238 239u_trace_py = files('perf/u_trace.py') 240 241u_indices_gen_c = custom_target( 242 'u_indices_gen.c', 243 input : 'indices/u_indices_gen.py', 244 output : 'u_indices_gen.c', 245 command : [prog_python, '@INPUT@'], 246 capture : true, 247) 248 249u_unfilled_gen_c = custom_target( 250 'u_unfilled_gen.c', 251 input : 'indices/u_unfilled_gen.py', 252 output : 'u_unfilled_gen.c', 253 command : [prog_python, '@INPUT@'], 254 capture : true, 255) 256 257libmesa_util_sse41 = static_library( 258 'mesa_util_sse41', 259 files('streaming-load-memcpy.c'), 260 c_args : [c_msvc_compat_args, sse41_args], 261 include_directories : [inc_include, inc_src, inc_mesa], 262 gnu_symbol_visibility : 'hidden', 263) 264 265_libmesa_util = static_library( 266 'mesa_util', 267 [files_mesa_util, files_debug_stack, format_srgb, u_indices_gen_c, u_unfilled_gen_c], 268 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 269 dependencies : deps_for_libmesa_util, 270 link_with: [libmesa_format, libmesa_util_sse41], 271 c_args : [c_msvc_compat_args], 272 gnu_symbol_visibility : 'hidden', 273 build_by_default : false 274) 275 276idep_mesautil = declare_dependency( 277 link_with : _libmesa_util, 278 include_directories : [inc_util, inc_gallium], 279 dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m, dep_valgrind, dep_futex], 280) 281 282xmlconfig_deps = [] 283if not (with_platform_android or with_platform_windows) 284 xmlconfig_deps += dep_expat 285endif 286xmlconfig_deps += dep_regex 287 288_libxmlconfig = static_library( 289 'xmlconfig', 290 files_xmlconfig, 291 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 292 dependencies : [idep_mesautil, dep_m, xmlconfig_deps], 293 c_args : [ 294 c_msvc_compat_args, 295 '-DSYSCONFDIR="@0@"'.format( 296 join_paths(get_option('prefix'), get_option('sysconfdir')) 297 ), 298 '-DDATADIR="@0@"'.format( 299 join_paths(get_option('prefix'), get_option('datadir')) 300 ), 301 ], 302 gnu_symbol_visibility : 'hidden', 303 build_by_default : false, 304) 305 306idep_xmlconfig = declare_dependency( 307 dependencies : xmlconfig_deps, 308 link_with : _libxmlconfig, 309) 310 311files_xxd = files('xxd.py') 312 313if with_tests 314 # DRI_CONF macros use designated initializers (required for union 315 # initializaiton), so we need c++2a since gtest forces us to use c++ 316 if host_machine.system() != 'windows' and cpp.has_argument('-std=c++2a') 317 test('xmlconfig', 318 executable('xmlconfig_test', 319 files('tests/xmlconfig.cpp'), 320 include_directories : [inc_include, inc_src], 321 dependencies : [idep_mesautil, idep_xmlconfig, idep_gtest], 322 override_options : ['cpp_std=c++2a'], 323 cpp_args: ['-Wno-write-strings'] 324 ), 325 suite : ['util'], 326 env: ['HOME=' + join_paths(meson.current_source_dir(), 327 'tests', 'drirc_home'), 328 'DRIRC_CONFIGDIR=' + join_paths(meson.current_source_dir(), 329 'tests', 'drirc_configdir')], 330 protocol : gtest_test_protocol, 331 ) 332 endif 333 334 files_util_tests = files( 335 'tests/bitset_test.cpp', 336 'tests/blob_test.cpp', 337 'tests/dag_test.cpp', 338 'tests/fast_idiv_by_const_test.cpp', 339 'tests/fast_urem_by_const_test.cpp', 340 'tests/half_float_test.cpp', 341 'tests/int_min_max.cpp', 342 'tests/rb_tree_test.cpp', 343 'tests/register_allocate_test.cpp', 344 'tests/roundeven_test.cpp', 345 'tests/set_test.cpp', 346 'tests/timespec_test.cpp', 347 'tests/u_atomic_test.cpp', 348 'tests/u_debug_stack_test.cpp', 349 'tests/u_printf_test.cpp', 350 'tests/u_qsort_test.cpp', 351 'tests/vector_test.cpp', 352 ) 353 354 if not (host_machine.system() == 'windows' and cc.get_id() == 'gcc') 355 # FIXME: These tests fail with mingw, but not with msvc. 356 files_util_tests += files( 357 'tests/string_buffer_test.cpp', 358 ) 359 endif 360 361 # FIXME: this test crashes on windows 362 if host_machine.system() != 'windows' 363 files_util_tests += files( 364 'tests/mesa-sha1_test.cpp', 365 ) 366 endif 367 368 # FIXME: this test cause a big timeout on MacOS 369 if host_machine.system() != 'darwin' 370 files_util_tests += files( 371 'tests/sparse_array_test.cpp', 372 ) 373 endif 374 375 if with_shader_cache 376 files_util_tests += files( 377 'tests/cache_test.cpp', 378 ) 379 endif 380 381 test( 382 'util_tests', 383 executable( 384 'util_tests', 385 files_util_tests, 386 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 387 dependencies : [idep_mesautil, idep_gtest], 388 ), 389 suite : ['util'], 390 protocol : gtest_test_protocol, 391 timeout : 180, 392 ) 393 394 process_test_exe = executable( 395 'process_test', 396 files('tests/process_test.c'), 397 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 398 dependencies : idep_mesautil, 399 c_args : [c_msvc_compat_args], 400 ) 401 if (host_machine.system() == 'windows' and build_machine.system() != 'windows') 402 # This conversion is only required on mingw crosscompilers, otherwise we hit at least one of these issues 403 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2690 404 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2788 405 prog_winepath = find_program('winepath') 406 process_test_exe_full_path = run_command( 407 prog_winepath, '-w', process_test_exe.full_path(), 408 check : true 409 ).stdout().strip() 410 else 411 process_test_exe_full_path = process_test_exe.full_path() 412 endif 413 414 test( 415 'process', 416 process_test_exe, 417 suite : ['util'], 418 env: ['BUILD_FULL_PATH='+process_test_exe_full_path] 419 ) 420 421 subdir('tests/hash_table') 422 subdir('tests/vma') 423 subdir('tests/format') 424endif 425