diff --git a/automation/build/debian/unstable-cppcheck.dockerfile b/automation/build/debian/unstable-cppcheck.dockerfile new file mode 100644 index 0000000000..adc192cea6 --- /dev/null +++ b/automation/build/debian/unstable-cppcheck.dockerfile @@ -0,0 +1,53 @@ +FROM arm64v8/debian:unstable AS builder + +ENV DEBIAN_FRONTEND=noninteractive +ENV CPPCHECK_VERSION=2.7 +ENV USER root + +# dependencies for cppcheck build +RUN apt-get update && \ + apt-get --quiet --yes install \ + curl \ + build-essential \ + python-is-python3 \ + libpcre3-dev + +RUN mkdir /build +WORKDIR /build + +# cppcheck release build (see cppcheck readme.md) +RUN curl -fsSLO https://github.com/danmar/cppcheck/archive/"$CPPCHECK_VERSION".tar.gz && \ + tar xvzf "$CPPCHECK_VERSION".tar.gz && \ + cd cppcheck-"$CPPCHECK_VERSION" && \ + make install -j$(nproc) \ + MATCHCOMPILER=yes \ + FILESDIR=/usr/share/cppcheck \ + HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" + +FROM arm64v8/debian:unstable +COPY --from=builder /usr/bin/cppcheck /usr/bin/cppcheck +COPY --from=builder /usr/share/cppcheck /usr/share/cppcheck + +LABEL maintainer.name="The Xen Project" \ + maintainer.email="xen-devel@lists.xenproject.org" + +ENV DEBIAN_FRONTEND=noninteractive +ENV USER root + +RUN mkdir /build +WORKDIR /build + +# dependencies for cppcheck analysis including Xen-only build/cross-build +RUN apt-get update && \ + apt-get --quiet --yes install \ + build-essential \ + python-is-python3 \ + libpcre3-dev \ + flex \ + bison \ + gcc-arm-linux-gnueabihf \ + gcc-x86-64-linux-gnu \ + && \ + apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/* diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml index 9b7425cca8..38bb22d860 100644 --- a/automation/gitlab-ci/build.yaml +++ b/automation/gitlab-ci/build.yaml @@ -7,6 +7,7 @@ paths: - binaries/ - xen-config + - xen-cppcheck.txt - '*.log' - '*/*.log' when: always @@ -235,6 +236,23 @@ tags: - x86_64 +.x86-64-cross-build-tmpl: + <<: *build + variables: + XEN_TARGET_ARCH: x86_64 + tags: + - arm64 + +.x86-64-cross-build: + extends: .x86-64-cross-build-tmpl + variables: + debug: n + +.gcc-x86-64-cross-build: + extends: .x86-64-cross-build + variables: + <<: *gcc + # Jobs below this line archlinux-gcc: @@ -672,6 +690,31 @@ yocto-qemux86-64: variables: YOCTO_BOARD: qemux86-64 +# Cppcheck analysis jobs + +debian-unstable-gcc-cppcheck: + extends: .gcc-x86-64-cross-build + variables: + CONTAINER: debian:unstable-cppcheck + CROSS_COMPILE: /usr/bin/x86_64-linux-gnu- + CPPCHECK: y + HYPERVISOR_ONLY: y + +debian-unstable-gcc-arm32-cppcheck: + extends: .gcc-arm32-cross-build + variables: + CONTAINER: debian:unstable-cppcheck + CROSS_COMPILE: /usr/bin/arm-linux-gnueabihf- + CPPCHECK: y + HYPERVISOR_ONLY: y + +debian-unstable-gcc-arm64-cppcheck: + extends: .gcc-arm64-build + variables: + CONTAINER: debian:unstable-cppcheck + CPPCHECK: y + HYPERVISOR_ONLY: y + ## Test artifacts common .test-jobs-artifact-common: diff --git a/automation/scripts/build b/automation/scripts/build index f2f5e55bc0..7d1b19c425 100755 --- a/automation/scripts/build +++ b/automation/scripts/build @@ -38,7 +38,16 @@ cp xen/.config xen-config # Directory for the artefacts to be dumped into mkdir binaries -if [[ "${HYPERVISOR_ONLY}" == "y" ]]; then +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. + 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