forked from continuwuation/continuwuity
51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Continuously monitor .env (watch_file is a direnv thing)
|
|
watch_file .env
|
|
if [ -f .env ]; then
|
|
dotenv .env
|
|
fi
|
|
|
|
# Use more efficient cache tool, if available
|
|
if ! command -v sccache >/dev/null 2>&1; then
|
|
echo "INFO: You should install sccache for faster caching."
|
|
elif [ -z "$DISABLE_SCCACHE" ]; then
|
|
export RUSTC_WRAPPER=sccache
|
|
|
|
# Infer base compiler, fall back to POSIX defaults
|
|
BASE_CC="${CC:-cc}"
|
|
BASE_CXX="${CXX:-c++}"
|
|
|
|
# Wrap C/C++ compilers w/ sccache if not already
|
|
if [[ "$BASE_CC" != sccache* ]]; then
|
|
export CC="sccache $BASE_CC"
|
|
fi
|
|
if [[ "$BASE_CXX" != sccache* ]]; then
|
|
export CXX="sccache $BASE_CXX"
|
|
fi
|
|
else
|
|
echo "skipping sccache due to DISABLE_SCCACHE being set."
|
|
fi
|
|
|
|
# Use mold linker if available (faster than ld)
|
|
if command -v mold >/dev/null 2>&1; then
|
|
export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C link-arg=-fuse-ld=mold"
|
|
else
|
|
echo "INFO: You should install mold for faster linking."
|
|
fi
|
|
|
|
# Nix stuff left to override above, if desired
|
|
if [ -f /etc/os-release ] && grep -q '^ID=nixos' /etc/os-release; then
|
|
use flake ".#${DIRENV_DEVSHELL:-default}"
|
|
fi
|
|
|
|
# Include our bins in PATH
|
|
PATH_add bin
|
|
|
|
# Tab completion
|
|
# Source - https://stackoverflow.com/a/76060899
|
|
# cat ~/.local/share/bash-completion/completions/rust
|
|
if type -P rustup >/dev/null; then
|
|
source <(rustup completions bash) # for rustup
|
|
source <(rustup completions bash cargo) # for cargo
|
|
fi
|