meson: force inclusion of inttypes.h for glcpp with msvc
[mesa.git] / src / compiler / glsl / glcpp / 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 glcpp_parse = custom_target(
22 'glcpp-parse.[ch]',
23 input : 'glcpp-parse.y',
24 output : ['glcpp-parse.c', 'glcpp-parse.h'],
25 command : [
26 prog_bison, '-o', '@OUTPUT0@', '-p', 'glcpp_parser_',
27 '--defines=@OUTPUT1@', '@INPUT@',
28 ],
29 )
30
31 glcpp_lex = custom_target(
32 'glcpp-lex.c',
33 input : 'glcpp-lex.l',
34 output : 'glcpp-lex.c',
35 command : [prog_flex, '-o', '@OUTPUT@', '@INPUT@'],
36 )
37
38 _extra_args = []
39 if cpp.get_id() == 'msvc'
40 # Flex relies on __STDC_VERSION__>=199901L to decide when to include C99
41 # inttypes.h. We always have inttypes.h available with MSVC (either the one
42 # bundled with MSVC 2013, or the one we bundle ourselves), but we can't just
43 # define __STDC_VERSION__ without breaking stuff, as MSVC doesn't fully
44 # support C99. There's also no way to premptively include stdint.
45 _extra_args += '-FIinttypes.h'
46 endif
47
48 libglcpp = static_library(
49 'glcpp',
50 [glcpp_lex, glcpp_parse, files('glcpp.h', 'pp.c')],
51 dependencies : idep_mesautil,
52 include_directories : [inc_common],
53 c_args : [c_vis_args, no_override_init_args, c_msvc_compat_args, _extra_args],
54 cpp_args : [cpp_vis_args, cpp_msvc_compat_args, _extra_args],
55 build_by_default : false,
56 )
57
58 glcpp = executable(
59 'glcpp',
60 'glcpp.c',
61 dependencies : [dep_m],
62 include_directories : [inc_common],
63 link_with : [libglcpp, libglsl_util],
64 c_args : [c_vis_args, no_override_init_args, c_msvc_compat_args],
65 build_by_default : false,
66 )
67
68 if with_any_opengl and with_tests
69 modes = ['unix', 'windows', 'oldmac', 'bizarro']
70 if dep_valgrind.found()
71 modes += ['valgrind']
72 endif
73
74 foreach m : modes
75 test(
76 'glcpp test (@0@)'.format(m),
77 prog_python,
78 args : [
79 join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'),
80 glcpp, join_paths(meson.current_source_dir(), 'tests'),
81 '--@0@'.format(m),
82 ],
83 suite : ['compiler', 'glcpp'],
84 )
85 endforeach
86 endif