Debian Codegraph @

test cases/common/134 compute int/meson.build

raw
1 project('compute int', 'c', 'cpp')
2
3 inc = include_directories('.')
4
5 # Test with C
6 cc = meson.get_compiler('c')
7
8 intsize = cc.compute_int('sizeof(int)', low : 1, high : 16, guess : 4)
9 foobar = cc.compute_int('FOOBAR_IN_FOOBAR_H', prefix : '#include "foobar.h"', include_directories : inc)
10 maxint = cc.compute_int('INT_MAX', prefix: '#include <limits.h>')
11 minint = cc.compute_int('INT_MIN', prefix: '#include <limits.h>')
12
13 # Regression test for the special case -1 that used to fail when cross compiling
14 assert(cc.compute_int('-1') == -1, 'compute_int(-1) failed')
15
16 cd = configuration_data()
17 cd.set('INTSIZE', intsize)
18 cd.set('FOOBAR', foobar)
19 cd.set('CONFIG', 'config.h')
20 cd.set('MAXINT', maxint)
21 cd.set('MININT', minint)
22 configure_file(input : 'config.h.in', output : 'config.h', configuration : cd)
23 s = configure_file(input : 'prog.c.in', output : 'prog.c', configuration : cd)
24
25 e = executable('prog', s)
26 test('compute int test', e)
27
28 # Test with C++
29 cpp = meson.get_compiler('cpp')
30
31 intsize = cpp.compute_int('sizeof(int)')
32 foobar = cpp.compute_int('FOOBAR_IN_FOOBAR_H', prefix : '#include "foobar.h"', include_directories : inc)
33 maxint = cpp.compute_int('INT_MAX', prefix: '#include <limits.h>')
34 minint = cpp.compute_int('INT_MIN', prefix: '#include <limits.h>')
35
36 cdpp = configuration_data()
37 cdpp.set('INTSIZE', intsize)
38 cdpp.set('FOOBAR', foobar)
39 cdpp.set('CONFIG', 'config.hpp')
40 cdpp.set('MAXINT', maxint)
41 cdpp.set('MININT', minint)
42 configure_file(input : 'config.h.in', output : 'config.hpp', configuration : cdpp)
43 spp = configure_file(input : 'prog.c.in', output : 'prog.cc', configuration : cdpp)
44
45 epp = executable('progpp', spp)
46 test('compute int test c++', epp)