Skip to content

Commit

Permalink
build: added support for ccache
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Jenikovsky <[email protected]>
  • Loading branch information
jendo42 committed Jul 9, 2024
1 parent d396ff8 commit 9c993c3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Defs.make
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
1 change: 1 addition & 0 deletions samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions samples/Makefile.pref_sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
10 changes: 10 additions & 0 deletions samples/ccache.cmake
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions samples/ps2dev.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions samples/ps2dev_iop.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ ENDFUNCTION()
SET(PLATFORM_PS2 TRUE)
SET(IOP TRUE)
SET(PS2 TRUE)

INCLUDE(${PS2DEV}/share/ccache.cmake)

0 comments on commit 9c993c3

Please sign in to comment.