From e1e55b4cb7ce02a0e353d16fd46bf0004cc075a9 Mon Sep 17 00:00:00 2001 From: Richard Wells Date: Wed, 19 Feb 2025 12:13:42 +0000 Subject: [PATCH] Output CI builds to separate folders. --- .gitlab-ci.yml | 8 ++-- Doxyfile | 2 +- scripts/ci-opencv.sh | 25 ++++++++---- scripts/ci.sh | 53 +++++++++++++------------ scripts/generate_coverage_report.py | 2 +- scripts/run_opencv_conformity_checks.sh | 6 +-- 6 files changed, 54 insertions(+), 42 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4d2edb3bf..5eeae1b6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,12 +24,12 @@ workflow: when: always expire_in: 1 day reports: - junit: build/test-results/**/*.xml + junit: build/ci/test-results/**/*.xml coverage_report: coverage_format: cobertura - path: build/cobertura-coverage.xml + path: build/ci/cobertura-coverage.xml paths: - - build/html + - build/ci/html coverage: /^line and branch coverage:\s+([\d\.]+\%)/ # On the main branch publish pages. @@ -37,7 +37,7 @@ pages: extends: .common rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - publish: build/html + publish: build/ci/html # On other branches don't publish pages. test: diff --git a/Doxyfile b/Doxyfile index 708925d32..ae881278b 100644 --- a/Doxyfile +++ b/Doxyfile @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 PROJECT_NAME = "KleidiCV" -OUTPUT_DIRECTORY = build +OUTPUT_DIRECTORY = build/ci HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES SHOW_INCLUDE_FILES = NO diff --git a/scripts/ci-opencv.sh b/scripts/ci-opencv.sh index 07fe62004..d34b557a0 100755 --- a/scripts/ci-opencv.sh +++ b/scripts/ci-opencv.sh @@ -6,6 +6,8 @@ set -exu +: "${CLEAN:=OFF}" + # Ensure we're at the root of the repo. cd "$(dirname "${BASH_SOURCE[0]}")/.." @@ -14,10 +16,13 @@ export OPENCV_VERSION="4.11.0" # ------------------------------------------------------------------------------ # Try to build unpatched OpenCV with KleidiCV # ------------------------------------------------------------------------------ -mkdir -p build/unpatched-opencv-src -tar -xzf /opt/opencv-${OPENCV_VERSION}.tar.gz -C build/unpatched-opencv-src -BUILD_ID=unpatched-opencv \ -OPENCV_PATH="$(pwd)/build/unpatched-opencv-src/opencv-${OPENCV_VERSION}" \ +if [[ "${CLEAN}" == "ON" ]]; then + rm -rf build/ci/unpatched-opencv* +fi +mkdir -p build/ci/unpatched-opencv-src +tar -xzf /opt/opencv-${OPENCV_VERSION}.tar.gz -C build/ci/unpatched-opencv-src +BUILD_ID="ci/unpatched-opencv" \ +OPENCV_PATH="$(pwd)/build/ci/unpatched-opencv-src/opencv-${OPENCV_VERSION}" \ CMAKE_EXE_LINKER_FLAGS="--rtlib=compiler-rt -fuse-ld=lld" \ EXTRA_CMAKE_ARGS="\ -DBUILD_SHARED_LIBS=OFF \ @@ -64,6 +69,7 @@ TESTRESULT=0 CLEAN="ON" \ OPENCV_URL="/opt/opencv-${OPENCV_VERSION}.tar.gz" \ LDFLAGS="--rtlib=compiler-rt -fuse-ld=lld" \ + BUILD_PATH="build/ci/conformity" \ ./scripts/run_opencv_conformity_checks.sh || TESTRESULT=1 # ------------------------------------------------------------------------------ @@ -71,16 +77,19 @@ CLEAN="ON" \ # ------------------------------------------------------------------------------ # Build OpenCV test executables from already configured conformity check project # The OpenCV source is patched in this case -ninja -C build/conformity/opencv_kleidicv \ +ninja -C build/ci/conformity/opencv_kleidicv \ opencv_test_imgproc \ opencv_test_core \ opencv_test_video # Some tests require opencv_extra for the test images -tar xf /opt/opencv-extra-${OPENCV_VERSION}.tar.gz -C build -mv build/opencv_extra-${OPENCV_VERSION} build/opencv_extra +if [[ "${CLEAN}" == "ON" ]]; then + rm -rf build/ci/opencv_extra* +fi +tar xf /opt/opencv-extra-${OPENCV_VERSION}.tar.gz -C build/ci +mv build/ci/opencv_extra-${OPENCV_VERSION} build/ci/opencv_extra -pushd build/opencv_extra/testdata/cv +pushd build/ci/opencv_extra/testdata/cv join_strings_with_colon() { local array="${1}" diff --git a/scripts/ci.sh b/scripts/ci.sh index 80a9671f4..f2d097b8c 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -10,7 +10,8 @@ set -exu cd "$(dirname "${BASH_SOURCE[0]}")/.." # Ensure we're doing a clean build -rm -rf build +rm -rf build/ci +mkdir -p build/ci if ! command -v qemu-aarch64; then apt-get update @@ -36,8 +37,8 @@ reuse lint # Generate documentation doxygen -# Build -cmake -S . -B build -G Ninja \ +# Build with Clang +cmake -S . -B build/ci/clang -G Ninja \ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ -DCMAKE_CXX_CLANG_TIDY=clang-tidy-20 \ -DCMAKE_CXX_FLAGS="--target=aarch64-linux-gnu --coverage" \ @@ -48,34 +49,36 @@ cmake -S . -B build -G Ninja \ -DKLEIDICV_CHECK_BANNED_FUNCTIONS=ON # Workaround to avoid applying clang-tidy to files in external projects. -echo '{"Checks": "-*,cppcoreguidelines-avoid-goto"}'>build/_deps/.clang-tidy +echo '{"Checks": "-*,cppcoreguidelines-avoid-goto"}'>build/ci/clang/_deps/.clang-tidy -ninja -C build +ninja -C build/ci/clang/ # Build with GCC -CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ cmake -S . -B build/gcc -G Ninja \ +CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ cmake -S . -B build/ci/gcc -G Ninja \ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ -DCMAKE_EXE_LINKER_FLAGS="-static" -ninja -C build/gcc +ninja -C build/ci/gcc -# Run tests +# Run tests on Clang build LONG_VECTOR_TESTS="GRAY2.*:RGB*:Yuv*:Rgb*:Resize*" TESTRESULT=0 -qemu-aarch64 build/test/framework/kleidicv-framework-test --gtest_output=xml:build/test-results/ || TESTRESULT=1 -qemu-aarch64 -cpu cortex-a35 build/test/api/kleidicv-api-test --gtest_output=xml:build/test-results/clang-neon/ || TESTRESULT=1 +qemu-aarch64 build/ci/clang/test/framework/kleidicv-framework-test --gtest_output=xml:build/ci/test-results/clang-framework/ || TESTRESULT=1 +qemu-aarch64 -cpu cortex-a35 build/ci/clang/test/api/kleidicv-api-test --gtest_output=xml:build/ci/test-results/clang-neon/ || TESTRESULT=1 qemu-aarch64 -cpu max,sve128=on,sme=off \ - build/test/api/kleidicv-api-test --gtest_output=xml:build/test-results/clang-sve128/ --vector-length=16 || TESTRESULT=1 + build/ci/clang/test/api/kleidicv-api-test --gtest_output=xml:build/ci/test-results/clang-sve128/ --vector-length=16 || TESTRESULT=1 qemu-aarch64 -cpu max,sve2048=on,sve-default-vector-length=256,sme=off \ - build/test/api/kleidicv-api-test --gtest_filter="${LONG_VECTOR_TESTS}" --gtest_output=xml:build/test-results/clang-sve2048/ --vector-length=256 || TESTRESULT=1 + build/ci/clang/test/api/kleidicv-api-test --gtest_filter="${LONG_VECTOR_TESTS}" --gtest_output=xml:build/ci/test-results/clang-sve2048/ --vector-length=256 || TESTRESULT=1 qemu-aarch64 -cpu max,sve128=on,sme512=on \ - build/test/api/kleidicv-api-test --gtest_output=xml:build/test-results/clang-sme/ --vector-length=64 || TESTRESULT=1 -qemu-aarch64 -cpu cortex-a35 build/gcc/test/api/kleidicv-api-test --gtest_output=xml:build/test-results/gcc-neon/ || TESTRESULT=1 + build/ci/clang/test/api/kleidicv-api-test --gtest_output=xml:build/ci/test-results/clang-sme/ --vector-length=64 || TESTRESULT=1 -scripts/prefix_testsuite_names.py build/test-results/clang-neon/kleidicv-api-test.xml "clang-neon." -scripts/prefix_testsuite_names.py build/test-results/clang-sve128/kleidicv-api-test.xml "clang-sve128." -scripts/prefix_testsuite_names.py build/test-results/clang-sve2048/kleidicv-api-test.xml "clang-sve2048." -scripts/prefix_testsuite_names.py build/test-results/clang-sme/kleidicv-api-test.xml "clang-sme." -scripts/prefix_testsuite_names.py build/test-results/gcc-neon/kleidicv-api-test.xml "gcc-neon." +# Run tests on GCC build +qemu-aarch64 -cpu cortex-a35 build/ci/gcc/test/api/kleidicv-api-test --gtest_output=xml:build/ci/test-results/gcc-neon/ || TESTRESULT=1 + +scripts/prefix_testsuite_names.py build/ci/test-results/clang-neon/kleidicv-api-test.xml "clang-neon." +scripts/prefix_testsuite_names.py build/ci/test-results/clang-sve128/kleidicv-api-test.xml "clang-sve128." +scripts/prefix_testsuite_names.py build/ci/test-results/clang-sve2048/kleidicv-api-test.xml "clang-sve2048." +scripts/prefix_testsuite_names.py build/ci/test-results/clang-sme/kleidicv-api-test.xml "clang-sme." +scripts/prefix_testsuite_names.py build/ci/test-results/gcc-neon/kleidicv-api-test.xml "gcc-neon." # Generate test coverage report LLVM_COV=llvm-cov scripts/generate_coverage_report.py @@ -83,17 +86,17 @@ LLVM_COV=llvm-cov scripts/generate_coverage_report.py # Sanitizers don't work when run through qemu so must be run natively. if [[ $(dpkg --print-architecture) = arm64 ]]; then # Clang address & undefined behaviour sanitizers - cmake -S . -B build/sanitize -G Ninja \ + cmake -S . -B build/ci/sanitize -G Ninja \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ -DKLEIDICV_ENABLE_SME2=OFF \ -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all -Wno-pass-failed" - ninja -C build/sanitize kleidicv-api-test - build/sanitize/test/api/kleidicv-api-test + ninja -C build/ci/sanitize kleidicv-api-test + build/ci/sanitize/test/api/kleidicv-api-test fi # Build benchmarks, just to prevent bitrot. -cmake -S . -B build/build-benchmark -G Ninja \ +cmake -S . -B build/ci/build-benchmark -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ -DCMAKE_CROSSCOMPILING_EMULATOR=qemu-aarch64 \ @@ -105,12 +108,12 @@ cmake -S . -B build/build-benchmark -G Ninja \ -DKLEIDICV_ENABLE_SME2=ON \ -DKLEIDICV_LIMIT_SME2_TO_SELECTED_ALGORITHMS=OFF \ -DKLEIDICV_LIMIT_SVE2_TO_SELECTED_ALGORITHMS=OFF -ninja -C build/build-benchmark kleidicv-benchmark +ninja -C build/ci/build-benchmark kleidicv-benchmark # TODO: Cross-build OpenCV if [[ $(dpkg --print-architecture) = arm64 ]]; then # Check OpenCV-KleidiCV integration - scripts/ci-opencv.sh + CLEAN="ON" scripts/ci-opencv.sh fi exit $TESTRESULT diff --git a/scripts/generate_coverage_report.py b/scripts/generate_coverage_report.py index edfa60f31..2e43922d6 100755 --- a/scripts/generate_coverage_report.py +++ b/scripts/generate_coverage_report.py @@ -41,7 +41,7 @@ the toolchain with which the binaries were built.""" source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) build_dir = os.path.abspath( - args.build_directory or os.path.join(source_dir, "build") + args.build_directory or os.path.join(source_dir, "build", "ci") ) cobertura = os.path.join(build_dir, "cobertura-coverage.xml") diff --git a/scripts/run_opencv_conformity_checks.sh b/scripts/run_opencv_conformity_checks.sh index 6002ed2a7..c40ee9641 100755 --- a/scripts/run_opencv_conformity_checks.sh +++ b/scripts/run_opencv_conformity_checks.sh @@ -6,15 +6,15 @@ set -exu +SCRIPT_PATH="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" + : "${CLEAN:=OFF}" : "${OPENCV_VERSION:=}" : "${OPENCV_URL:=}" - -SCRIPT_PATH="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" +: "${BUILD_PATH:=${SCRIPT_PATH}/../build/conformity}" SOURCE_PATH="${SCRIPT_PATH}/../conformity/opencv" KLEIDICV_SOURCE_PATH="${SCRIPT_PATH}/.." -BUILD_PATH="${SCRIPT_PATH}/../build/conformity" OPENCV_DEFAULT_PATH="${BUILD_PATH}/opencv_default" OPENCV_KLEIDICV_PATH="${BUILD_PATH}/opencv_kleidicv" -- GitLab