Last active
April 5, 2017 08:17
-
-
Save colin-kiegel/52ebfa55bfb12878bb32 to your computer and use it in GitHub Desktop.
racer-update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RACER_SRC_PATH="/usr/local/src/racer" | |
RACER_REPO="https://github.com/phildawes/racer.git" | |
RUST_REPO="https://github.com/rust-lang/rust.git" | |
if [ -z $RUST_SRC_PATH ]; then | |
echo "TODO: Set the RUST_SRC_PATH env variable to point to the 'src' dir in your rust source installation, e.g.: | |
export RUST_SRC_PATH=/usr/local/src/rust/src"; | |
RUST_SRC_PATH=/usr/local/src/rust/src | |
fi | |
# move up one directory e.g. "path/rust/src" -> "path/rust" | |
RUST_SRC_PATH_REAL="$(dirname $RUST_SRC_PATH)"; | |
if [ ! -d $RUST_SRC_PATH_REAL ]; then | |
echo "RUST: download source" | |
sudo git clone -b stable $RUST_REPO $RUST_SRC_PATH_REAL | |
else | |
echo "RUST: switching to stable branch" | |
sudo git -C $RUST_SRC_PATH_REAL checkout stable | |
echo "RUST: reset local changes" | |
sudo git -C $RUST_SRC_PATH_REAL reset --hard origin/stable | |
echo "RUST: remove untracked files" | |
sudo git -C $RUST_SRC_PATH_REAL clean -f | |
echo "RUST: update source" | |
sudo git -C $RUST_SRC_PATH_REAL pull | |
fi | |
if [ ! -d $RACER_SRC_PATH ]; then | |
echo "RACER: download source" | |
sudo git clone $RACER_REPO $RACER_SRC_PATH | |
else | |
echo "RACER: update source" | |
sudo git -C $RACER_SRC_PATH pull | |
fi | |
echo "RACER: cargo build --release" | |
cd /usr/local/src/racer | |
sudo $HOME/.cargo/bin/rustup run nightly cargo build --release | |
echo "RACER: deploy binary" | |
sudo rm /usr/local/bin/racer | |
sudo cp /usr/local/src/racer/target/release/racer /usr/local/bin/racer | |
sudo chmod 1755 /usr/local/bin/racer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
place this in
/usr/local/bin
andchmod +x