#!/usr/bin/env bash # Use sccache for rustc when it is installed. It is a developer convenience, never a requirement: # without it nothing is exported and a clone needs only stable Rust and a C compiler. # # Sourced, it exports RUSTC_WRAPPER into the current shell for later cargo commands; run with a # command, it wraps just that command. The verify, land and smoke scripts source it themselves. # # . scripts/sccache.sh && cargo play # scripts/sccache.sh cargo play # # An existing RUSTC_WRAPPER wins, BENILLA_NO_SCCACHE=1 skips this, and SCCACHE_DISABLE=1 turns # sccache itself off. Only rustc is wrapped: the vendored Lua build wants its own `CC="sccache cc"`. # Sourced, it must not change the caller's shell options. enable() { [ -n "${RUSTC_WRAPPER:-}" ] && return 0 [ -n "${BENILLA_NO_SCCACHE:-}" ] && return 0 command -v sccache >/dev/null 2>&1 || return 0 export RUSTC_WRAPPER=sccache } enable # Executed with a command: run it wrapped. Sourced: leave the caller's positionals alone. if [ "${BASH_SOURCE[0]}" = "$0" ] && [ "$#" -gt 0 ]; then exec "$@" fi