cash/cash.sh

24 lines
364 B
Bash
Raw Permalink Normal View History

2024-12-29 00:45:07 +03:00
_try_cc() {
local out="$1"
shift
local infile
infile=$(mktemp --suffix .c)
cat > "$infile"
2024-12-29 22:55:26 +03:00
CCACHE_NOHASHDIR=1 ccache "${CC:-cc}" -o "$out" "$infile" "$@"
2024-12-29 00:45:07 +03:00
code=$?
rm "$infile" || :
return $?
}
cash() {
local out
out=$(mktemp)
_try_cc "$out" "$@" || {
code=$?
echo 'Error: compilation failed' >&2
rm "$out" || :
return "$code"
}
echo "$out"
}