1prog_scan_sh = find_program('scan.sh') 2dep_scanner = dependency('wayland-scanner', native: true) 3prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner')) 4 5libwayland = [ 6 dependency('wayland-client'), 7 dependency('wayland-server'), 8] 9 10# Check that each protocol passes through the scanner 11foreach protocol_file : protocol_files 12 protocol_path = join_paths(wayland_protocols_srcdir, protocol_file) 13 test_name = 'scan-@0@'.format(protocol_file.underscorify()) 14 test(test_name, prog_scan_sh, 15 args: protocol_path, 16 env: [ 17 'SCANNER=@0@'.format(prog_scanner.path()), 18 ] 19 ) 20endforeach 21 22# Check buildability 23 24add_languages('c', 'cpp', native: false) 25replace = find_program('replace.py') 26 27extra_linker_flags = meson.get_compiler('c').get_supported_link_arguments([ 28 '-Wl,--unresolved-symbols=ignore-all', 29]) 30 31foreach protocol_file : protocol_files 32 xml_file = fs.name(protocol_file) 33 xml_components = xml_file.split('.') 34 protocol_base_file_name = xml_components[0] 35 36 protocol_path = files(join_paths(wayland_protocols_srcdir, protocol_file)) 37 client_header_path = '@0@-client.h'.format(protocol_base_file_name) 38 server_header_path = '@0@-server.h'.format(protocol_base_file_name) 39 code_path = '@0@-code.c'.format(protocol_base_file_name) 40 client_header = custom_target( 41 client_header_path, 42 output: client_header_path, 43 input: protocol_path, 44 command: [ 45 prog_scanner, 46 '--strict', 47 'client-header', 48 '@INPUT@', 49 '@OUTPUT@', 50 ], 51 install: false, 52 ) 53 server_header = custom_target( 54 server_header_path, 55 output: server_header_path, 56 input: protocol_path, 57 command: [ 58 prog_scanner, 59 '--strict', 60 'server-header', 61 '@INPUT@', 62 '@OUTPUT@', 63 ], 64 install: false, 65 ) 66 code = custom_target( 67 code_path, 68 output: code_path, 69 input: protocol_path, 70 command: [ 71 prog_scanner, 72 '--strict', 73 'private-code', 74 '@INPUT@', 75 '@OUTPUT@', 76 ], 77 install: false, 78 ) 79 80 replace_command = [ 81 replace, 82 '@INPUT@', 83 '@OUTPUT@', 84 'PROTOCOL_CLIENT_INCLUDE_FILE', 85 client_header.full_path(), 86 'PROTOCOL_SERVER_INCLUDE_FILE', 87 server_header.full_path(), 88 ] 89 90 # Check that header can be included by a pedantic C99 compiler 91 test_name = 'test-build-pedantic-@0@'.format(protocol_file.underscorify()) 92 test_name_source = '@0@.c'.format(test_name) 93 test_source = custom_target( 94 test_name_source, 95 input: 'build-pedantic.c.in', 96 output: test_name_source, 97 command: replace_command, 98 ) 99 pedantic_test_executable = executable( 100 test_name, 101 [ 102 test_source, 103 client_header, 104 server_header, 105 code 106 ], 107 link_args: extra_linker_flags, 108 dependencies: libwayland, 109 c_args: [ 110 '-std=c99', 111 '-pedantic', 112 '-Wall', 113 '-Werror' ], 114 install: false, 115 ) 116 test(test_name, pedantic_test_executable) 117 118 # Check that the header 119 if not protocol_file.contains('xdg-foreign-unstable-v1') 120 test_name = 'test-build-cxx-@0@'.format(protocol_file.underscorify()) 121 test_name_source = '@0@.cc'.format(test_name) 122 test_source = custom_target( 123 test_name_source, 124 input: 'build-cxx.cc.in', 125 output: test_name_source, 126 command: replace_command, 127 ) 128 cxx_test_executable = executable( 129 test_name, 130 [ 131 test_source, 132 client_header, 133 server_header, 134 ], 135 link_args: extra_linker_flags, 136 dependencies: libwayland, 137 cpp_args: [ 138 '-Wall', 139 '-Werror', 140 ], 141 install: false, 142 ) 143 test(test_name, cxx_test_executable) 144 endif 145endforeach 146