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