Use make to generate the test command

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
Dave Rodgman 2023-10-03 15:47:05 +01:00
parent 43a5ce8c7f
commit 4243610c15

View file

@ -3946,9 +3946,24 @@ build_test_config_combos() {
shift
OPTIONS=("$@")
# clear all of the options so that they can be overridden on the clang commandline
for OPT in "${OPTIONS[@]}"; do
./scripts/config.py unset ${OPT}
done
# enter the directory containing the target file & strip the dir from the filename
cd $(dirname ${FILE})
FILE=$(basename ${FILE})
# The most common issue is unused variables/functions, so ensure -Wunused is set.
WARNING_FLAGS="-Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused"
# Extract the command generated by the Makefile to build the target file.
# This ensures that we have any include paths, macro definitions, etc
# that may be applied by make.
# Add -fsyntax-only as we only want a syntax check and don't need to generate a file.
MAKE_CMD=$(make -B -n ${FILE} CC=clang CFLAGS="${WARNING_FLAGS} -fsyntax-only" | egrep "^clang")
MAKEFILE=$(mktemp)
DEPS=""
@ -3973,7 +3988,7 @@ build_test_config_combos() {
# if valid, add it to the makefile
if [[ "$INVALID" == "" ]]; then
cmd="clang ${CLANG_ARGS} -fsyntax-only ${FILE} -Iinclude -std=c99 $WARNING_FLAGS"
cmd="${MAKE_CMD} ${CLANG_ARGS}"
echo "${TARGET}:" >> ${MAKEFILE}
echo -e "\t$cmd" >> ${MAKEFILE}
@ -3983,11 +3998,6 @@ build_test_config_combos() {
echo "all: ${DEPS}" >> ${MAKEFILE}
# clear all of the options so that they can be overridden on the clang commandline
for OPT in "${OPTIONS[@]}"; do
./scripts/config.py unset ${OPT}
done
# execute all of the commands via Make (probably in parallel)
make -s -f ${MAKEFILE} all
@ -4015,7 +4025,7 @@ component_build_aes_variations() {
msg "build: aes.o for all combinations of relevant config options"
build_test_config_combos library/aes.c validate_aes_config_variations \
build_test_config_combos library/aes.o validate_aes_config_variations \
"MBEDTLS_AES_SETKEY_ENC_ALT" "MBEDTLS_AES_DECRYPT_ALT" \
"MBEDTLS_AES_ROM_TABLES" "MBEDTLS_AES_ENCRYPT_ALT" "MBEDTLS_AES_SETKEY_DEC_ALT" \
"MBEDTLS_AES_FEWER_TABLES" "MBEDTLS_PADLOCK_C" "MBEDTLS_AES_USE_HARDWARE_ONLY" \