Repository navigation
Expand file tree
/
Copy pathupdate_rust.sh
More file actions
executable file
·68 lines (58 loc) · 1.99 KB
/
Copy pathupdate_rust.sh
File metadata and controls
executable file
·68 lines (58 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -xueo pipefail
if ! rustup update; then
echo "rustup update failed; retrying."
if rustup toolchain list | grep -q '^nightly-'; then
echo "Reinstalling nightly toolchain (recover from partial install / conflicts)."
rustup toolchain uninstall nightly 2>/dev/null || true
rustup toolchain install nightly
fi
rustup update
fi
# Use the updated stable toolchain even if the default or current directory pins an older one.
rustup run stable cargo install cargo-edit superseedr bttf
rustup run stable cargo install cargo-shear --locked
upgrade_cargo_project() {
local _project_path=$1
local _cargo_manifest
local _cargo_toml_before
local _cargo_toml_after
local _cargo_shear_status
[[ -d "${_project_path}" ]] || return 0
echo "${_project_path}"
cd "${_project_path}"
if [[ -f Cargo.toml ]]; then
_cargo_manifest=Cargo.toml
elif [[ -f cargo.toml ]]; then
_cargo_manifest=cargo.toml
else
return 0
fi
cargo clean
cargo update || true
_cargo_toml_before=$(shasum -a 256 "${_cargo_manifest}" | awk '{print $1}')
if grep -Eq '^[[:space:]]*tokio-quiche[[:space:]]*=' "${_cargo_manifest}" && grep -Eq '^[[:space:]]*boring[[:space:]]*=' "${_cargo_manifest}"; then
cargo upgrade --incompatible --recursive false --exclude boring
else
cargo upgrade --incompatible --recursive false
fi
_cargo_shear_status=0
cargo shear --fix || _cargo_shear_status=$?
if [[ "${_cargo_shear_status}" -gt 1 ]]; then
return "${_cargo_shear_status}"
fi
_cargo_toml_after=$(shasum -a 256 "${_cargo_manifest}" | awk '{print $1}')
if [[ "${_cargo_toml_before}" != "${_cargo_toml_after}" ]]; then
cargo check || true
fi
cargo clean
}
# _rust_experiments_dir="${HOME}/matthewblair87@gmail.com - Google Drive/My Drive/experiments/rust"
# if [[ -d "${_rust_experiments_dir}" ]]; then
# for _project_path in "${_rust_experiments_dir}"/*; do
# if [[ -d "${_project_path}" ]]; then
# upgrade_cargo_project "${_project_path}"
# fi
# done
# fi
upgrade_cargo_project "${HOME}/my_src/mattyb.rs"