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