From 5c805d95f6e69e549234846eb1101103d42e48ff Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sat, 13 Jan 2018 10:29:56 -0800 Subject: [PATCH] [meta] add script for updating Rust --- bin/rust-update | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 bin/rust-update diff --git a/bin/rust-update b/bin/rust-update new file mode 100755 index 0000000..a987bbe --- /dev/null +++ b/bin/rust-update @@ -0,0 +1,31 @@ +#!/bin/sh + +if [ "$1" = '-h' ] ; then + echo 'Updates rustc & clippy' + echo 'It first checks if clippy would compile at currentl nightly and if so, it updates.' + echo 'Options:' + echo '-h: This help message' + echo '-f: Skips the check and just updates' + exit +fi + +set -ex + +renice -n 10 -p $$ + +export CARGO_INCREMENTAL=0 +export RUSTFLAGS='-C target-cpu=native' + +try_out() { + export RUSTUP_HOME=$HOME/.rustup-attempt + test -d $RUSTUP_HOME || (rustup toolchain add nightly && rustup default nightly) + rustup update + cargo +nightly install --force clippy + unset RUSTUP_HOME + export RUSTUP_HOME +} + +[ "$1" = '-f' ] || try_out + +rustup update +cargo +nightly install --force clippy