mirror of
https://github.com/apple/swift-nio
synced 2026-11-22 04:30:41 +00:00
Honor CMAKE_VERSION in cmake-build.sh by downloading the requested CMake release (#3795)
`cmake_tests.yml` has a `cmake_version` input and passes it to `scripts/cmake-build.sh` as `CMAKE_VERSION`, but the script does not use that value, so the CMake from the image's apt is used instead. With this patch, when `CMAKE_VERSION` is set, the script downloads the release from Kitware's GitHub releases on Linux (x86_64/aarch64) and uses it for the build. This lets projects that need a newer CMake than the image's apt provides use the shared workflow by setting `cmake_version`. This is blocking https://github.com/apple/swift-certificates/pull/325.
This commit is contained in:
1 parent
93bd8f2e02
commit
ae78c343cd
1 file changed
+16
@@ -25,8 +25,24 @@ if [ -z "$target_dir" ]; then
|
||||
fatal "Target directory must be specified."
|
||||
fi
|
||||
|
||||
cmake_version="${CMAKE_VERSION:=""}"
|
||||
|
||||
CURL_BIN="${CURL_BIN:-$(which curl)}" || fatal "CURL_BIN unset and no curl on PATH"
|
||||
TAR_BIN="${TAR_BIN:-$(which tar)}" || fatal "TAR_BIN unset and no tar on PATH"
|
||||
|
||||
if [ -n "$cmake_version" ]; then
|
||||
[ "$(uname -s)" = "Linux" ] || fatal "CMAKE_VERSION is only supported on Linux."
|
||||
cmake_arch="$(uname -m)"
|
||||
cmake_dist="cmake-${cmake_version}-linux-${cmake_arch}"
|
||||
cmake_url="https://github.com/Kitware/CMake/releases/download/v${cmake_version}/${cmake_dist}.tar.gz"
|
||||
cmake_install_dir="$(mktemp -d)" || fatal "Could not create a temporary directory for CMake"
|
||||
|
||||
log "Downloading CMake ${cmake_version} from ${cmake_url}"
|
||||
"$CURL_BIN" -fsSL --retry 3 "$cmake_url" | "$TAR_BIN" -xz -C "$cmake_install_dir" \
|
||||
|| fatal "Failed to download or extract CMake ${cmake_version}"
|
||||
CMAKE_BIN="${cmake_install_dir}/${cmake_dist}/bin/cmake"
|
||||
fi
|
||||
|
||||
CMAKE_BIN="${CMAKE_BIN:-$(which cmake)}" || fatal "CMAKE_BIN unset and no cmake on PATH"
|
||||
NINJA_BIN="${NINJA_BIN:-$(which ninja)}" || fatal "NINJA_BIN unset and no ninja on PATH"
|
||||
ASSEMBLY_COMPILER_BIN="${ASSEMBLY_COMPILER_BIN:-$(which clang)}" || fatal "ASSEMBLY_COMPILER_BIN unset and no clang on PATH"
|
||||
|
||||
Reference in new issue
Block a user