Generate cpp_cummy_build.cpp dynamically

Generate programs/test/cpp_dummy_build.cpp dynamically instead of
maintaining it manually. This removes the need to update it when the list of
headers changes.

Include all the headers unconditionally except for the ones that cannot be
included directly.

Support this dynamic generation both with make and with cmake.

Adapt all.sh accordingly. Remove the redundant C build from
component_build_default_make_gcc_and_cxx (it was also done in
component_test_default_out_of_box), leaving a component_test_make_cxx. Also
run the C++ program, because why not. Do this in the full configuration
which may catch a bit more problems in headers.

Fixes #2570 for good.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-07-09 15:19:28 +02:00
parent 7238503642
commit 03ab544832
6 changed files with 109 additions and 116 deletions

View file

@ -368,14 +368,6 @@ check_tools()
done
}
check_headers_in_cpp () {
ls include/mbedtls | grep "\.h$" >headers.txt
<programs/test/cpp_dummy_build.cpp sed -n 's/"$//; s!^#include "mbedtls/!!p' |
sort |
diff headers.txt -
rm headers.txt
}
pre_parse_command_line () {
COMMAND_LINE_COMPONENTS=
all_except=0
@ -1406,15 +1398,13 @@ component_build_key_exchanges () {
tests/scripts/key-exchanges.pl
}
component_build_default_make_gcc_and_cxx () {
msg "build: Unix make, -Os (gcc)" # ~ 30s
make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
component_test_make_cxx () {
msg "build: Unix make, full, gcc + g++"
scripts/config.py full
make TEST_CPP=1 lib programs
msg "test: verify header list in cpp_dummy_build.cpp"
check_headers_in_cpp
msg "build: Unix make, incremental g++"
make TEST_CPP=1
msg "test: cpp_dummy_build"
programs/test/cpp_dummy_build
}
component_build_module_alt () {