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 'compiler.h', 37 'crc32.c', 38 'crc32.h', 39 'dag.c', 40 'debug.c', 41 'debug.h', 42 'disk_cache.c', 43 'disk_cache.h', 44 'disk_cache_os.c', 45 'disk_cache_os.h', 46 'double.c', 47 'double.h', 48 'enum_operators.h', 49 'fast_idiv_by_const.c', 50 'fast_idiv_by_const.h', 51 'format_r11g11b10f.h', 52 'format_rgb9e5.h', 53 'format_srgb.h', 54 'futex.h', 55 'half_float.c', 56 'half_float.h', 57 'hash_table.c', 58 'hash_table.h', 59 'u_idalloc.c', 60 'u_idalloc.h', 61 'list.h', 62 'log.c', 63 'macros.h', 64 'memstream.c', 65 'memstream.h', 66 'mesa-sha1.c', 67 'mesa-sha1.h', 68 'os_time.c', 69 'os_time.h', 70 'os_file.c', 71 'os_misc.c', 72 'os_misc.h', 73 'os_socket.c', 74 'os_socket.h', 75 'u_process.c', 76 'u_process.h', 77 'rwlock.h', 78 'sha1/sha1.c', 79 'sha1/sha1.h', 80 'ralloc.c', 81 'ralloc.h', 82 'rand_xor.c', 83 'rand_xor.h', 84 'rb_tree.c', 85 'rb_tree.h', 86 'register_allocate.c', 87 'register_allocate.h', 88 'rgtc.c', 89 'rgtc.h', 90 'rounding.h', 91 'set.c', 92 'set.h', 93 'simple_list.h', 94 'simple_mtx.h', 95 'slab.c', 96 'slab.h', 97 'softfloat.c', 98 'softfloat.h', 99 'sparse_array.c', 100 'sparse_array.h', 101 'string_buffer.c', 102 'string_buffer.h', 103 'strndup.h', 104 'strtod.c', 105 'strtod.h', 106 'texcompress_rgtc_tmp.h', 107 'timespec.h', 108 'u_atomic.c', 109 'u_atomic.h', 110 'u_dynarray.h', 111 'u_endian.h', 112 'u_queue.c', 113 'u_queue.h', 114 'u_string.h', 115 'u_thread.h', 116 'u_vector.c', 117 'u_vector.h', 118 'u_math.c', 119 'u_math.h', 120 'u_memset.h', 121 'u_mm.c', 122 'u_mm.h', 123 'u_debug.c', 124 'u_debug.h', 125 'u_debug_memory.c', 126 'u_cpu_detect.c', 127 'u_cpu_detect.h', 128 'vma.c', 129 'vma.h', 130 'xxhash.h', 131) 132 133files_drirc = files('00-mesa-defaults.conf') 134 135install_data(files_drirc, install_dir : join_paths(get_option('datadir'), 'drirc.d')) 136 137if with_tests 138 prog_xmllint = find_program('xmllint', required : false, native : true) 139 if prog_xmllint.found() 140 test( 141 'drirc xml validation', 142 prog_xmllint, 143 args : ['--noout', '--valid', files_drirc], 144 suite : ['util'], 145 ) 146 endif 147endif 148 149files_xmlconfig = files( 150 'xmlconfig.c', 151 'xmlconfig.h', 152) 153 154format_srgb = custom_target( 155 'format_srgb', 156 input : ['format_srgb.py'], 157 output : 'format_srgb.c', 158 command : [prog_python, '@INPUT0@'], 159 capture : true, 160) 161 162deps_for_libmesa_util = [ 163 dep_zlib, 164 dep_clock, 165 dep_thread, 166 dep_atomic, 167 dep_m, 168 dep_valgrind, 169 dep_zstd, 170 dep_dl, 171 dep_unwind, 172] 173 174if with_platform_android 175 deps_for_libmesa_util += dep_android 176 files_debug_stack = files('u_debug_stack_android.cpp') 177 else 178 files_debug_stack = files( 179 'u_debug_stack.c', 180 'u_debug_symbol.c', 181 'u_debug_symbol.h', 182 ) 183endif 184 185_libmesa_util = static_library( 186 'mesa_util', 187 [files_mesa_util, files_debug_stack, format_srgb], 188 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 189 dependencies : deps_for_libmesa_util, 190 link_with: libmesa_format, 191 c_args : [c_msvc_compat_args], 192 gnu_symbol_visibility : 'hidden', 193 build_by_default : false 194) 195 196idep_mesautil = declare_dependency( 197 link_with : _libmesa_util, 198 include_directories : inc_util, 199 dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m], 200) 201 202xmlconfig_deps = [] 203if not (with_platform_android or with_platform_windows) 204 xmlconfig_deps += dep_expat 205endif 206 207_libxmlconfig = static_library( 208 'xmlconfig', 209 files_xmlconfig, 210 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 211 dependencies : [idep_mesautil, dep_m, xmlconfig_deps], 212 c_args : [ 213 c_msvc_compat_args, 214 '-DSYSCONFDIR="@0@"'.format( 215 join_paths(get_option('prefix'), get_option('sysconfdir')) 216 ), 217 '-DDATADIR="@0@"'.format( 218 join_paths(get_option('prefix'), get_option('datadir')) 219 ), 220 ], 221 gnu_symbol_visibility : 'hidden', 222 build_by_default : false, 223) 224 225idep_xmlconfig = declare_dependency( 226 dependencies : xmlconfig_deps, 227 link_with : _libxmlconfig, 228) 229 230files_xxd = files('xxd.py') 231 232if with_tests 233 # DRI_CONF macros use designated initializers (required for union 234 # initializaiton), so we need c++2a since gtest forces us to use c++ 235 if host_machine.system() != 'windows' and cpp.has_argument('-std=c++2a') 236 test('xmlconfig', 237 executable('xmlconfig_test', 238 files('tests/xmlconfig.cpp'), 239 include_directories : [inc_include, inc_src], 240 dependencies : [idep_mesautil, idep_xmlconfig, idep_gtest], 241 override_options : ['cpp_std=c++2a'], 242 cpp_args: ['-Wno-write-strings'] 243 ), 244 suite : ['util'], 245 ) 246 endif 247 248 test( 249 'u_atomic', 250 executable( 251 'u_atomic_test', 252 files('u_atomic_test.c'), 253 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 254 dependencies : idep_mesautil, 255 c_args : [c_msvc_compat_args], 256 ), 257 suite : ['util'], 258 ) 259 260 test( 261 'blob', 262 executable( 263 'blob_test', 264 files('blob_test.c'), 265 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 266 dependencies : idep_mesautil, 267 c_args : [c_msvc_compat_args], 268 ), 269 suite : ['util'], 270 ) 271 272 test( 273 'rb_tree', 274 executable( 275 'rb_tree_test', 276 files('rb_tree_test.c'), 277 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 278 dependencies : idep_mesautil, 279 c_args : [c_msvc_compat_args], 280 ), 281 suite : ['util'], 282 ) 283 284 test( 285 'roundeven', 286 executable( 287 'roundeven_test', 288 files('roundeven_test.c'), 289 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 290 c_args : [c_msvc_compat_args], 291 dependencies : [dep_m], 292 ), 293 suite : ['util'], 294 should_fail : meson.get_cross_property('xfail', '').contains('roundeven'), 295 ) 296 297 # FIXME: this test crashes on windows 298 if host_machine.system() != 'windows' 299 test( 300 'mesa-sha1', 301 executable( 302 'mesa-sha1_test', 303 files('mesa-sha1_test.c'), 304 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 305 link_with : _libmesa_util, 306 c_args : [c_msvc_compat_args], 307 ), 308 suite : ['util'], 309 ) 310 endif 311 312 test( 313 'bitset', 314 executable( 315 'bitset_test', 316 files('bitset_test.cpp'), 317 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 318 dependencies : [idep_mesautil, idep_gtest], 319 ), 320 suite : ['util'], 321 ) 322 323 test( 324 'u_debug_stack', 325 executable( 326 'u_debug_stack_test', 327 files('u_debug_stack_test.cpp'), 328 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 329 dependencies : [idep_mesautil, idep_gtest], 330 c_args : [c_msvc_compat_args], 331 ), 332 suite : ['util'], 333 ) 334 335 process_test_exe = executable( 336 'process_test', 337 files('process_test.c'), 338 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 339 dependencies : idep_mesautil, 340 c_args : [c_msvc_compat_args], 341 ) 342 if (host_machine.system() == 'windows' and build_machine.system() != 'windows') 343 # This conversion is only required on mingw crosscompilers, otherwise we hit at least one of these issues 344 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2690 345 # https://gitlab.freedesktop.org/mesa/mesa/-/issues/2788 346 prog_winepath = find_program('winepath') 347 process_test_exe_full_path = run_command( 348 prog_winepath, '-w', process_test_exe.full_path() 349 ).stdout().strip() 350 else 351 process_test_exe_full_path = process_test_exe.full_path() 352 endif 353 354 test( 355 'process', 356 process_test_exe, 357 suite : ['util'], 358 env: ['BUILD_FULL_PATH='+process_test_exe_full_path] 359 ) 360 361 subdir('tests/fast_idiv_by_const') 362 subdir('tests/fast_urem_by_const') 363 subdir('tests/hash_table') 364 if not (host_machine.system() == 'windows' and cc.get_id() == 'gcc') 365 # FIXME: These tests fail with mingw, but not with msvc. 366 subdir('tests/string_buffer') 367 endif 368 if cc.has_header('sys/time.h') # MinGW has this, but Vanilla windows doesn't 369 subdir('tests/timespec') 370 endif 371 subdir('tests/vma') 372 subdir('tests/set') 373 subdir('tests/sparse_array') 374 subdir('tests/format') 375 subdir('tests/vector') 376endif 377