Klemens Nanni writes:
> I'm not convinced we should help the port(er) use ccache(1) directly.
>
> Rather all usage should go through USE_CCACHE, which does warn if the
> package is missing.
USE_CCACHE is a user setting, so ports aren't allowed to toggle it.
The only option within a port is to add ccache to BUILD_DEPENDS or to
disable ccache in the upstream code.
Of course disabling is better, but sometimes there is no knob, so we
patch ccache away. I can imagine a situation where it's too hard to
patch away (I'm thinking of the handful of ports that still use doxygen
despite our best efforts). Avoiding a hidden dep is the most important
thing since it hurts bulks.
> > # poison some common binaries unless the relevant BUILD_DEPENDS is used
> > +.if empty(_BUILD_DEP:Mdevel/ccache) && \
> > + empty(_BUILD_DEP:Mdevel/ccache)
>
> Same check twice?
Oops, fixed.
> > + @printf '#!/bin/sh\n\
> > + echo "*** $$0 was called without devel/ccache dependency ***" >
> &2\n\
>
> Again, I'd refer to our bsd.port.mk knob and not encourage direct use.
As mentioned, it doesn't make sense to reference our USE_CCACHE here.
This check is for catching a problem in the port whether the porter has
chosen to enable ccache or not.
Here's a better version that encourages disabling ccache first.
--- infrastructure/mk/bsd.port.mk
+++ infrastructure/mk/bsd.port.mk
@@ -452,7 +452,8 @@ CCACHE_DIR ?= ${WRKOBJDIR_${PKGPATH}}/.ccache
MAKE_ENV += CCACHE_DIR=${CCACHE_DIR} ${CCACHE_ENV}
CONFIGURE_ENV += CCACHE_DIR=${CCACHE_DIR}
# scons cleans the environment when calling the compiler
-COMPILER_WRAPPER += env CCACHE_DIR=${CCACHE_DIR} ${CCACHE_ENV} ccache
+COMPILER_WRAPPER += env CCACHE_DIR=${CCACHE_DIR} ${CCACHE_ENV} \
+ ${LOCALBASE}/bin/ccache
. if !exists(${LOCALBASE}/bin/ccache)
ERRORS += "Fatal: USE_CCACHE is set, but ccache is not installed."
. endif
@@ -2783,6 +2784,12 @@ ${_WRKDIR_COOKIE}:
@${_PBUILD} mkdir -p ${WRKDIR} ${WRKDIR}/bin
@${_wrap_install_commands}
# poison some common binaries unless the relevant BUILD_DEPENDS is used
+.if empty(_BUILD_DEP:Mdevel/ccache)
+ @printf '#!/bin/sh\n\
+ echo "*** $$0 was called; disable it or add an explicit
dependency ***" >&2\n\
+ exit 1\n' ${_PREDIR} ${WRKDIR}/bin/ccache
+ @${_PBUILD} chmod 555 ${WRKDIR}/bin/ccache
+.endif
.if empty(_BUILD_DEP:Mdevel/gettext,-tools) && \
empty(_BUILD_DEP:Mtextproc/intltool)
@printf '#!/bin/sh\n\
@@ -2793,6 +2800,12 @@ ${_WRKDIR_COOKIE}:
@${_PBUILD} ln -sf msgfmt ${WRKDIR}/bin/${name}
. endfor
.endif
+.if empty(_BUILD_DEP:Mdevel/sccache)
+ @printf '#!/bin/sh\n\
+ echo "*** $$0 was called; disable it or add an explicit
dependency ***" >&2\n\
+ exit 1\n' ${_PREDIR} ${WRKDIR}/bin/sccache
+ @${_PBUILD} chmod 555 ${WRKDIR}/bin/sccache
+.endif
.if empty(_BUILD_DEP:Mtextproc/asciidoc)
@printf '#!/bin/sh\n\
echo "*** $$0 was called without textproc/asciidoc dependency
***" >&2\n\