Skip to content

Commit fe1cd8c

Browse files
committed
Merge #208: ci: Test minimum cmake version in olddeps job
0f58039 ci: Test minimum cmake version in olddeps job (Ryan Ofsky) Pull request description: Add CI job to test minimum version of cmake that can be used to build. Current minimum version 3.12, since that's version that added c++20 support according to #164. ACKs for top commit: hebasto: ACK 0f58039, I have reviewed the code and it looks OK. CI log also looks reasonable. Tree-SHA512: 6c3ce85fbf903f480f4bf7e923cce124c1a70c035d33a01d144bca0ccc34926d3dfb6927e3435e90a75cace202b6762fd252565d29c2fc23078d91d8e8ad7768
2 parents b713a0b + 0f58039 commit fe1cd8c

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

ci/configs/olddeps.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CI_DESC="CI job using old Cap'n Proto version"
1+
CI_DESC="CI job using old Cap'n Proto and cmake versions"
22
CI_DIR=build-olddeps
33
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds"
4-
NIX_ARGS=(--argstr capnprotoVersion "0.7.1")
4+
NIX_ARGS=(--argstr capnprotoVersion "0.7.1" --argstr cmakeVersion "3.12.4")
55
BUILD_ARGS=(-k)

ci/scripts/ci.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@ fi
1818
[ -n "${CI_CLEAN-}" ] && rm -rf "${CI_DIR}"
1919

2020
cmake --version
21+
cmake_ver=$(cmake --version | awk '/version/{print $3; exit}')
22+
ver_ge() { [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; }
2123

22-
cmake -B "$CI_DIR" "${CMAKE_ARGS[@]+"${CMAKE_ARGS[@]}"}"
23-
cmake --build "$CI_DIR" -t "${BUILD_TARGETS[@]}" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}"
24-
ctest --test-dir "$CI_DIR" --output-on-failure
24+
src_dir=$PWD
25+
mkdir -p "$CI_DIR"
26+
cd "$CI_DIR"
27+
cmake "$src_dir" "${CMAKE_ARGS[@]+"${CMAKE_ARGS[@]}"}"
28+
if ver_ge "$cmake_ver" "3.15"; then
29+
cmake --build . -t "${BUILD_TARGETS[@]}" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}"
30+
else
31+
# Older versions of cmake can only build one target at a time with --target,
32+
# and do not support -t shortcut
33+
for t in "${BUILD_TARGETS[@]}"; do
34+
cmake --build . --target "$t" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}"
35+
done
36+
fi
37+
ctest --output-on-failure

shell.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
, enableLibcxx ? false # Whether to use libc++ toolchain and libraries instead of libstdc++
44
, minimal ? false # Whether to create minimal shell without extra tools (faster when cross compiling)
55
, capnprotoVersion ? null
6+
, cmakeVersion ? null
67
}:
78

89
let
@@ -37,12 +38,23 @@ let
3738
capnproto = capnprotoBase.override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; });
3839
clang = if enableLibcxx then llvm.libcxxClang else llvm.clang;
3940
clang-tools = llvm.clang-tools.override { inherit enableLibcxx; };
41+
cmakeHashes = {
42+
"3.12.4" = "sha256-UlVYS/0EPrcXViz/iULUcvHA5GecSUHYS6raqbKOMZQ=";
43+
};
44+
cmakeBuild = if cmakeVersion == null then pkgs.cmake else (pkgs.cmake.overrideAttrs (old: {
45+
version = cmakeVersion;
46+
src = pkgs.fetchurl {
47+
url = "https://cmake.org/files/v${lib.versions.majorMinor cmakeVersion}/cmake-${cmakeVersion}.tar.gz";
48+
hash = lib.attrByPath [cmakeVersion] "" cmakeHashes;
49+
};
50+
patches = [];
51+
})).override { isMinimalBuild = true; };
4052
in crossPkgs.mkShell {
4153
buildInputs = [
4254
capnproto
4355
];
4456
nativeBuildInputs = with pkgs; [
45-
cmake
57+
cmakeBuild
4658
include-what-you-use
4759
ninja
4860
] ++ lib.optionals (!minimal) [

0 commit comments

Comments
 (0)