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 21bison_command = [] 22if yacc_is_bison 23 bison_command = [ 24 prog_bison, '-o', '@OUTPUT0@', '-p', 'glcpp_parser_', 25 '--defines=@OUTPUT1@', '@INPUT@', 26 ] 27else 28 bison_command = [ 29 prog_bison, '-o', '@OUTPUT0@', '-p', 'glcpp_parser_', 30 '-H', '@OUTPUT1@', '@INPUT@', 31 ] 32endif 33 34glcpp_parse = custom_target( 35 'glcpp-parse.[ch]', 36 input : 'glcpp-parse.y', 37 output : ['glcpp-parse.c', 'glcpp-parse.h'], 38 command : bison_command 39) 40 41glcpp_lex = custom_target( 42 'glcpp-lex.c', 43 input : 'glcpp-lex.l', 44 output : 'glcpp-lex.c', 45 command : [prog_flex, '-o', '@OUTPUT@', '@INPUT@'], 46) 47 48_extra_args = [] 49if cpp.get_id() == 'msvc' 50 # Flex relies on __STDC_VERSION__>=199901L to decide when to include C99 51 # inttypes.h. We always have inttypes.h available with MSVC (either the one 52 # bundled with MSVC 2013, or the one we bundle ourselves), but we can't just 53 # define __STDC_VERSION__ without breaking stuff, as MSVC doesn't fully 54 # support C99. There's also no way to premptively include stdint. 55 _extra_args += '-FIinttypes.h' 56endif 57 58libglcpp = static_library( 59 'glcpp', 60 [glcpp_lex, glcpp_parse, files('glcpp.h', 'pp.c')], 61 dependencies : idep_mesautil, 62 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 63 c_args : [no_override_init_args, c_msvc_compat_args, _extra_args], 64 cpp_args : [cpp_msvc_compat_args, _extra_args], 65 gnu_symbol_visibility : 'hidden', 66 build_by_default : false, 67) 68 69libglcpp_standalone = static_library( 70 'glcpp_standalone', 71 'pp_standalone_scaffolding.c', 72 link_with : libglcpp, 73 dependencies : idep_mesautil, 74 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 75 c_args : [no_override_init_args, c_msvc_compat_args, _extra_args], 76 cpp_args : [cpp_msvc_compat_args, _extra_args], 77 gnu_symbol_visibility : 'hidden', 78 build_by_default : false, 79) 80 81glcpp = executable( 82 'glcpp', 83 'glcpp.c', 84 dependencies : [dep_m, idep_getopt, idep_mesautil], 85 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], 86 link_with : [libglcpp_standalone, libglsl_util], 87 c_args : [no_override_init_args, c_msvc_compat_args], 88 gnu_symbol_visibility : 'hidden', 89 build_by_default : false, 90) 91 92# Meson can't auto-skip these on cross builds because of the python wrapper 93# 94# TODO: has_exe_wrapper() is deprecated and renamed to can_run_host_binaries() 95# starting with Meson 0.55.0 96# 97# FIXME: these fail on windows due to whitespace differences 98if with_any_opengl and with_tests and meson.has_exe_wrapper() and \ 99 host_machine.system() != 'windows' 100 modes = ['unix', 'windows', 'oldmac', 'bizarro'] 101 102 foreach m : modes 103 test( 104 'glcpp test (@0@)'.format(m), 105 prog_python, 106 args : [ 107 join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'), 108 glcpp, join_paths(meson.current_source_dir(), 'tests'), 109 '--@0@'.format(m), 110 ], 111 suite : ['compiler', 'glcpp'], 112 timeout: 60, 113 ) 114 endforeach 115 116 if dep_valgrind.found() 117 test( 118 'glcpp test (valgrind)', 119 prog_python, 120 args : [ 121 join_paths(meson.current_source_dir(), 'tests/glcpp_test.py'), 122 glcpp, join_paths(meson.current_source_dir(), 'tests'), 123 '--valgrind', 124 ], 125 suite : ['compiler', 'glcpp'], 126 timeout: 240, 127 ) 128 endif 129endif 130