Files
xen/automation/eclair_analysis/build.sh
T
Nicola Vetrini ddf664a557 automation/eclair: make the docs for MISRA C:2012 Dir 4.1 visible to ECLAIR
To be able to check for the existence of the necessary subsections in
the documentation for MISRA C:2012 Dir 4.1, ECLAIR needs to have a source
file that is built.

This file is generated from 'C-runtime-failures.rst' in docs/misra
and the configuration is updated accordingly.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2023-11-29 18:25:38 +01:00

68 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Stop immediately if any executed command has exit status different from 0.
set -e
script_name="$(basename "$0")"
fatal() {
echo "${script_name}: $*" >&2
exit 1
}
usage() {
fatal "Usage: ${script_name} <ARM64|X86_64>"
}
if [ $# -ne 1 ]; then
usage
fi
if [ "$1" = "X86_64" ]; then
export CROSS_COMPILE=
export XEN_TARGET_ARCH=x86_64
elif [ "$1" = "ARM64" ]; then
export CROSS_COMPILE=aarch64-linux-gnu-
export XEN_TARGET_ARCH=arm64
else
fatal "Unknown configuration: $1"
fi
if [[ -f /proc/cpuinfo ]]; then
PROCESSORS=$(grep -c ^processor /proc/cpuinfo)
else
PROCESSORS=6
fi
# Variables driving the build
CC=${CROSS_COMPILE}gcc-12
CXX=${CROSS_COMPILE}g++-12
runtime_failures_docs() {
doc="C-runtime-failures.rst"
builddir="automation/eclair_analysis"
cd "${builddir}"
printf "/*\n\n" >"${doc}.c"
sed -e 's|\*/|*//*|g' "../../docs/misra/${doc}" >>"${doc}.c"
# At least a dummy decl is needed to comply with the C standard.
printf "\n\n*/\ntypedef int dummy_typedef;\n" >>"${doc}.c"
# The C language standard applicable to Xen is C99 (with extensions),
# therefore even this dummy file needs to be compiled with -std=c99.
# Cannot redirect to /dev/null because it would be excluded from the analysis
"${CC}" -std=c99 -c "${doc}.c" -o "${doc}.o"
cd -
}
(
runtime_failures_docs
make "-j${PROCESSORS}" "-l${PROCESSORS}.0" \
"CROSS_COMPILE=${CROSS_COMPILE}" \
"CC=${CC}" \
"CXX=${CXX}" \
"XEN_TARGET_ARCH=${XEN_TARGET_ARCH}" \
-C xen
)