#!/bin/bash
# Cargo's rustc wrapper for this workspace (`.cargo/config.toml`): Cargo runs it as
# `rustc-wrapper RUSTC ARGS...`. It hands the compile to kache, a local compiler cache, where
# kache is on PATH and the build is not CI's; anywhere else it runs the compiler itself. kache is a
# tool on PATH, never a dependency, and its store stays on the machine.
#
# bash, not sh: the wrapper must hand the compiler the environment Cargo gave it, and Cargo names
# some variables after a target with a hyphen in it (`CARGO_BIN_EXE_corpus-triage`, which `env!`
# reads in the validation crate's integration tests). dash, `/bin/sh` on Debian and Ubuntu, drops
# every variable whose name is not a shell identifier from the environment it passes on; bash
# passes them through.
if [ -z "${CI:-}" ] && command -v kache >/dev/null 2>&1; then
  exec kache "$@"
fi
exec "$@"
