d6647c0c5c38d3ccb6809ed5bea2d9a579b78d69
[mesa.git] / src / util / meson.build
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 = include_directories('.')
22
23 subdir('format')
24 subdir('xmlpool')
25
26 files_mesa_util = files(
27 'anon_file.h',
28 'anon_file.c',
29 'bigmath.h',
30 'bitscan.c',
31 'bitscan.h',
32 'bitset.h',
33 'blob.c',
34 'blob.h',
35 'build_id.c',
36 'build_id.h',
37 'compiler.h',
38 'crc32.c',
39 'crc32.h',
40 'dag.c',
41 'debug.c',
42 'debug.h',
43 'disk_cache.c',
44 'disk_cache.h',
45 'double.c',
46 'double.h',
47 'fast_idiv_by_const.c',
48 'fast_idiv_by_const.h',
49 'fnv1a.h',
50 'format_r11g11b10f.h',
51 'format_rgb9e5.h',
52 'format_srgb.h',
53 'futex.h',
54 'half_float.c',
55 'half_float.h',
56 'hash_table.c',
57 'hash_table.h',
58 'imports.c',
59 'imports.h',
60 'list.h',
61 'macros.h',
62 'mesa-sha1.c',
63 'mesa-sha1.h',
64 'os_time.c',
65 'os_time.h',
66 'os_file.c',
67 'os_misc.c',
68 'os_misc.h',
69 'os_socket.c',
70 'os_socket.h',
71 'u_process.c',
72 'u_process.h',
73 'sha1/sha1.c',
74 'sha1/sha1.h',
75 'ralloc.c',
76 'ralloc.h',
77 'rand_xor.c',
78 'rand_xor.h',
79 'rb_tree.c',
80 'rb_tree.h',
81 'register_allocate.c',
82 'register_allocate.h',
83 'rgtc.c',
84 'rgtc.h',
85 'rounding.h',
86 'set.c',
87 'set.h',
88 'simple_list.h',
89 'simple_mtx.h',
90 'slab.c',
91 'slab.h',
92 'softfloat.c',
93 'softfloat.h',
94 'sparse_array.c',
95 'sparse_array.h',
96 'string_buffer.c',
97 'string_buffer.h',
98 'strndup.h',
99 'strtod.c',
100 'strtod.h',
101 'texcompress_rgtc_tmp.h',
102 'timespec.h',
103 'u_atomic.c',
104 'u_atomic.h',
105 'u_dynarray.h',
106 'u_endian.h',
107 'u_queue.c',
108 'u_queue.h',
109 'u_string.h',
110 'u_thread.h',
111 'u_vector.c',
112 'u_vector.h',
113 'u_math.c',
114 'u_math.h',
115 'u_mm.c',
116 'u_mm.h',
117 'u_debug.c',
118 'u_debug.h',
119 'u_debug_memory.c',
120 'u_cpu_detect.c',
121 'u_cpu_detect.h',
122 'vma.c',
123 'vma.h',
124 'xxhash.h',
125 )
126
127 files_drirc = files('00-mesa-defaults.conf')
128
129 install_data(files_drirc, install_dir : join_paths(get_option('datadir'), 'drirc.d'))
130
131 if with_tests
132 prog_xmllint = find_program('xmllint', required : false, native : true)
133 if prog_xmllint.found()
134 test(
135 'drirc xml validation',
136 prog_xmllint,
137 args : ['--noout', '--valid', files_drirc],
138 suite : ['util'],
139 )
140 endif
141 endif
142
143 files_xmlconfig = files(
144 'xmlconfig.c',
145 'xmlconfig.h',
146 )
147
148 format_srgb = custom_target(
149 'format_srgb',
150 input : ['format_srgb.py'],
151 output : 'format_srgb.c',
152 command : [prog_python, '@INPUT0@'],
153 capture : true,
154 )
155
156 deps_for_libmesa_util = [
157 dep_zlib,
158 dep_clock,
159 dep_thread,
160 dep_atomic,
161 dep_m,
162 dep_valgrind,
163 dep_zstd,
164 ]
165
166 if with_platform_android
167 deps_for_libmesa_util += dep_android
168 endif
169
170 _libmesa_util = static_library(
171 'mesa_util',
172 [files_mesa_util, format_srgb],
173 include_directories : inc_common,
174 dependencies : deps_for_libmesa_util,
175 link_with: libmesa_format,
176 c_args : [c_msvc_compat_args, c_vis_args],
177 build_by_default : false
178 )
179
180 idep_mesautil = declare_dependency(
181 link_with : _libmesa_util,
182 include_directories : inc_util,
183 dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m],
184 )
185
186 _libxmlconfig = static_library(
187 'xmlconfig',
188 files_xmlconfig,
189 include_directories : inc_common,
190 dependencies : [idep_mesautil, dep_expat, dep_m],
191 c_args : [
192 c_msvc_compat_args, c_vis_args,
193 '-DSYSCONFDIR="@0@"'.format(
194 join_paths(get_option('prefix'), get_option('sysconfdir'))
195 ),
196 '-DDATADIR="@0@"'.format(
197 join_paths(get_option('prefix'), get_option('datadir'))
198 ),
199 ],
200 build_by_default : false,
201 )
202
203 idep_xmlconfig = declare_dependency(
204 dependencies : [idep_xmlconfig_headers, dep_expat],
205 link_with : _libxmlconfig,
206 )
207
208 if with_tests
209 test(
210 'u_atomic',
211 executable(
212 'u_atomic_test',
213 files('u_atomic_test.c'),
214 include_directories : inc_common,
215 dependencies : idep_mesautil,
216 c_args : [c_msvc_compat_args],
217 ),
218 suite : ['util'],
219 )
220
221 test(
222 'blob',
223 executable(
224 'blob_test',
225 files('blob_test.c'),
226 include_directories : inc_common,
227 dependencies : idep_mesautil,
228 c_args : [c_msvc_compat_args],
229 ),
230 suite : ['util'],
231 )
232
233 test(
234 'rb_tree',
235 executable(
236 'rb_tree_test',
237 files('rb_tree_test.c'),
238 include_directories : inc_common,
239 dependencies : idep_mesautil,
240 c_args : [c_msvc_compat_args],
241 ),
242 suite : ['util'],
243 )
244
245 test(
246 'roundeven',
247 executable(
248 'roundeven_test',
249 files('roundeven_test.c'),
250 include_directories : inc_common,
251 c_args : [c_msvc_compat_args],
252 dependencies : [dep_m],
253 ),
254 suite : ['util'],
255 should_fail : meson.get_cross_property('xfail', '').contains('roundeven'),
256 )
257
258 # FIXME: this test crashes on windows
259 if host_machine.system() != 'windows'
260 test(
261 'mesa-sha1',
262 executable(
263 'mesa-sha1_test',
264 files('mesa-sha1_test.c'),
265 include_directories : inc_common,
266 link_with : _libmesa_util,
267 c_args : [c_msvc_compat_args],
268 ),
269 suite : ['util'],
270 )
271 endif
272
273 test(
274 'bitset',
275 executable(
276 'bitset_test',
277 files('bitset_test.cpp'),
278 include_directories : inc_common,
279 dependencies : [idep_mesautil, idep_gtest],
280 ),
281 suite : ['util'],
282 )
283
284 process_test_exe = executable(
285 'process_test',
286 files('process_test.c'),
287 include_directories : inc_common,
288 dependencies : idep_mesautil,
289 c_args : [c_msvc_compat_args],
290 )
291 if (host_machine.system() == 'windows' and cc.get_id() == 'gcc')
292 # This conversion is only required on mingw
293 process_test_exe_full_path = run_command(
294 'winepath', '-w', process_test_exe.full_path()
295 ).stdout().strip()
296 else
297 process_test_exe_full_path = process_test_exe.full_path()
298 endif
299
300 test(
301 'process',
302 process_test_exe,
303 suite : ['util'],
304 env: ['BUILD_FULL_PATH='+process_test_exe_full_path]
305 )
306
307 subdir('tests/fast_idiv_by_const')
308 subdir('tests/fast_urem_by_const')
309 subdir('tests/hash_table')
310 if not (host_machine.system() == 'windows' and cc.get_id() == 'gcc')
311 # FIXME: These tests fail with mingw, but not with msvc.
312 subdir('tests/string_buffer')
313 endif
314 if cc.has_header('sys/time.h') # MinGW has this, but Vanilla windows doesn't
315 subdir('tests/timespec')
316 endif
317 subdir('tests/vma')
318 subdir('tests/set')
319 # FIXME: this test on the Wine version in GitLab CI
320 if host_machine.system() != 'windows'
321 subdir('tests/sparse_array')
322 endif
323 subdir('tests/format')
324 subdir('tests/vector')
325 endif