Skip to content

Commit 62ae456

Browse files
committed
drm: ensure drm headers are self-contained and pass kernel-doc
Ensure drm headers build, are self-contained, have header guards, and have no kernel-doc warnings, when CONFIG_DRM_HEADER_TEST=y. The mechanism follows similar patters used in i915, xe, and usr/include. To cover include/drm, we need to recurse there using the top level Kbuild and the new include/Kbuild files. v4: check for CONFIG_WERROR in addition to CONFIG_DRM_WERROR v3: adapt to upstream build changes v2: make DRM_HEADER_TEST depend on DRM Suggested-by: Daniel Vetter <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: Masahiro Yamada <[email protected]> Acked-by: Thomas Zimmermann <[email protected]> Acked-by: Simona Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/d8ad1c6d707f38a55987f616cb9650aef30b84e1.1737556766.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]>
1 parent 48ca4a1 commit 62ae456

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

Diff for: Kbuild

+1
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,4 @@ obj-$(CONFIG_SAMPLES) += samples/
9797
obj-$(CONFIG_NET) += net/
9898
obj-y += virt/
9999
obj-y += $(ARCH_DRIVERS)
100+
obj-$(CONFIG_DRM_HEADER_TEST) += include/

Diff for: drivers/gpu/drm/Kconfig

+11
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,17 @@ config DRM_WERROR
494494

495495
If in doubt, say N.
496496

497+
config DRM_HEADER_TEST
498+
bool "Ensure DRM headers are self-contained and pass kernel-doc"
499+
depends on DRM && EXPERT
500+
default n
501+
help
502+
Ensure the DRM subsystem headers both under drivers/gpu/drm and
503+
include/drm compile, are self-contained, have header guards, and have
504+
no kernel-doc warnings.
505+
506+
If in doubt, say N.
507+
497508
endif
498509

499510
# Separate option because drm_panel_orientation_quirks.c is shared with fbdev

Diff for: drivers/gpu/drm/Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,21 @@ obj-y += solomon/
222222
obj-$(CONFIG_DRM_SPRD) += sprd/
223223
obj-$(CONFIG_DRM_LOONGSON) += loongson/
224224
obj-$(CONFIG_DRM_POWERVR) += imagination/
225+
226+
# Ensure drm headers are self-contained and pass kernel-doc
227+
hdrtest-files := \
228+
$(shell cd $(src) && find . -maxdepth 1 -name 'drm_*.h') \
229+
$(shell cd $(src) && find display lib -name '*.h')
230+
231+
always-$(CONFIG_DRM_HEADER_TEST) += \
232+
$(patsubst %.h,%.hdrtest, $(hdrtest-files))
233+
234+
# Include the header twice to detect missing include guard.
235+
quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
236+
cmd_hdrtest = \
237+
$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
238+
$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
239+
touch $@
240+
241+
$(obj)/%.hdrtest: $(src)/%.h FORCE
242+
$(call if_changed_dep,hdrtest)

Diff for: include/Kbuild

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-$(CONFIG_DRM_HEADER_TEST) += drm/

Diff for: include/drm/Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
# Ensure drm headers are self-contained and pass kernel-doc
4+
hdrtest-files := \
5+
$(shell cd $(src) && find * -name '*.h' 2>/dev/null)
6+
7+
always-$(CONFIG_DRM_HEADER_TEST) += \
8+
$(patsubst %.h,%.hdrtest, $(hdrtest-files))
9+
10+
# Include the header twice to detect missing include guard.
11+
quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
12+
cmd_hdrtest = \
13+
$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
14+
$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
15+
touch $@
16+
17+
$(obj)/%.hdrtest: $(src)/%.h FORCE
18+
$(call if_changed_dep,hdrtest)

0 commit comments

Comments
 (0)