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