diff --git a/man/meson.build b/man/meson.build index 488ff702209..22ac236b273 100644 --- a/man/meson.build +++ b/man/meson.build @@ -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