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
21glcpp_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
31glcpp_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 = []
39if 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'
46endif
47
48libglcpp = static_library(
49  'glcpp',
50  [glcpp_lex, glcpp_parse, files('glcpp.h', 'pp.c')],
51  dependencies : idep_mesautil,
52  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
53  c_args : [no_override_init_args, c_msvc_compat_args, _extra_args],
54  cpp_args : [cpp_msvc_compat_args, _extra_args],
55  gnu_symbol_visibility : 'hidden',
56  build_by_default : false,
57)
58
59libglcpp_standalone = static_library(
60  'glcpp_standalone',
61  'pp_standalone_scaffolding.c',
62  link_with : libglcpp,
63  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
64  c_args : [no_override_init_args, c_msvc_compat_args, _extra_args],
65  cpp_args : [cpp_msvc_compat_args, _extra_args],
66  gnu_symbol_visibility : 'hidden',
67  build_by_default : false,
68)
69
70glcpp = executable(
71  'glcpp',
72  'glcpp.c',
73  dependencies : [dep_m, idep_getopt],
74  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
75  link_with : [libglcpp_standalone, libglsl_util],
76  c_args : [no_override_init_args, c_msvc_compat_args],
77  gnu_symbol_visibility : 'hidden',
78  build_by_default : false,
79)
80
81# FIXME: these fail on windows due to whitespace differences
82if with_any_opengl and with_tests and host_machine.system() != 'windows'
83  modes = ['unix', 'windows', 'oldmac', 'bizarro']
84  if dep_valgrind.found()
85    modes += ['valgrind']
86  endif
87
88  # For some unfathomable reason, three out of these four tests often time out
89  # when running within CI. On the assumption that there is some
90  # parallelisation badness happening rather than the non-UNIX tests entering
91  # infinite loops, try just marking them as serial-only.
92  #
93  # This should have a negligible impact on runtime since they are quick to
94  # execute.
95  foreach m : modes
96    test(
97      'glcpp test (@0@)'.format(m),
98      prog_python,
99      args : [
100        join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'),
101        glcpp, join_paths(meson.current_source_dir(), 'tests'),
102        '--@0@'.format(m),
103      ],
104      suite : ['compiler', 'glcpp'],
105      timeout: 60,
106      is_parallel: false,
107    )
108  endforeach
109endif
110