From 3f01acbb44141257313f6614fa854f960a71b1c1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 28 Apr 2020 13:21:25 -0400 Subject: IWYU: add some mappings found with a newer IWYU build --- Utilities/IWYU/mapping.imp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index 3497b53..7fa8516 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -27,6 +27,7 @@ { include: [ "", private, "", public ] }, { include: [ "", private, "", public ] }, { include: [ "", private, "", public ] }, + { include: [ "", private, "", public ] }, { include: [ "", private, "", public ] }, { include: [ "", private, "", public ] }, { include: [ "", private, "", public ] }, @@ -86,6 +87,7 @@ { symbol: [ "std::__decay_and_strip &>::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip &>::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, + { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip<__gnu_cxx::__normal_iterator > > &>::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__success_type > >::type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__success_type > >::type", private, "\"cmConfigure.h\"", public ] }, -- cgit v0.12 From 1bf89388252370e8af78f9b6620a4e1617364bd8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 28 Apr 2020 13:44:12 -0400 Subject: IWYU: add a mapping for other `__decay_and_strip` instances --- Source/cmArgumentParser.cxx | 1 - Utilities/IWYU/mapping.imp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmArgumentParser.cxx b/Source/cmArgumentParser.cxx index 4c87177..4624f1c 100644 --- a/Source/cmArgumentParser.cxx +++ b/Source/cmArgumentParser.cxx @@ -3,7 +3,6 @@ #include "cmArgumentParser.h" #include -#include namespace ArgumentParser { diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index 7fa8516..87e8bad 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -78,6 +78,7 @@ # Use '-Xiwyu -v7' to see the fully qualified names that need this. # TODO: Can this be simplified with an @-expression? #{ symbol: [ "@std::__decay_and_strip<.*>::__type", private, "\"cmConfigure.h\"", public ] }, + { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, @@ -89,6 +90,7 @@ { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__decay_and_strip<__gnu_cxx::__normal_iterator > > &>::__type", private, "\"cmConfigure.h\"", public ] }, + { symbol: [ "std::__decay_and_strip > *, std::vector >, std::allocator > > > > &>::__type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__success_type > >::type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::__success_type > >::type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::enable_if > >::type", private, "\"cmConfigure.h\"", public ] }, -- cgit v0.12 From 24a9fed5d9c9d341585c0e05c72909d5f3164927 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 28 Apr 2020 13:22:19 -0400 Subject: IWYU: mark as needed Newer IWYU is not seeing them as needed for `size_t`. --- Source/CPack/IFW/cmCPackIFWCommon.cxx | 2 +- Source/CTest/cmCTestMultiProcessHandler.cxx | 2 +- Source/CTest/cmCTestRunTest.cxx | 2 +- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/bindexplib.cxx | 2 +- Source/cmForEachCommand.cxx | 2 +- Source/cmStringAlgorithms.cxx | 2 +- Source/cmUVProcessChain.h | 2 +- Source/cmXMLWriter.h | 2 +- Tests/CMakeLib/testCTestBinPacker.cxx | 2 +- Tests/CMakeLib/testGccDepfileReader.cxx | 2 +- Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx index 9fa74be..20d392d 100644 --- a/Source/CPack/IFW/cmCPackIFWCommon.cxx +++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWCommon.h" -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 5c37f97..b7251d9 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 7d0f69b..7674d7a 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -3,7 +3,7 @@ #include "cmCTestRunTest.h" #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2408d57..e6b3f36 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index fdfd4c0..4a5c641 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -64,7 +64,7 @@ */ #include "bindexplib.h" -#include +#include // IWYU pragma: keep #include #include diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 0546186..82c5223 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -4,7 +4,7 @@ #include #include -#include +#include // IWYU pragma: keep // NOTE The declaration of `std::abs` has moved to `cmath` since C++17 // See https://en.cppreference.com/w/cpp/numeric/math/abs // ALERT But IWYU used to lint `#include`s do not "understand" diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index bb6dcd7..71d28a4 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -4,7 +4,7 @@ #include #include -#include +#include // IWYU pragma: keep #include #include diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h index 05a7cc8..cd7397e 100644 --- a/Source/cmUVProcessChain.h +++ b/Source/cmUVProcessChain.h @@ -4,7 +4,7 @@ #define cmUVProcessChain_h #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index bc445aa..00ea08c 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -6,7 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Tests/CMakeLib/testCTestBinPacker.cxx b/Tests/CMakeLib/testCTestBinPacker.cxx index 6f09af2..abdbefb 100644 --- a/Tests/CMakeLib/testCTestBinPacker.cxx +++ b/Tests/CMakeLib/testCTestBinPacker.cxx @@ -1,4 +1,4 @@ -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Tests/CMakeLib/testGccDepfileReader.cxx b/Tests/CMakeLib/testGccDepfileReader.cxx index 924d87b..e79f047 100644 --- a/Tests/CMakeLib/testGccDepfileReader.cxx +++ b/Tests/CMakeLib/testGccDepfileReader.cxx @@ -1,4 +1,4 @@ -#include +#include // IWYU pragma: keep #include #include #include diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx index 80db05e..daf8a2d 100644 --- a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx +++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx @@ -1,6 +1,6 @@ #include #include -#include +#include // IWYU pragma: keep #include #include #include -- cgit v0.12 From 99663a5157bca24d0a36a82ebf64f32e56f0a3b4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 28 Apr 2020 13:43:15 -0400 Subject: IWYU: mark as needed Newer IWYU is not seeing this as necessary for `_GLIBCXX_USE_CXX11_ABI`. --- Tests/CMakeLib/testString.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index 1fd3f38..48d2590 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include +#include // IWYU pragma: keep #include #include #include -- cgit v0.12 From a58457a6c273d9d7286bd9cb74477e5cf9aadc59 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 28 Apr 2020 13:23:05 -0400 Subject: IWYU: mark cmLinkLineComputer as necessary IWYU is not seeing that the full declaration is necessary for `std::unique_ptr`. --- Source/cmGhsMultiTargetGenerator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index f0c6d48..8ccecdd 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -14,7 +14,7 @@ #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalGhsMultiGenerator.h" -#include "cmLinkLineComputer.h" +#include "cmLinkLineComputer.h" // IWYU pragma: keep #include "cmLocalGenerator.h" #include "cmLocalGhsMultiGenerator.h" #include "cmMakefile.h" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 267d5e1..84eddb8 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -18,7 +18,7 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalUnixMakefileGenerator3.h" -#include "cmLinkLineComputer.h" +#include "cmLinkLineComputer.h" // IWYU pragma: keep #include "cmLocalCommonGenerator.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" -- cgit v0.12 From b745b8fd3697742d636b8bd3d7703abf6273404e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 28 Apr 2020 13:27:41 -0400 Subject: IWYU: mark includes needed for assert statements as needed --- Source/cmFunctionBlocker.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx index 5778a71..0d8401e 100644 --- a/Source/cmFunctionBlocker.cxx +++ b/Source/cmFunctionBlocker.cxx @@ -3,6 +3,7 @@ #include "cmFunctionBlocker.h" #include +#include // IWYU pragma: keep #include #include -- cgit v0.12 From 3ac24a8a6e31be136436fc011ac94ef06b63857d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 28 Apr 2020 13:28:02 -0400 Subject: cmFunctionBlocker: include missing header This is needed to have `std::string::operator==` used in the code. Mark it as such since older IWYU releases don't recognize this. --- Source/cmFunctionBlocker.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx index 0d8401e..643cd82 100644 --- a/Source/cmFunctionBlocker.cxx +++ b/Source/cmFunctionBlocker.cxx @@ -5,6 +5,7 @@ #include #include // IWYU pragma: keep #include +#include // IWYU pragma: keep #include #include "cmExecutionStatus.h" -- cgit v0.12 From 68903ae23884bcbb8bb47e0ce188da5151947bfd Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 8 Apr 2020 09:58:48 -0400 Subject: ci: add a Docker container for building CMake Since we're starting with just `clang-tidy`, external deps are not included right now. --- .gitlab/ci/docker/fedora31/Dockerfile | 5 +++++ .gitlab/ci/docker/fedora31/install_deps.sh | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .gitlab/ci/docker/fedora31/Dockerfile create mode 100755 .gitlab/ci/docker/fedora31/install_deps.sh diff --git a/.gitlab/ci/docker/fedora31/Dockerfile b/.gitlab/ci/docker/fedora31/Dockerfile new file mode 100644 index 0000000..5588a85 --- /dev/null +++ b/.gitlab/ci/docker/fedora31/Dockerfile @@ -0,0 +1,5 @@ +FROM fedora:31 +MAINTAINER Ben Boeckel + +COPY install_deps.sh /root/install_deps.sh +RUN sh /root/install_deps.sh diff --git a/.gitlab/ci/docker/fedora31/install_deps.sh b/.gitlab/ci/docker/fedora31/install_deps.sh new file mode 100755 index 0000000..978fdbd --- /dev/null +++ b/.gitlab/ci/docker/fedora31/install_deps.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Install build requirements. +dnf install -y \ + openssl-devel + +# Install development tools. +dnf install -y \ + clang-tools-extra \ + gcc-c++ \ + git-core + +dnf clean all -- cgit v0.12 From 6af91c7c4dc1c04c446d4994f2650234b9f10183 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 27 Apr 2020 16:00:03 -0400 Subject: ci: add an image for Debian 10 This image is primarily for the include-what-you-use build. --- .gitlab/ci/docker/debian10/Dockerfile | 15 ++++++++++++++ .gitlab/ci/docker/debian10/install_deps.sh | 22 ++++++++++++++++++++ .gitlab/ci/docker/debian10/install_iwyu.sh | 32 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .gitlab/ci/docker/debian10/Dockerfile create mode 100755 .gitlab/ci/docker/debian10/install_deps.sh create mode 100755 .gitlab/ci/docker/debian10/install_iwyu.sh diff --git a/.gitlab/ci/docker/debian10/Dockerfile b/.gitlab/ci/docker/debian10/Dockerfile new file mode 100644 index 0000000..e8c3851 --- /dev/null +++ b/.gitlab/ci/docker/debian10/Dockerfile @@ -0,0 +1,15 @@ +FROM debian:10 as iwyu-build +MAINTAINER Ben Boeckel + +COPY install_iwyu.sh /root/install_iwyu.sh +RUN sh /root/install_iwyu.sh + +FROM debian:10 +MAINTAINER Ben Boeckel + +COPY install_deps.sh /root/install_deps.sh +RUN sh /root/install_deps.sh + +COPY --from=iwyu-build /root/iwyu.tar.gz /root/iwyu.tar.gz +RUN tar -C / -xf /root/iwyu.tar.gz +RUN ln -s /usr/lib/llvm-6.0/bin/include-what-you-use /usr/bin/include-what-you-use-6.0 diff --git a/.gitlab/ci/docker/debian10/install_deps.sh b/.gitlab/ci/docker/debian10/install_deps.sh new file mode 100755 index 0000000..9c32d64 --- /dev/null +++ b/.gitlab/ci/docker/debian10/install_deps.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +apt-get update + +# Install build requirements. +apt-get install -y \ + libssl-dev + +# Install development tools. +apt-get install -y \ + g++ \ + curl \ + git + +# Install iwyu runtime deps. +apt-get install -y \ + clang-6.0 \ + libncurses6 + +apt-get clean diff --git a/.gitlab/ci/docker/debian10/install_iwyu.sh b/.gitlab/ci/docker/debian10/install_iwyu.sh new file mode 100755 index 0000000..54d26ef --- /dev/null +++ b/.gitlab/ci/docker/debian10/install_iwyu.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e + +# Install development tools. +apt-get update +apt-get install -y \ + clang-6.0 \ + libclang-6.0-dev \ + llvm-6.0-dev \ + libz-dev \ + g++ \ + cmake \ + ninja-build \ + git + +cd /root +git clone "https://github.com/include-what-you-use/include-what-you-use.git" +cd include-what-you-use +readonly llvm_version="$( clang-6.0 --version | head -n1 | cut -d' ' -f3 | cut -d. -f-2 )" +git checkout "clang_$llvm_version" +mkdir build +cd build + +cmake -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + "-DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$llvm_version" \ + "-DIWYU_LLVM_ROOT_PATH=/usr/lib/llvm-$llvm_version" \ + .. +ninja +DESTDIR=/root/iwyu-destdir ninja install +tar -C /root/iwyu-destdir -cf /root/iwyu.tar.gz . -- cgit v0.12 From 960158b90dc921a1ac521132861c2689052dd256 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 8 Apr 2020 09:59:28 -0400 Subject: ci: add scripts to download build tools --- .gitlab/ci/cmake.sh | 16 ++++++++++++++++ .gitlab/ci/ninja.sh | 15 +++++++++++++++ .gitlab/ci/sccache.sh | 16 ++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100755 .gitlab/ci/cmake.sh create mode 100755 .gitlab/ci/ninja.sh create mode 100755 .gitlab/ci/sccache.sh diff --git a/.gitlab/ci/cmake.sh b/.gitlab/ci/cmake.sh new file mode 100755 index 0000000..4b2f53f --- /dev/null +++ b/.gitlab/ci/cmake.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +readonly version="3.17.2" +readonly sha256sum="dc57f3cc448ca67fc8776b4ad4c22b087b9c6a8e459938b9622b8c7f4ef6b21e" +readonly filename="cmake-$version-Linux-x86_64" +readonly tarball="$filename.tar.gz" + +cd .gitlab + +echo "$sha256sum $tarball" > cmake.sha256sum +curl -OL "https://github.com/Kitware/CMake/releases/download/v$version/$tarball" +sha256sum --check cmake.sha256sum +tar xf "$tarball" +mv "$filename" cmake diff --git a/.gitlab/ci/ninja.sh b/.gitlab/ci/ninja.sh new file mode 100755 index 0000000..31da12b --- /dev/null +++ b/.gitlab/ci/ninja.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e + +readonly version="1.10.0" +readonly sha256sum="6566836ddf3d72ca06685b34814e0c6fa0f0943542d651d0dab3150f10307c82" +readonly filename="ninja-linux" +readonly tarball="$filename.zip" + +cd .gitlab + +echo "$sha256sum $tarball" > ninja.sha256sum +curl -OL "https://github.com/ninja-build/ninja/releases/download/v$version/$tarball" +sha256sum --check ninja.sha256sum +./cmake/bin/cmake -E tar xf "$tarball" diff --git a/.gitlab/ci/sccache.sh b/.gitlab/ci/sccache.sh new file mode 100755 index 0000000..c88cdcc --- /dev/null +++ b/.gitlab/ci/sccache.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +readonly version="0.2.12" +readonly sha256sum="26fd04c1273952cc2a0f359a71c8a1857137f0ee3634058b3f4a63b69fc8eb7f" +readonly filename="sccache-$version-x86_64-unknown-linux-musl" +readonly tarball="$filename.tar.gz" + +cd .gitlab + +echo "$sha256sum $tarball" > sccache.sha256sum +curl -OL "https://github.com/mozilla/sccache/releases/download/$version/$tarball" +sha256sum --check sccache.sha256sum +tar xf "$tarball" +mv "$filename/sccache" . -- cgit v0.12 From 0a5bcf97b9e0a7ac9c2bca0f92f6740a85ee3fdf Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 8 Apr 2020 10:00:57 -0400 Subject: gitlab-ci: add scripts for use by CI --- .gitlab/ci/configure_common.cmake | 3 +++ .gitlab/ci/configure_fedora31_tidy.cmake | 3 +++ .gitlab/ci/configure_sccache.cmake | 2 ++ .gitlab/ci/ctest_build.cmake | 30 +++++++++++++++++++++ .gitlab/ci/ctest_configure.cmake | 32 ++++++++++++++++++++++ .gitlab/ci/ctest_exclusions.cmake | 6 +++++ .gitlab/ci/ctest_test.cmake | 24 +++++++++++++++++ .gitlab/ci/gitlab_ci.cmake | 46 ++++++++++++++++++++++++++++++++ 8 files changed, 146 insertions(+) create mode 100644 .gitlab/ci/configure_common.cmake create mode 100644 .gitlab/ci/configure_fedora31_tidy.cmake create mode 100644 .gitlab/ci/configure_sccache.cmake create mode 100644 .gitlab/ci/ctest_build.cmake create mode 100644 .gitlab/ci/ctest_configure.cmake create mode 100644 .gitlab/ci/ctest_exclusions.cmake create mode 100644 .gitlab/ci/ctest_test.cmake create mode 100644 .gitlab/ci/gitlab_ci.cmake diff --git a/.gitlab/ci/configure_common.cmake b/.gitlab/ci/configure_common.cmake new file mode 100644 index 0000000..fc2aaae --- /dev/null +++ b/.gitlab/ci/configure_common.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS "ON" CACHE STRING "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_sccache.cmake") diff --git a/.gitlab/ci/configure_fedora31_tidy.cmake b/.gitlab/ci/configure_fedora31_tidy.cmake new file mode 100644 index 0000000..f41ad82 --- /dev/null +++ b/.gitlab/ci/configure_fedora31_tidy.cmake @@ -0,0 +1,3 @@ +set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") diff --git a/.gitlab/ci/configure_sccache.cmake b/.gitlab/ci/configure_sccache.cmake new file mode 100644 index 0000000..261bb28 --- /dev/null +++ b/.gitlab/ci/configure_sccache.cmake @@ -0,0 +1,2 @@ +set(CMAKE_C_COMPILER_LAUNCHER "sccache" CACHE STRING "") +set(CMAKE_CXX_COMPILER_LAUNCHER "sccache" CACHE STRING "") diff --git a/.gitlab/ci/ctest_build.cmake b/.gitlab/ci/ctest_build.cmake new file mode 100644 index 0000000..28bdb35 --- /dev/null +++ b/.gitlab/ci/ctest_build.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.8) + +include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake") + +# Read the files from the build directory. +ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + +# Pick up from where the configure left off. +ctest_start(APPEND) + +if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles") + include(ProcessorCount) + ProcessorCount(nproc) + set(CTEST_BUILD_FLAGS "-j${nproc}") +endif () + +ctest_build( + NUMBER_WARNINGS num_warnings + RETURN_VALUE build_result) +ctest_submit(PARTS Build) + +if (build_result) + message(FATAL_ERROR + "Failed to build") +endif () + +if ("$ENV{CTEST_NO_WARNINGS_ALLOWED}" AND num_warnings GREATER 0) + message(FATAL_ERROR + "Found ${num_warnings} warnings (treating as fatal).") +endif () diff --git a/.gitlab/ci/ctest_configure.cmake b/.gitlab/ci/ctest_configure.cmake new file mode 100644 index 0000000..55cad13 --- /dev/null +++ b/.gitlab/ci/ctest_configure.cmake @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.8) + +include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake") + +set(cmake_args + -C "${CMAKE_CURRENT_LIST_DIR}/configure_$ENV{CMAKE_CONFIGURATION}.cmake") + +# Create an entry in CDash. +ctest_start(Experimental TRACK "${ctest_track}") + +# Gather update information. +find_package(Git) +set(CTEST_UPDATE_VERSION_ONLY ON) +set(CTEST_UPDATE_COMMAND "${GIT_EXECUTABLE}") +ctest_update() + +# Configure the project. +ctest_configure( + OPTIONS "${cmake_args}" + RETURN_VALUE configure_result) + +# Read the files from the build directory. +ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + +# We can now submit because we've configured. This is a cmb-superbuild-ism. +ctest_submit(PARTS Update) +ctest_submit(PARTS Configure) + +if (configure_result) + message(FATAL_ERROR + "Failed to configure") +endif () diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake new file mode 100644 index 0000000..5bb03ca --- /dev/null +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -0,0 +1,6 @@ +set(test_exclusions +) +string(REPLACE ";" "|" test_exclusions "${test_exclusions}") +if (test_exclusions) + set(test_exclusions "(${test_exclusions})") +endif () diff --git a/.gitlab/ci/ctest_test.cmake b/.gitlab/ci/ctest_test.cmake new file mode 100644 index 0000000..569139d --- /dev/null +++ b/.gitlab/ci/ctest_test.cmake @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.8) + +include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake") + +# Read the files from the build directory. +ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + +# Pick up from where the configure left off. +ctest_start(APPEND) + +include(ProcessorCount) +ProcessorCount(nproc) + +include("${CMAKE_CURRENT_LIST_DIR}/ctest_exclusions.cmake") +ctest_test( + PARALLEL_LEVEL "${nproc}" + RETURN_VALUE test_result + EXCLUDE "${test_exclusions}") +ctest_submit(PARTS Test) + +if (test_result) + message(FATAL_ERROR + "Failed to test") +endif () diff --git a/.gitlab/ci/gitlab_ci.cmake b/.gitlab/ci/gitlab_ci.cmake new file mode 100644 index 0000000..401cc40 --- /dev/null +++ b/.gitlab/ci/gitlab_ci.cmake @@ -0,0 +1,46 @@ +if (NOT DEFINED "ENV{GITLAB_CI}") + message(FATAL_ERROR + "This script assumes it is being run inside of GitLab-CI") +endif () + +# Set up the source and build paths. +set(CTEST_SOURCE_DIRECTORY "$ENV{CI_PROJECT_DIR}") +set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build") + +if ("$ENV{CMAKE_CONFIGURATION}" STREQUAL "") + message(FATAL_ERROR + "The CMAKE_CONFIGURATION environment variable is required to know what " + "cache initialization file to use.") +endif () + +# Set the build metadata. +set(CTEST_BUILD_NAME "$ENV{CI_PROJECT_NAME}-$ENV{CMAKE_CONFIGURATION}") +set(CTEST_SITE "gitlab-ci") + +# Default to Release builds. +if (NOT "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "") + set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_BUILD_TYPE}") +endif () +if (NOT CTEST_BUILD_CONFIGURATION) + set(CTEST_BUILD_CONFIGURATION "Release") +endif () + +# Default to using Ninja. +if (NOT "$ENV{CMAKE_GENERATOR}" STREQUAL "") + set(CTEST_CMAKE_GENERATOR "$ENV{CMAKE_GENERATOR}") +endif () +if (NOT CTEST_CMAKE_GENERATOR) + set(CTEST_CMAKE_GENERATOR "Ninja") +endif () + +# Determine the track to submit to. +set(ctest_track "Experimental") +if (NOT "$ENV{CI_MERGE_REQUEST_ID}" STREQUAL "") + set(ctest_track "merge-requests") +elseif ("$ENV{CI_PROJECT_PATH}" STREQUAL "cmb/smtk") + if ("$ENV{CI_COMMIT_REF_NAME}" STREQUAL "master") + set(ctest_track "master") + elseif ("$ENV{CI_COMMIT_REF_NAME}" STREQUAL "release") + set(ctest_track "release") + endif () +endif () -- cgit v0.12 From 0866b9253bcb270b1bb737ce1fee3a4c8111969e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 8 Apr 2020 10:01:34 -0400 Subject: gitlab-ci: add initial clang-tidy build --- .gitlab-ci.yml | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..c15c794 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,65 @@ +.only_settings: &only_settings + - merge_requests + - branches@cmake/cmake + - tags@cmake/cmake + +.fedora31: &fedora31 + image: "kitware/cmake:ci-fedora31-x86_64-2020-04-27" + + variables: + GIT_CLONE_PATH: "$CI_BUILDS_DIR/gitlab-kitware-cmake ci" + +.fedora31_tidy: &fedora31_tidy + extends: .fedora31 + + variables: + CMAKE_CONFIGURATION: fedora31_tidy + CTEST_NO_WARNINGS_ALLOWED: 1 + +before_script: + - .gitlab/ci/cmake.sh + - .gitlab/ci/ninja.sh + - export PATH=$PWD/.gitlab:$PWD/.gitlab/cmake/bin:$PATH + - cmake --version + - ninja --version + +.cmake_build_unix: &cmake_build_unix + stage: build + only: *only_settings + tags: + - build + - docker + - linux + + script: + - .gitlab/ci/sccache.sh + - sccache --start-server + - sccache --show-stats + - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake" + - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake" + - sccache --show-stats + + interruptible: true + +stages: + - build + - test + +build:fedora31-tidy: + <<: + - *fedora31_tidy + stage: build + only: *only_settings + tags: + - build + - docker + - linux + + script: + - .gitlab/ci/sccache.sh + - sccache --start-server + - sccache --show-stats + - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake" + - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake" + - sccache --show-stats + interruptible: true -- cgit v0.12 From 4318e8ed353064d8f1d531ab3e42c16347f1081b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 27 Apr 2020 12:52:30 -0400 Subject: gitlab-ci: add iwyu job --- .gitlab-ci.yml | 32 ++++++++++++++++++++++++++++++++ .gitlab/ci/configure_debian10_iwyu.cmake | 4 ++++ 2 files changed, 36 insertions(+) create mode 100644 .gitlab/ci/configure_debian10_iwyu.cmake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c15c794..9a91d20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,19 @@ variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/gitlab-kitware-cmake ci" +.debian10: &debian10 + image: "kitware/cmake:ci-debian10-x86_64-2020-04-27" + + variables: + GIT_CLONE_PATH: "$CI_BUILDS_DIR/gitlab-kitware-cmake ci" + +.debian10_iwyu: &debian10_iwyu + extends: .debian10 + + variables: + CMAKE_CONFIGURATION: debian10_iwyu + CTEST_NO_WARNINGS_ALLOWED: 1 + .fedora31_tidy: &fedora31_tidy extends: .fedora31 @@ -45,6 +58,25 @@ stages: - build - test +build:debian10-iwyu: + <<: + - *debian10_iwyu + stage: build + only: *only_settings + tags: + - build + - docker + - linux + + script: + - .gitlab/ci/sccache.sh + - sccache --start-server + - sccache --show-stats + - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake" + - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake" + - sccache --show-stats + interruptible: true + build:fedora31-tidy: <<: - *fedora31_tidy diff --git a/.gitlab/ci/configure_debian10_iwyu.cmake b/.gitlab/ci/configure_debian10_iwyu.cmake new file mode 100644 index 0000000..1daa581 --- /dev/null +++ b/.gitlab/ci/configure_debian10_iwyu.cmake @@ -0,0 +1,4 @@ +set(CMake_RUN_IWYU ON CACHE BOOL "") +set(IWYU_COMMAND "/usr/bin/include-what-you-use-6.0" CACHE FILEPATH "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") -- cgit v0.12