From 6ca7359d0bf87b11c0f68b13a3fe68d10ba4a9d7 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 29 Aug 2025 16:03:08 +0200 Subject: [PATCH] WIP: clang-tidy --- hw/kdrive/ephyr/meson.build | 2 ++ hw/vfb/meson.build | 2 ++ hw/xfree86/meson.build | 9 +++++++-- hw/xnest/meson.build | 2 +- meson.build | 26 +++++++++++++++++++++++++- 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/hw/kdrive/ephyr/meson.build b/hw/kdrive/ephyr/meson.build index 42ec9dab2..2a42e6781 100644 --- a/hw/kdrive/ephyr/meson.build +++ b/hw/kdrive/ephyr/meson.build @@ -73,3 +73,5 @@ xephyr_man = configure_file( configuration: manpage_config, ) install_man(xephyr_man) + +tidy_candidates += xephyr_server diff --git a/hw/vfb/meson.build b/hw/vfb/meson.build index 891bb75b4..7061c7958 100644 --- a/hw/vfb/meson.build +++ b/hw/vfb/meson.build @@ -28,3 +28,5 @@ install_man(configure_file( output: 'Xvfb.1', configuration: manpage_config, )) + +tidy_candidates += xvfb_server diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build index 5b1e51dbd..1c4d328ab 100644 --- a/hw/xfree86/meson.build +++ b/hw/xfree86/meson.build @@ -120,6 +120,8 @@ e = executable( implib: true, ) +tidy_candidates += e + # subdirs for modules loadable by Xorg subdir('dixmods') subdir('exa') @@ -147,7 +149,7 @@ meson.add_install_script( join_paths(get_option('prefix'), get_option('bindir'), 'X'))) if get_option('suid_wrapper') - executable('Xorg.wrap', + tidy_candidates += executable('Xorg.wrap', 'xorg-wrapper.c', include_directories: [inc, xorg_inc], dependencies: xorg_deps, @@ -173,7 +175,7 @@ if get_option('suid_wrapper') ) endif -executable('gtf', +tidy_candidates += executable('gtf', 'utils/gtf/gtf.c', include_directories: [inc, xorg_inc], dependencies: xorg_deps, @@ -181,6 +183,7 @@ executable('gtf', install: true, ) + # For symbol presence testing only xorgserver_lib = shared_library( 'xorgserver', @@ -193,6 +196,8 @@ xorgserver_lib = shared_library( install: false, ) +tidy_candidates += xorgserver_lib + xorgserver_dep = declare_dependency(link_with: xorgserver_lib) install_man(configure_file( diff --git a/hw/xnest/meson.build b/hw/xnest/meson.build index d01b871db..b77fe38ff 100644 --- a/hw/xnest/meson.build +++ b/hw/xnest/meson.build @@ -27,7 +27,7 @@ xcb_shape_dep = dependency('xcb-shape', required: true) xcb_icccm_dep = dependency('xcb-icccm', required: true) xcb_xkb_dep = dependency('xcb-xkb', required: true) -executable( +tidy_candidates += executable( 'Xnest', srcs, include_directories: inc, diff --git a/meson.build b/meson.build index 907301f25..aeaa56d27 100644 --- a/meson.build +++ b/meson.build @@ -19,7 +19,6 @@ add_project_link_arguments('-fvisibility=hidden', language : 'c') if cc.get_id() == 'gcc' or cc.get_id() == 'clang' test_wflags = [ - '-pedantic', '-Wall', '-Wpointer-arith', '-Wmissing-declarations', @@ -656,6 +655,8 @@ if serverconfigdir == '' serverconfigdir = join_paths(get_option('prefix'), get_option('libdir'), 'xorg') endif +tidy_candidates = [] + subdir('man') require_docs = get_option('docs') == 'true' @@ -870,3 +871,26 @@ configure_file(output : 'xorg-server.h', configuration : conf_data, install: build_xorg, install_dir: xorgsdkdir) + +clangtidy = find_program('clang-tidy', required : false) + +if clangtidy.found() + tidy_opts = [ + '--checks=-*,clang-analyzer-core.uninitialized.*', + '--', + '-std=c11' + ] + + tidy_targets = [] + foreach s : tidy_candidates + tidy_targets += custom_target( + 'tidy-' + s.name(), + input: s.sources(), + output: 'tidy-' + s.name() + '.log', + command: [clangtidy, '@INPUT@'] + tidy_opts, + capture: true + ) + endforeach + + run_target('clang-tidy-all', command: ['true'], depends: tidy_targets) +endif