23 lines
364 B
Bash
23 lines
364 B
Bash
_try_cc() {
|
|
local out="$1"
|
|
shift
|
|
local infile
|
|
infile=$(mktemp --suffix .c)
|
|
cat > "$infile"
|
|
CCACHE_NOHASHDIR=1 ccache "${CC:-cc}" -o "$out" "$infile" "$@"
|
|
code=$?
|
|
rm "$infile" || :
|
|
return $?
|
|
}
|
|
|
|
cash() {
|
|
local out
|
|
out=$(mktemp)
|
|
_try_cc "$out" "$@" || {
|
|
code=$?
|
|
echo 'Error: compilation failed' >&2
|
|
rm "$out" || :
|
|
return "$code"
|
|
}
|
|
echo "$out"
|
|
}
|