diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-07-01 09:58:42 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-07-09 10:10:52 +0900 |
commit | 1e21cbfada87f697a2a7c450542a7d28925abee6 (patch) | |
tree | cbc197d95ca2fb327678bdd5276600ae3ddc72f8 /scripts | |
parent | c93a0368aaa2962e6c89da20f79b8789b42e3387 (diff) | |
download | linux-1e21cbfada87f697a2a7c450542a7d28925abee6.tar.bz2 |
kbuild: support header-test-pattern-y
In my view, most of headers can be self-contained. So, it would be
tedious to add every header to header-test-y explicitly. We usually
end up with "all headers with some exceptions".
There are two types in exceptions:
[1] headers that are never compiled as standalone units
For examples, include/linux/compiler-gcc.h is not intended for
direct inclusion. We should always exclude such ones.
[2] headers that are conditionally compiled as standalone units
Some headers can be compiled only for particular architectures.
For example, include/linux/arm-cci.h can be compiled only for
arm/arm64 because it requires <asm/arm-cci.h> to exist.
Clang can compile include/soc/nps/mtm.h only for arc because
it contains an arch-specific register in inline assembler.
So, you can write Makefile like this:
header-test- += linux/compiler-gcc.h
header-test-$(CONFIG_ARM) += linux/arm-cci.h
header-test-$(CONFIG_ARM64) += linux/arm-cci.h
header-test-$(CONFIG_ARC) += soc/nps/mtm.h
The new syntax header-test-pattern-y will be useful to specify
"the rest".
The typical usage is like this:
header-test-pattern-y += */*.h
This will add all the headers in sub-directories to the test coverage,
excluding $(header-test-). In this regards, header-test-pattern-y
behaves like a weaker variant of header-test-y.
Caveat:
The patterns in header-test-pattern-y are prefixed with $(srctree)/$(src)/
but not $(objtree)/$(obj)/. Stale generated headers are often left over
when you traverse the git history without cleaning. Wildcard patterns for
$(objtree) may match to stale headers, which could fail to compile.
One pitfall is $(srctree)/$(src)/ and $(objtree)/$(obj)/ point to the
same directory for in-tree building. So, header-test-pattern-y should
be used with care since it can potentially match to stale headers.
Caveat2:
You could use wildcard for header-test-. For example,
header-test- += asm-generic/%
... will exclude headers in asm-generic directory. Unfortunately, the
wildcard character is '%' instead of '*' here because this is evaluated
by $(filter-out ...) whereas header-test-pattern-y is evaluated by
$(wildcard ...). This is a kludge, but seems useful in some places...
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.lib | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 55ae1ec65342..281864fcf0fe 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -67,6 +67,17 @@ extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif # Test self-contained headers + +# Wildcard searches in $(srctree)/$(src)/, but not in $(objtree)/$(obj)/. +# Stale generated headers are often left over, so pattern matching should +# be avoided. Please notice $(srctree)/$(src)/ and $(objtree)/$(obj) point +# to the same location for in-tree building. So, header-test-pattern-y should +# be used with care. +header-test-y += $(filter-out $(header-test-), \ + $(patsubst $(srctree)/$(src)/%, %, \ + $(wildcard $(addprefix $(srctree)/$(src)/, \ + $(header-test-pattern-y))))) + extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y)) # Add subdir path |