man/meson: add simple build test for example code

This commit is contained in:
Yu Watanabe 2024-04-03 03:42:55 +09:00
parent e10409ad55
commit e98d4c3599

View file

@ -248,3 +248,87 @@ update_man_rules = custom_target(
'@0@/man/*.xml'.format(project_source_root),
'@0@/rules/meson.build'.format(meson.current_source_dir())],
depends : man_page_depends)
############################################################
simple_examples = files(
'event-quick-child.c',
'hwdb-usb-device.c',
'id128-app-specific.c',
'inotify-watch-tmp.c',
'journal-enumerate-fields.c',
'journal-iterate-foreach.c',
'journal-iterate-poll.c',
'journal-iterate-unique.c',
'journal-iterate-wait.c',
'journal-stream-fd.c',
'logcontrol-example.c',
'notify-selfcontained-example.c',
'path-documents.c',
'print-unit-path-call-method.c',
'print-unit-path.c',
'sd-bus-container-append.c',
'sd-bus-container-read.c',
'sd_bus_error-example.c',
'sd_bus_service_reconnect.c',
'send-unit-files-changed.c',
'vtable-example.c',
)
examples = []
foreach example : simple_examples
examples += [ { 'file' : example } ]
endforeach
if conf.get('HAVE_GLIB') == 1
examples += [
{
'file' : files('glib-event-glue.c'),
'opts' : [
'-I', libglib.get_variable('includedir') / 'glib-2.0',
'-I', libglib.get_variable('libdir') / 'glib-2.0/include',
],
},
]
endif
default_args = [
cc.cmd_array(),
'-c',
'-x', 'c',
'-pedantic',
'-Wall',
'-Werror',
'-Wextra',
'-Wno-unused-parameter',
'-o', '/dev/null',
'-I', meson.current_source_dir() / '../src',
]
std_args_in = [
[ '-std=c99', '-D_GNU_SOURCE', ],
[ '-std=c11', '-D_GNU_SOURCE', ],
[ '-std=c17', '-D_GNU_SOURCE', ],
[ '-std=c23', '-D_GNU_SOURCE', ],
[ '-std=gnu99', ],
[ '-std=gnu11', ],
[ '-std=gnu17', ],
[ '-std=gnu23', ],
]
std_args = []
foreach std : std_args_in
if cc.has_argument(std[0])
std_args += [std]
endif
endforeach
foreach item : examples
foreach std : std_args
file = item.get('file')
test('cc-' + fs.stem(file) + '-' + std[0].split('=')[1],
env,
suite : 'example',
args : default_args + std + item.get('opts', []) + [file])
endforeach
endforeach