diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index b4ab5769ae..5aca56290d 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -74,4 +74,4 @@ jobs: run: mkosi sandbox -- env CC=clang CXX=clang++ meson setup build - name: Run clang-tidy - run: mkosi sandbox -- ninja -C build clang-tidy + run: mkosi sandbox -- meson test -C build --suite=clang-tidy --print-errorlogs --no-stdsplit diff --git a/meson.build b/meson.build index aeff1b3629..5dd5f348aa 100644 --- a/meson.build +++ b/meson.build @@ -15,7 +15,7 @@ project('systemd', 'c', add_test_setup( 'default', - exclude_suites : ['integration-tests'], + exclude_suites : ['clang-tidy', 'integration-tests'], is_default : true, ) @@ -2002,6 +2002,7 @@ executables_by_name = {} objects_by_name = {} fuzzer_exes = [] generated_sources = [version_h, vmlinux_h_dependency] +sources = [] # binaries that have --help and are intended for use by humans, # usually, but not always, installed in /bin. @@ -2470,6 +2471,10 @@ foreach dict : executables executables_by_name += { name : exe } + if not name.endswith('.standalone') + sources += dict.get('sources', []) + endif + if dict.has_key('extract') objects_by_name += { name : { @@ -2829,23 +2834,32 @@ endif alias_target('gensources', generated_sources) -run_clang_tidy = find_program('run-clang-tidy', required : false) -if run_clang_tidy.found() - run_target( - 'clang-tidy', - command : [ - run_clang_tidy, - '-use-color', - '-quiet', - '-p', meson.project_build_root(), - # There seems to be a bug in clang-tidy where by even with --quiet some - # messages from clang's own diagnostics engine leak through: - # X warnings generated. - # Until this is fixed upstream, we use -fno-caret-diagnostics to suppress these. - '-extra-arg=-fno-caret-diagnostics', - ], - depends : generated_sources - ) +clang_tidy = find_program('clang-tidy', required : false) +if meson.version().version_compare('>=1.4.0') + foreach source : sources + if fs.name(source).endswith('.h') + continue + endif + + inputs = [source] + + header = source.full_path().replace('.c', '.h') + if fs.exists(header) + inputs += header + endif + + foreach input : inputs + if clang_tidy.found() + test( + 'clang-tidy-@0@'.format(fs.name(input)), + clang_tidy, + args : ['-p', meson.project_build_root(), input], + suite : 'clang-tidy', + depends : generated_sources, + ) + endif + endforeach + endforeach endif check_api_docs_sh = find_program('tools/check-api-docs.sh') diff --git a/src/basic/meson.build b/src/basic/meson.build index 44b90c2e76..df363f6048 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -118,6 +118,8 @@ basic_sources = files( 'xattr-util.c', ) +sources += basic_sources + missing_audit_h = files('missing_audit.h') missing_socket_h = files('missing_socket.h') diff --git a/src/basic/rlimit-util.h b/src/basic/rlimit-util.h index ad48e31550..dd1fef4396 100644 --- a/src/basic/rlimit-util.h +++ b/src/basic/rlimit-util.h @@ -2,6 +2,7 @@ #pragma once #include +#include #include "macro.h" diff --git a/src/basic/uid-range.h b/src/basic/uid-range.h index 197085a60b..e1965cf9b7 100644 --- a/src/basic/uid-range.h +++ b/src/basic/uid-range.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include #include #include diff --git a/src/basic/virt.h b/src/basic/virt.h index 8193d4a760..e4fdaca976 100644 --- a/src/basic/virt.h +++ b/src/basic/virt.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include #include #include "errno-list.h" diff --git a/src/boot/meson.build b/src/boot/meson.build index 48d03b5b80..dffd5db88e 100644 --- a/src/boot/meson.build +++ b/src/boot/meson.build @@ -348,6 +348,11 @@ if host_machine.cpu_family() in ['aarch64', 'arm', 'x86_64', 'x86'] systemd_boot_sources += files('bcd.c') endif +sources += libefi_sources +sources += systemd_boot_sources +sources += stub_sources +sources += addon_sources + boot_targets = [] efi_elf_binaries = [] efi_archspecs = [ diff --git a/src/core/meson.build b/src/core/meson.build index 659dc9b7ea..24843ec789 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -78,6 +78,8 @@ if conf.get('BPF_FRAMEWORK') == 1 restrict_ifaces_skel_h] endif +sources += libcore_sources + load_fragment_gperf_gperf = custom_target( 'load-fragment-gperf.gperf', input : 'load-fragment-gperf.gperf.in', diff --git a/src/core/show-status.h b/src/core/show-status.h index a51616f75a..1986985c21 100644 --- a/src/core/show-status.h +++ b/src/core/show-status.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include #include #include diff --git a/src/fundamental/meson.build b/src/fundamental/meson.build index 5536be6e4c..6bc26caad2 100644 --- a/src/fundamental/meson.build +++ b/src/fundamental/meson.build @@ -13,3 +13,5 @@ fundamental_sources = files( 'string-util-fundamental.c', 'uki.c', ) + +sources += fundamental_sources diff --git a/src/journal/journald-stream.h b/src/journal/journald-stream.h index a22b136049..cb55970059 100644 --- a/src/journal/journald-stream.h +++ b/src/journal/journald-stream.h @@ -1,13 +1,19 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -typedef struct Manager Manager; -typedef struct StdoutStream StdoutStream; -typedef struct StreamSyncReq StreamSyncReq; +#include + +#include "sd-event.h" +#include "sd-id128.h" #include "fdset.h" #include "list.h" +typedef struct ClientContext ClientContext; +typedef struct Manager Manager; +typedef struct StdoutStream StdoutStream; +typedef struct StreamSyncReq StreamSyncReq; + typedef enum StdoutStreamState { STDOUT_STREAM_IDENTIFIER, STDOUT_STREAM_UNIT_ID, diff --git a/src/journal/journald-sync.h b/src/journal/journald-sync.h index 5f042ece96..4ef4aa4952 100644 --- a/src/journal/journald-sync.h +++ b/src/journal/journald-sync.h @@ -1,14 +1,16 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -typedef struct Manager Manager; -typedef struct StreamSyncReq StreamSyncReq; -typedef struct SyncReq SyncReq; +#include "sd-varlink.h" #include "journald-stream.h" #include "list.h" #include "macro.h" +typedef struct Manager Manager; +typedef struct StreamSyncReq StreamSyncReq; +typedef struct SyncReq SyncReq; + /* Encapsulates the synchronization request data we need to keep per STDOUT stream. Primarily a byte counter * to count down. */ struct StreamSyncReq { diff --git a/src/libsystemd-network/meson.build b/src/libsystemd-network/meson.build index a6de329627..6b36c2eb64 100644 --- a/src/libsystemd-network/meson.build +++ b/src/libsystemd-network/meson.build @@ -1,6 +1,6 @@ # SPDX-License-Identifier: LGPL-2.1-or-later -sources = files( +libsystemd_network_sources = files( 'arp-util.c', 'dhcp-network.c', 'dhcp-option.c', @@ -36,9 +36,11 @@ sources = files( 'sd-radv.c', ) +sources += libsystemd_network_sources + libsystemd_network = static_library( 'systemd-network', - sources, + libsystemd_network_sources, include_directories : includes, implicit_include_directories : false, dependencies : userspace, diff --git a/src/libsystemd/meson.build b/src/libsystemd/meson.build index 60b73f4da1..57fc116929 100644 --- a/src/libsystemd/meson.build +++ b/src/libsystemd/meson.build @@ -137,6 +137,8 @@ libsystemd_sources = files( + sd_login_sources + sd_json_sources + sd_varlink_sources \ + sd_path_sources + sd_netlink_sources + sd_network_sources +sources += libsystemd_sources + libsystemd_c_args = ['-fvisibility=default'] libsystemd_static = static_library( diff --git a/src/libudev/meson.build b/src/libudev/meson.build index e5c0c8361b..43959640b9 100644 --- a/src/libudev/meson.build +++ b/src/libudev/meson.build @@ -11,6 +11,8 @@ libudev_sources = files( 'libudev.c', ) +sources += libudev_sources + ############################################################ libudev_includes = [includes, include_directories('.')] diff --git a/src/login/logind-seat.h b/src/login/logind-seat.h index 2dc57686e9..c391363303 100644 --- a/src/login/logind-seat.h +++ b/src/login/logind-seat.h @@ -5,6 +5,7 @@ #include "list.h" #include "memory-util.h" +#include "set.h" #include "string-util.h" #include "time-util.h" diff --git a/src/machine/operation.h b/src/machine/operation.h index 1fd8d42a2e..330ef0bf98 100644 --- a/src/machine/operation.h +++ b/src/machine/operation.h @@ -7,6 +7,7 @@ #include "sd-event.h" #include "sd-varlink.h" +#include "assert-util.h" #include "list.h" typedef struct Machine Machine; diff --git a/src/shared/meson.build b/src/shared/meson.build index d57bd93da1..3f70ddbfd5 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -317,6 +317,7 @@ ethtool_link_mode_h = custom_target( generated_sources += ethtool_link_mode_h shared_sources += ethtool_link_mode_h +sources += shared_sources fname = 'ethtool-link-mode.xml' ethtool_link_mode_xml = custom_target( diff --git a/src/shared/smack-util.h b/src/shared/smack-util.h index e380de3dd7..5bd2cea38b 100644 --- a/src/shared/smack-util.h +++ b/src/shared/smack-util.h @@ -7,6 +7,7 @@ Author: Auke Kok ***/ +#include #include #include diff --git a/src/shared/utmp-wtmp.h b/src/shared/utmp-wtmp.h index 2e04fac404..8577d9b013 100644 --- a/src/shared/utmp-wtmp.h +++ b/src/shared/utmp-wtmp.h @@ -4,6 +4,7 @@ #include #include +#include "assert-util.h" #include "time-util.h" #if ENABLE_UTMP diff --git a/src/sysupdate/sysupdate-partition.h b/src/sysupdate/sysupdate-partition.h index 094d8e0ca4..15324013f3 100644 --- a/src/sysupdate/sysupdate-partition.h +++ b/src/sysupdate/sysupdate-partition.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include #include #include