66d097783cc9784e62c88f37fd00eded38004713
[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 '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_mm.c',
112 'u_mm.h',
113 'u_debug.c',
114 'u_debug.h',
115 'u_cpu_detect.c',
116 'u_cpu_detect.h',
117 'vma.c',
118 'vma.h',
119 'xxhash.h',
120 )
121
122 files_drirc = files('00-mesa-defaults.conf')
123
124 install_data(files_drirc, install_dir : join_paths(get_option('datadir'), 'drirc.d'))
125
126 if with_tests
127 prog_xmllint = find_program('xmllint', required : false, native : true)
128 if prog_xmllint.found()
129 test(
130 'drirc xml validation',
131 prog_xmllint,
132 args : ['--noout', '--valid', files_drirc],
133 suite : ['util'],
134 )
135 endif
136 endif
137
138 files_xmlconfig = files(
139 'xmlconfig.c',
140 'xmlconfig.h',
141 )
142
143 format_srgb = custom_target(
144 'format_srgb',
145 input : ['format_srgb.py'],
146 output : 'format_srgb.c',
147 command : [prog_python, '@INPUT0@'],
148 capture : true,
149 )
150
151 deps_for_libmesa_util = [
152 dep_zlib,
153 dep_clock,
154 dep_thread,
155 dep_atomic,
156 dep_m,
157 dep_valgrind,
158 dep_zstd,
159 ]
160
161 if with_platform_android
162 deps_for_libmesa_util += dep_android
163 endif
164
165 _libmesa_util = static_library(
166 'mesa_util',
167 [files_mesa_util, format_srgb],
168 include_directories : inc_common,
169 dependencies : deps_for_libmesa_util,
170 link_with: libmesa_format,
171 c_args : [c_msvc_compat_args, c_vis_args],
172 build_by_default : false
173 )
174
175 idep_mesautil = declare_dependency(
176 link_with : _libmesa_util,
177 include_directories : inc_util,
178 dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m],
179 )
180
181 _libxmlconfig = static_library(
182 'xmlconfig',
183 files_xmlconfig,
184 include_directories : inc_common,
185 dependencies : [idep_mesautil, dep_expat, dep_m],
186 c_args : [
187 c_msvc_compat_args, c_vis_args,
188 '-DSYSCONFDIR="@0@"'.format(
189 join_paths(get_option('prefix'), get_option('sysconfdir'))
190 ),
191 '-DDATADIR="@0@"'.format(
192 join_paths(get_option('prefix'), get_option('datadir'))
193 ),
194 ],
195 build_by_default : false,
196 )
197
198 idep_xmlconfig = declare_dependency(
199 dependencies : [idep_xmlconfig_headers, dep_expat],
200 link_with : _libxmlconfig,
201 )
202
203 if with_tests
204 test(
205 'u_atomic',
206 executable(
207 'u_atomic_test',
208 files('u_atomic_test.c'),
209 include_directories : inc_common,
210 dependencies : idep_mesautil,
211 c_args : [c_msvc_compat_args],
212 ),
213 suite : ['util'],
214 )
215
216 test(
217 'blob',
218 executable(
219 'blob_test',
220 files('blob_test.c'),
221 include_directories : inc_common,
222 dependencies : idep_mesautil,
223 c_args : [c_msvc_compat_args],
224 ),
225 suite : ['util'],
226 )
227
228 test(
229 'rb_tree',
230 executable(
231 'rb_tree_test',
232 files('rb_tree_test.c'),
233 include_directories : inc_common,
234 dependencies : idep_mesautil,
235 c_args : [c_msvc_compat_args],
236 ),
237 suite : ['util'],
238 )
239
240 test(
241 'roundeven',
242 executable(
243 'roundeven_test',
244 files('roundeven_test.c'),
245 include_directories : inc_common,
246 c_args : [c_msvc_compat_args],
247 dependencies : [dep_m],
248 ),
249 suite : ['util'],
250 )
251
252 # FIXME: this test crashes on windows
253 if host_machine.system() != 'windows'
254 test(
255 'mesa-sha1',
256 executable(
257 'mesa-sha1_test',
258 files('mesa-sha1_test.c'),
259 include_directories : inc_common,
260 link_with : _libmesa_util,
261 c_args : [c_msvc_compat_args],
262 ),
263 suite : ['util'],
264 )
265 endif
266
267 test(
268 'bitset',
269 executable(
270 'bitset_test',
271 files('bitset_test.cpp'),
272 include_directories : inc_common,
273 dependencies : [idep_mesautil, idep_gtest],
274 ),
275 suite : ['util'],
276 )
277
278 subdir('tests/fast_idiv_by_const')
279 subdir('tests/fast_urem_by_const')
280 subdir('tests/hash_table')
281 if not (host_machine.system() == 'windows' and cc.get_id() == 'gcc')
282 # FIXME: These tests fail with mingw, but not with msvc.
283 subdir('tests/string_buffer')
284 endif
285 if cc.has_header('sys/time.h') # MinGW has this, but Vanilla windows doesn't
286 subdir('tests/timespec')
287 endif
288 subdir('tests/vma')
289 subdir('tests/set')
290 subdir('tests/sparse_array')
291 subdir('tests/format')
292 subdir('tests/vector')
293 endif