From dcff22df71b717773633d10a2753ef69713c7458 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Sat, 16 Nov 2024 01:07:03 +0100 Subject: [PATCH] Add ccache support --- build.sh | 5 +++++ n64.mk | 4 ++-- tools/Makefile | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index fb533e3ab4..5c62d907da 100755 --- a/build.sh +++ b/build.sh @@ -20,6 +20,11 @@ if [[ $OSTYPE == 'msys' ]]; then fi fi +# Check if ccache is installed, and if so, use it +if command -v ccache &> /dev/null; then + export CCACHE=ccache +fi + makeWithParams(){ make -j"${JOBS}" "$@" } diff --git a/n64.mk b/n64.mk index c3826305d1..5e67d0c537 100644 --- a/n64.mk +++ b/n64.mk @@ -31,8 +31,8 @@ N64_GCCPREFIX_TRIPLET = $(N64_GCCPREFIX)/bin/mips64-elf- COMMA:=, -N64_CC = $(N64_GCCPREFIX_TRIPLET)gcc -N64_CXX = $(N64_GCCPREFIX_TRIPLET)g++ +N64_CC = $(CCACHE) $(N64_GCCPREFIX_TRIPLET)gcc +N64_CXX = $(CCACHE) $(N64_GCCPREFIX_TRIPLET)g++ N64_AS = $(N64_GCCPREFIX_TRIPLET)as N64_AR = $(N64_GCCPREFIX_TRIPLET)ar N64_LD = $(N64_GCCPREFIX_TRIPLET)ld diff --git a/tools/Makefile b/tools/Makefile index dc52c5755c..8750e9c191 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -13,10 +13,10 @@ all: %.o: %.c @echo " [CC] $@" - $(CC) $(CFLAGS) -c -o $@ $< + $(CCACHE) $(CC) $(CFLAGS) -c -o $@ $< %.o: %.cpp @echo " [CXX] $@" - $(CXX) $(CXXFLAGS) -c -o $@ $< + $(CCACHE) $(CXX) $(CXXFLAGS) -c -o $@ $< %.a: @echo " [AR] $@" rm -f $@