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