1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-25 21:07:39 +03:00

ci: factor out ci/check-rust-version.sh

refs: #1079
This commit is contained in:
Wez Furlong 2021-09-16 08:54:05 -07:00
parent 6949430cb1
commit e36cf75451
2 changed files with 55 additions and 48 deletions

54
ci/check-rust-version.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
min_rust=(1 53 0)
rust_ver=()
parse_rustc_version() {
local IFS
IFS=' '
local FIELDS
read -ra FIELDS <<< $(rustc --version)
IFS='.'
read -ra rust_ver <<< "${FIELDS[1]}"
}
check_rust_version() {
parse_rustc_version
# rust_ver=(1 46 0) for testing purposes
if [[ "${rust_ver[0]}" -gt "${min_rust[0]}" ]] ; then
return 0
fi
if [[ "${rust_ver[0]}" -lt "${min_rust[0]}" ]] ; then
return 1
fi
if [[ "${rust_ver[1]}" -gt "${min_rust[1]}" ]] ; then
return 0
fi
if [[ "${rust_ver[1]}" -lt "${min_rust[1]}" ]] ; then
return 1
fi
if [[ "${rust_ver[2]}" -gt "${min_rust[2]}" ]] ; then
return 0
fi
if [[ "${rust_ver[2]}" -lt "${min_rust[2]}" ]] ; then
return 1
fi
return 0
}
if ! check_rust_version ; then
rust_ver=$(IFS=. ; echo "${rust_ver[*]}")
min_rust=$(IFS=. ; echo "${min_rust[*]}")
echo "Installed rustc version $rust_ver is less than required $min_rust"
echo
echo "Using rustup to manage your installed version of Rust is recommended"
echo "https://www.rust-lang.org/en-US/install.html"
echo
echo "See https://wezfurlong.org/wezterm/install/source.html for complete"
echo "installation instructions for wezterm"
exit 1
fi
exit 0

View File

@ -1,53 +1,6 @@
#!/bin/bash
min_rust=(1 53 0)
rust_ver=()
parse_rustc_version() {
local IFS
IFS=' '
local FIELDS
read -ra FIELDS <<< $(rustc --version)
IFS='.'
read -ra rust_ver <<< "${FIELDS[1]}"
}
check_rust_version() {
parse_rustc_version
# rust_ver=(1 46 0) for testing purposes
if [[ "${rust_ver[0]}" -gt "${min_rust[0]}" ]] ; then
return 0
fi
if [[ "${rust_ver[0]}" -lt "${min_rust[0]}" ]] ; then
return 1
fi
if [[ "${rust_ver[1]}" -gt "${min_rust[1]}" ]] ; then
return 0
fi
if [[ "${rust_ver[1]}" -lt "${min_rust[1]}" ]] ; then
return 1
fi
if [[ "${rust_ver[2]}" -gt "${min_rust[2]}" ]] ; then
return 0
fi
if [[ "${rust_ver[2]}" -lt "${min_rust[2]}" ]] ; then
return 1
fi
return 0
}
if ! check_rust_version ; then
rust_ver=$(IFS=. ; echo "${rust_ver[*]}")
min_rust=$(IFS=. ; echo "${min_rust[*]}")
echo "Installed rustc version $rust_ver is less than required $min_rust"
echo
echo "Using rustup to manage your installed version of Rust is recommended"
echo "https://www.rust-lang.org/en-US/install.html"
echo
echo "See https://wezfurlong.org/wezterm/install/source.html for complete"
echo "installation instructions for wezterm"
if ! ./ci/check-rust-version.sh ; then
exit 1
fi