Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Last active December 11, 2015 12:18
Show Gist options
  • Save nikomatsakis/4599447 to your computer and use it in GitHub Desktop.
Save nikomatsakis/4599447 to your computer and use it in GitHub Desktop.
#!/bin/bash
DIR="$PWD"
while [[ "$DIR" != "/" && "$DIR" != "$HOME" ]]; do
if [[ -r "$DIR/src/libsyntax/syntax.rc" ]]; then
echo "$DIR"
exit 0
fi
DIR=$(dirname "$DIR")
done
echo "/no/rust/root/found"
exit 1
#!/bin/bash
R=$($(dirname $0)/rustc-path)
if [[ -x "$R" ]]; then
echo > /dev/stderr Running "$R":
"$R" "$@"
exit $?
fi
echo > /dev/stderr "ERROR: Could not find an appropriate rustc to execute from dir $PWD!"
exit 1
#!/bin/bash
#
# Script which finds an appropriate rustc to execute based on the current
# directory. We begin by walking up the set of directories until we find
# one that contains "src/comp/rustc.rc".
# Walk up directories looking for the main rust directory. Don't walk
# past the home directory of the current user, just seems unsanitary.
if [ -z "$1" ]; then
STAGES="stage2 stage1"
else
STAGES="$1"
fi
DIR=$(rust-root)
for stage in ${STAGES}; do
# Use glob to search through all architectures.
# But if some stage doesn't exist, then
# the glob will keep the "*" rather than return the
# empty set, so we have to check within the for loop
# too.
for rustc in "$DIR"/build/*/$stage/bin/rustc; do
if [[ -x "$rustc" ]]; then
echo "$rustc"
exit 0
fi
done
done
# Fallback to /usr/local/bin/rustc, if any:
echo /usr/local/bin/rustc
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment