mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
Add a debian container with cppcheck installation routine inside, capable of performing cppcheck analysis on Xen-only build including cross-builds for arm32 and x86_64. Populate build jobs making use of that container to run cppcheck analysis to produce a text report (xen-cppcheck.txt) containing the list of all the findings. This patch does not aim at performing any sort of bisection. Cppcheck is imperfect and for now, our goal is to at least be aware of its reports, so that we can compare them with the ones produced by better tools and to be able to see how these reports change as a result of further infrastructure improvements (e.g. exception list, rules exclusion). Signed-off-by: Michal Orzel <michal.orzel@amd.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
105 lines
3.5 KiB
Python
Executable File
105 lines
3.5 KiB
Python
Executable File
#!/bin/bash -ex
|
|
|
|
test -f /etc/os-release && cat "$_"
|
|
|
|
# Construct $cc such that it matches what `make` will chose when taking
|
|
# CROSS_COMPILE into account. Do not modify $CC directly, as that will cause
|
|
# `make` to double-account CROSS_COMPILE.
|
|
cc="${CROSS_COMPILE}${CC}"
|
|
|
|
$cc --version
|
|
|
|
# random config or default config
|
|
if [[ "${RANDCONFIG}" == "y" ]]; then
|
|
|
|
# Append job-specific fixed configuration
|
|
if [[ -n "${EXTRA_FIXED_RANDCONFIG}" ]]; then
|
|
echo "${EXTRA_FIXED_RANDCONFIG}" >> xen/tools/kconfig/allrandom.config
|
|
fi
|
|
|
|
make -j$(nproc) -C xen KCONFIG_ALLCONFIG=tools/kconfig/allrandom.config randconfig
|
|
|
|
# RANDCONFIG implies HYPERVISOR_ONLY
|
|
HYPERVISOR_ONLY="y"
|
|
else
|
|
echo "CONFIG_DEBUG=${debug}" > xen/.config
|
|
|
|
if [[ -n "${EXTRA_XEN_CONFIG}" ]]; then
|
|
echo "${EXTRA_XEN_CONFIG}" >> xen/.config
|
|
fi
|
|
|
|
make -j$(nproc) -C xen olddefconfig
|
|
fi
|
|
|
|
# Save the config file before building because build failure causes the script
|
|
# to exit early -- bash is invoked with -e.
|
|
cp xen/.config xen-config
|
|
|
|
# Directory for the artefacts to be dumped into
|
|
mkdir binaries
|
|
|
|
if [[ "${CPPCHECK}" == "y" ]] && [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
|
|
# Cppcheck analysis invokes Xen-only build.
|
|
# Known limitation: cppcheck generates inconsistent reports when running
|
|
# in parallel mode, therefore do not specify -j<n>.
|
|
xen/scripts/xen-analysis.py --run-cppcheck --cppcheck-misra
|
|
|
|
# Preserve artefacts
|
|
cp xen/xen binaries/xen
|
|
cp xen/cppcheck-report/xen-cppcheck.txt xen-cppcheck.txt
|
|
elif [[ "${HYPERVISOR_ONLY}" == "y" ]]; then
|
|
# Xen-only build
|
|
make -j$(nproc) xen
|
|
|
|
# Preserve artefacts
|
|
cp xen/xen binaries/xen
|
|
else
|
|
# Full build. Figure out our ./configure options
|
|
cfgargs=()
|
|
cfgargs+=("--enable-docs")
|
|
|
|
# booleans for which compiler is in use
|
|
cc_is_gcc="$($cc --version | grep -q gcc && echo "y" || :)"
|
|
cc_is_clang="$($cc --version | grep -q clang && echo "y" || :)"
|
|
|
|
# The compiler version as an integer. e.g. GCC 4.9.2 => 0x040902
|
|
cc_ver="$($cc -dumpversion | awk -F. '{ printf "0x%02x%02x%02x", $1, $2, $3 }')"
|
|
|
|
if [[ "${cc_is_clang}" == "y" ]]; then
|
|
# SeaBIOS cannot be built with clang
|
|
cfgargs+=("--with-system-seabios=/usr/share/seabios/bios.bin")
|
|
# iPXE cannot be built with clang
|
|
cfgargs+=("--with-system-ipxe=/usr/lib/ipxe/ipxe.pxe")
|
|
# newlib cannot be built with clang so we cannot build stubdoms
|
|
cfgargs+=("--disable-stubdom")
|
|
fi
|
|
|
|
if ldd /bin/ls | grep -q musl; then
|
|
# disable --disable-werror for QEMUU when building with MUSL
|
|
cfgargs+=("--with-extra-qemuu-configure-args=\"--disable-werror\"")
|
|
# SeaBIOS doesn't build on MUSL systems
|
|
cfgargs+=("--with-system-seabios=/bin/false")
|
|
fi
|
|
|
|
# Qemu requires Python 3.5 or later, and ninja
|
|
if ! type python3 || python3 -c "import sys; res = sys.version_info < (3, 5); exit(not(res))" \
|
|
|| ! type ninja; then
|
|
cfgargs+=("--with-system-qemu=/bin/false")
|
|
fi
|
|
|
|
# SeaBIOS requires GCC 4.6 or later
|
|
if [[ "${cc_is_gcc}" == "y" && "${cc_ver}" -lt 0x040600 ]]; then
|
|
cfgargs+=("--with-system-seabios=/bin/false")
|
|
fi
|
|
|
|
./configure "${cfgargs[@]}"
|
|
make -j$(nproc) dist
|
|
|
|
# Preserve artefacts
|
|
# Note: Some smoke tests depending on finding binaries/xen on a full build
|
|
# even though dist/ contains everything, while some containers don't even
|
|
# build Xen
|
|
cp -r dist binaries/
|
|
if [[ -f xen/xen ]] ; then cp xen/xen binaries/xen; fi
|
|
fi
|