kbuild: add support for ensuring headers are self-contained

Sometimes it's useful to be able to explicitly ensure certain headers
remain self-contained, i.e. that they are compilable as standalone
units, by including and/or forward declaring everything they depend on.

Add special target header-test-y where individual Makefiles can add
headers to be tested if CONFIG_HEADER_TEST is enabled. This will
generate a dummy C file per header that gets built as part of extra-y.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
Jani Nikula
2019-06-04 15:42:48 +03:00
committed by Masahiro Yamada
parent 0315bb7a25
commit e846f0dc57
9 changed files with 32 additions and 12 deletions

View File

@@ -294,6 +294,15 @@ quiet_cmd_cc_lst_c = MKLST $@
$(obj)/%.lst: $(src)/%.c FORCE
$(call if_changed_dep,cc_lst_c)
# Dummy C sources for header test (header-test-y target)
# ---------------------------------------------------------------------------
quiet_cmd_header_test = HDRTEST $@
cmd_header_test = echo "\#include \"$*.h\"" > $@
$(obj)/%.hdrtest.c:
$(call cmd,header_test)
# Compile assembler sources (.S)
# ---------------------------------------------------------------------------