share/mk: Add sccache suport for WITH_CCACHE_BUILD option
By setting CCACHE_NAME=sccache , sccache can be used as an alternative for ccache. Reviewed by: emaste, jhb Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49417
This commit is contained in:
@@ -66,9 +66,10 @@ CCACHE_BUILD_TYPE?= command
|
|||||||
# PATH since it is more clear that ccache is used and avoids wasting time
|
# PATH since it is more clear that ccache is used and avoids wasting time
|
||||||
# for mkdep/linking/asm builds.
|
# for mkdep/linking/asm builds.
|
||||||
LOCALBASE?= /usr/local
|
LOCALBASE?= /usr/local
|
||||||
|
CCACHE_NAME?= ccache
|
||||||
CCACHE_PKG_PREFIX?= ${LOCALBASE}
|
CCACHE_PKG_PREFIX?= ${LOCALBASE}
|
||||||
CCACHE_WRAPPER_PATH?= ${CCACHE_PKG_PREFIX}/libexec/ccache
|
CCACHE_WRAPPER_PATH?= ${CCACHE_PKG_PREFIX}/libexec/ccache
|
||||||
CCACHE_BIN?= ${CCACHE_PKG_PREFIX}/bin/ccache
|
CCACHE_BIN?= ${CCACHE_PKG_PREFIX}/bin/${CCACHE_NAME}
|
||||||
.if exists(${CCACHE_BIN})
|
.if exists(${CCACHE_BIN})
|
||||||
# Export to ensure sub-makes can filter it out for mkdep/linking and
|
# Export to ensure sub-makes can filter it out for mkdep/linking and
|
||||||
# to chain down into kernel build which won't include this file.
|
# to chain down into kernel build which won't include this file.
|
||||||
@@ -122,7 +123,12 @@ CCACHE_NOCPP2= 1
|
|||||||
.endif
|
.endif
|
||||||
# Canonicalize CCACHE_DIR for meta mode usage.
|
# Canonicalize CCACHE_DIR for meta mode usage.
|
||||||
.if !defined(CCACHE_DIR)
|
.if !defined(CCACHE_DIR)
|
||||||
|
.if !empty(CCACHE_BIN:M*sccache)
|
||||||
|
# Get the temp directory and remove beginning and trailing \"
|
||||||
|
CCACHE_DIR!= ${CCACHE_BIN} -s | awk '$$2 == "location" && $$3 == "Local" {print substr($$5, 2, length($$5) - 2)}'
|
||||||
|
.else
|
||||||
CCACHE_DIR!= ${CCACHE_BIN} -p | awk '$$2 == "cache_dir" {print $$4}'
|
CCACHE_DIR!= ${CCACHE_BIN} -p | awk '$$2 == "cache_dir" {print $$4}'
|
||||||
|
.endif
|
||||||
.export CCACHE_DIR
|
.export CCACHE_DIR
|
||||||
.endif
|
.endif
|
||||||
.if !empty(CCACHE_DIR) && empty(.MAKE.META.IGNORE_PATHS:M${CCACHE_DIR})
|
.if !empty(CCACHE_DIR) && empty(.MAKE.META.IGNORE_PATHS:M${CCACHE_DIR})
|
||||||
@@ -134,7 +140,11 @@ CCACHE_DIR:= ${CCACHE_DIR:tA}
|
|||||||
# comparisons.
|
# comparisons.
|
||||||
.MAKE.META.IGNORE_PATHS+= ${CCACHE_BIN}
|
.MAKE.META.IGNORE_PATHS+= ${CCACHE_BIN}
|
||||||
ccache-print-options: .PHONY
|
ccache-print-options: .PHONY
|
||||||
|
.if !empty(CCACHE_BIN:M*sccache)
|
||||||
|
@${CCACHE_BIN} -s
|
||||||
|
.else
|
||||||
@${CCACHE_BIN} -p
|
@${CCACHE_BIN} -p
|
||||||
|
.endif # !empty(CCACHE_BIN:M*sccache)
|
||||||
.endif # exists(${CCACHE_BIN})
|
.endif # exists(${CCACHE_BIN})
|
||||||
.endif # ${MK_CCACHE_BUILD} == "yes"
|
.endif # ${MK_CCACHE_BUILD} == "yes"
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,18 @@ Use
|
|||||||
for the build.
|
for the build.
|
||||||
No configuration is required except to install the
|
No configuration is required except to install the
|
||||||
.Sy devel/ccache
|
.Sy devel/ccache
|
||||||
|
or
|
||||||
|
.Sy devel/sccache
|
||||||
package.
|
package.
|
||||||
When using with
|
When using with
|
||||||
.Xr distcc 1 ,
|
.Xr distcc 1 ,
|
||||||
set
|
set
|
||||||
.Sy CCACHE_PREFIX=/usr/local/bin/distcc .
|
.Sy CCACHE_PREFIX=/usr/local/bin/distcc .
|
||||||
|
When using with sccache
|
||||||
|
set
|
||||||
|
.Sy CCACHE_NAME=sccache
|
||||||
|
in
|
||||||
|
.Xr src.conf 5 .
|
||||||
The default cache directory of
|
The default cache directory of
|
||||||
.Pa $HOME/.ccache
|
.Pa $HOME/.ccache
|
||||||
will be used, which can be overridden by setting
|
will be used, which can be overridden by setting
|
||||||
|
|||||||
Reference in New Issue
Block a user