5f3d85735af623473688908fc4b41c99f5218190
[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 'pp_standalone_scaffolding.c')],
52 dependencies : idep_mesautil,
53 include_directories : [inc_common],
54 c_args : [c_vis_args, no_override_init_args, c_msvc_compat_args, _extra_args],
55 cpp_args : [cpp_vis_args, cpp_msvc_compat_args, _extra_args],
56 build_by_default : false,
57 )
58
59 glcpp = executable(
60 'glcpp',
61 'glcpp.c',
62 dependencies : [dep_m, idep_getopt],
63 include_directories : [inc_common],
64 link_with : [libglcpp, libglsl_util],
65 c_args : [c_vis_args, no_override_init_args, c_msvc_compat_args],
66 build_by_default : false,
67 )
68
69 # FIXME: these fail on windows due to whitespace differences
70 if with_any_opengl and with_tests and host_machine.system() != 'windows'
71 modes = ['unix', 'windows', 'oldmac', 'bizarro']
72 if dep_valgrind.found()
73 modes += ['valgrind']
74 endif
75
76 foreach m : modes
77 test(
78 'glcpp test (@0@)'.format(m),
79 prog_python,
80 args : [
81 join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'),
82 glcpp, join_paths(meson.current_source_dir(), 'tests'),
83 '--@0@'.format(m),
84 ],
85 suite : ['compiler', 'glcpp'],
86 timeout: 60,
87 )
88 endforeach
89 endif