Skip to content

Instantly share code, notes, and snippets.

@topecongiro
Last active December 15, 2017 02:34
Show Gist options
  • Save topecongiro/7c87b4c424453039899bd21ded0a056b to your computer and use it in GitHub Desktop.
Save topecongiro/7c87b4c424453039899bd21ded0a056b to your computer and use it in GitHub Desktop.
Keep rustfmt and clippy up to date
#!/bin/sh
BUILD_DIR=$HOME/.rust-tool-build
# update_tool tool_name tool_binary
update_tool() {
rustup run nightly $2 --version 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echo "Updating $1"
mkdir -p $BUILD_DIR/.cargo
cd $BUILD_DIR
cat > .cargo/config <<-EOL
[build]
rustflags = [
"-C", "link-arg=-Xlinker",
"-C", "link-arg=-rpath=$(rustc --print sysroot)/lib",
]
EOL
rustup run nightly cargo install --force $1
else
echo "$1 is up to date"
fi
}
# Update to the latest nightly
rustup update nightly
# Update rustfmt and clippy
update_tool rustfmt-nightly rustfmt
update_tool clippy clippy-driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment