From f94322513829cdab2c683787d581733c63a0fb36 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 28 Jan 2011 15:14:41 -0500 Subject: [PATCH] tool: use ccache in gccx, if available This improves the compile-time of the hot-compilation case. Signed-off-by: Jean Privat --- bin/gccx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bin/gccx b/bin/gccx index bdeb3bb..6bcd9cf 100755 --- a/bin/gccx +++ b/bin/gccx @@ -66,6 +66,11 @@ fi return $res } +cache=true +if ccache -V 2>&1 >/dev/null; then + cache=ccache +fi + stop=false verbose=false vverbose=false @@ -91,6 +96,10 @@ if [ $nolibgc != true ] && test_libgc; then OPTS="$OPTS -DWITH_LIBGC -lgc" fi +if [ $cache = "ccache" ]; then + CC="ccache $CC" +fi + for i in "$@"; do j=`basename "$i" .c` transformed=`echo "$i" | sed " @@ -107,6 +116,13 @@ for i in "$@"; do "` found="false" + if [ $cache != true ]; then + o="$dir$j.o" + if [ $vverbose = true ] ; then + echo "* $CC $OPTS -c $i -o $o" >&2 + fi + $CC $OPTS -c $i -o $o || exit 1 + else # We remove starting # to be path independent (after preprocess, there are the only # remainings) cksum=`gcc -E $OPTS $i 2> /dev/null | grep -v "^#" | $CKSUM` for e in $ext; do @@ -137,6 +153,7 @@ for i in "$@"; do exit 1 fi fi +fi objs="$objs $o" done -- 1.7.9.5