mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
man/meson: add simple build test for example code
This commit is contained in:
parent
e10409ad55
commit
e98d4c3599
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue