1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-09 22:15:15 +03:00
wezterm/ci/check-rust-version.sh
Wez Furlong a7cdd46720 logging: use our own custom logger
I wanted to use the Target::Pipe feature of env_logger so that we could
log to a log file as well as stderr, but it just doesn't work
(https://github.com/env-logger-rs/env_logger/issues/208).

Since we were already composing over the top of the logger in order
to capture data for our ringlog, this commit embraces that and makes
our logger responsible for both stderr and log file printing.

Thankfully, we can use the filter parsing code from env_logger to
avoid having to get too crazy with this.

Logs are stored in the runtime directory and look something like:

/run/user/1000/wezterm/wezterm-gui-log-596324.txt

Logs are collected on all platforms.

There isn't currently a thing to clean up logs.
2022-04-07 09:51:00 -07:00

55 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
min_rust=(1 57 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