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