diff --git a/Defs.make b/Defs.make index 28e6e5b02ee..4ffc191a35a 100644 --- a/Defs.make +++ b/Defs.make @@ -50,6 +50,28 @@ AR ?= ar OBJCOPY ?= objcopy STRIP ?= strip +# +# ccache support +# +CCACHE ?= ccache +ifeq (, $(shell which $(CCACHE))) + +else + EE_CC := $(CCACHE) $(EE_CC) + EE_CXX := $(CCACHE) $(EE_CXX) + EE_AS := $(CCACHE) $(EE_AS) + EE_LD := $(CCACHE) $(EE_LD) + EE_AR := $(CCACHE) $(EE_AR) + IOP_CC := $(CCACHE) $(IOP_CC) + IOP_AS := $(CCACHE) $(IOP_AS) + IOP_LD := $(CCACHE) $(IOP_LD) + IOP_AR := $(CCACHE) $(IOP_AR) + CC := $(CCACHE) $(CC) + AS := $(CCACHE) $(AS) + LD := $(CCACHE) $(LD) + AR := $(CCACHE) $(AR) +endif + # # Definitions for local shell operations # diff --git a/samples/Makefile b/samples/Makefile index 22fbb39b990..e847aaa7cad 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -28,6 +28,7 @@ release-samples: cp -f Makefile.iopglobal_sample $(SAMPLES_TARGET)/Makefile.iopglobal cp -f ps2dev.cmake $(SHARE_TARGET)/ps2dev.cmake cp -f ps2dev_iop.cmake $(SHARE_TARGET)/ps2dev_iop.cmake + cp -f ccache.cmake $(SHARE_TARGET)/ccache.cmake release-clean: rm -f -r $(SAMPLES_TARGET) diff --git a/samples/Makefile.pref_sample b/samples/Makefile.pref_sample index d03c793da70..756066bf185 100644 --- a/samples/Makefile.pref_sample +++ b/samples/Makefile.pref_sample @@ -50,6 +50,28 @@ AR ?= ar OBJCOPY ?= objcopy STRIP ?= strip +# +# ccache support +# +CCACHE ?= ccache +ifeq (, $(shell which $(CCACHE))) + +else + EE_CC := $(CCACHE) $(EE_CC) + EE_CXX := $(CCACHE) $(EE_CXX) + EE_AS := $(CCACHE) $(EE_AS) + EE_LD := $(CCACHE) $(EE_LD) + EE_AR := $(CCACHE) $(EE_AR) + IOP_CC := $(CCACHE) $(IOP_CC) + IOP_AS := $(CCACHE) $(IOP_AS) + IOP_LD := $(CCACHE) $(IOP_LD) + IOP_AR := $(CCACHE) $(IOP_AR) + CC := $(CCACHE) $(CC) + AS := $(CCACHE) $(AS) + LD := $(CCACHE) $(LD) + AR := $(CCACHE) $(AR) +endif + # # Definitions for local shell operations # diff --git a/samples/ccache.cmake b/samples/ccache.cmake new file mode 100644 index 00000000000..a6973b1ee96 --- /dev/null +++ b/samples/ccache.cmake @@ -0,0 +1,10 @@ +find_program(CCACHE_FOUND "ccache") +set(CCACHE_SUPPORT ON CACHE BOOL "Enable ccache support") +if (CCACHE_FOUND AND CCACHE_SUPPORT) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # without this compiler messages in `make` backend would be uncolored + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto") + endif() + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache") +endif(CCACHE_FOUND AND CCACHE_SUPPORT) diff --git a/samples/ps2dev.cmake b/samples/ps2dev.cmake index f8feb3d51c0..eed5ff63710 100644 --- a/samples/ps2dev.cmake +++ b/samples/ps2dev.cmake @@ -53,3 +53,5 @@ SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostartfiles -Wl,-r -Wl,-d") SET(PS2 TRUE) SET(PLATFORM_PS2 TRUE) SET(EE TRUE) + +INCLUDE(${PS2DEV}/share/ccache.cmake) diff --git a/samples/ps2dev_iop.cmake b/samples/ps2dev_iop.cmake index 8e2e54938da..c292b7ae70a 100644 --- a/samples/ps2dev_iop.cmake +++ b/samples/ps2dev_iop.cmake @@ -78,3 +78,5 @@ ENDFUNCTION() SET(PLATFORM_PS2 TRUE) SET(IOP TRUE) SET(PS2 TRUE) + +INCLUDE(${PS2DEV}/share/ccache.cmake)