"make test" always produces TEST_LOGFILE (default is ${WRKDIR}/test.log)
which is really handy for analysing failures and sharing them here on
ports@.
Diff below implements BUILD_LOGFILE so "make build" behaves the same;
sometimes builds fail late and/or relevant output has fallen of my
teminal's scrollback history.
File descriptor handling is finicky and the build target differs from
the test one, but for devel/coccinelle I just got a build.log as
expected.
Do others consider this useful? If so, I can handle the other case for
ports with an explicit do-build target as well, bsd.port.mk(5)
documentation follows if this goes in.
Any potential issues with the build target I am not aware of that
prevents doing so?
FAKE_LOGFILE could be a thing as well; generally, I don't think it
hurts to log stuff by default.
Index: infrastructure/mk/bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.1542
diff -u -p -r1.1542 bsd.port.mk
--- infrastructure/mk/bsd.port.mk 26 Jun 2020 11:51:16 -0000 1.1542
+++ infrastructure/mk/bsd.port.mk 18 Jul 2020 18:09:14 -0000
@@ -889,6 +889,9 @@ WRKCONF ?= ${WRKBUILD}
_WRKDEBUG = ${WRKINST}/debug-pkg
+BUILD_LOGFILE ?= ${WRKDIR}/build.log
+BUILD_LOG = | ${_PBUILD} tee ${BUILD_LOGFILE}
+
MAKE_FILE ?= Makefile
ALL_TARGET ?= all
@@ -2921,8 +2924,10 @@ ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
@${_PMAKE} do-build
. else
# What BUILD normally does:
- @cd ${WRKBUILD} && exec ${_PBUILD} ${SETENV} ${MAKE_ENV} \
- ${MAKE_PROGRAM} ${MAKE_FLAGS} -f ${MAKE_FILE} ${ALL_TARGET}
+ @cd ${WRKBUILD} && exec 3>&1 && exit `exec 4>&1 1>&3; \
+ (exec; set +e; ${_PBUILD} ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM}
\
+ ${MAKE_FLAGS} -f ${MAKE_FILE} ${ALL_TARGET}; \
+ echo $$? >&4) 2>&1 ${BUILD_LOG}`
# End of BUILD
. endif
. if target(post-build)