Auto-create bmake/unit-tests objdir if appropriate

Given the way bmake/unit-tests is visited, when doing 'test'
MK_AUTO_OBJ=yes will not be effective.
So create the objdir before running the sub-make.

Also ensure MAKEOBJDIR is passed to opt-m-include-dir

Reviewed by: deo
This commit is contained in:
Simon J. Gerraty 2022-07-26 13:24:34 -07:00
parent e726e71056
commit 08604a023d
2 changed files with 15 additions and 1 deletions

View file

@ -147,11 +147,24 @@ ${OBJS}: config.h
# A simple unit-test driver to help catch regressions
TEST_MAKE ?= ${.OBJDIR}/${PROG:T}
accept test:
accept test: .NOMETA
cd ${.CURDIR}/unit-tests && \
MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}}
.if make(test) && ${MK_AUTO_OBJ} == "yes"
# because of the way unit-tests is visted for test
# the objdir will not be auto-created as expected.
.if defined(MAKEOBJDIRPREFIX) || ${MAKEOBJDIR:Uno:M*/*} != ""
_utobj = ${.OBJDIR}/unit-tests
.else
_utobj = ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj}
.endif
utobj: .NOMETA
mkdir -p ${_utobj}
test: utobj
.endif
# override some simple things
BINDIR= /usr/bin
MANDIR= /usr/share/man/man

View file

@ -505,6 +505,7 @@ ENV.depsrc-optional+= TZ=UTC
ENV.deptgt-phony+= MAKESYSPATH=.
ENV.directive-undef= ENV_VAR=env-value
ENV.envfirst= FROM_ENV=value-from-env
ENV.opt-m-include-dir= ${MAKEOBJDIR:DMAKEOBJDIR=${MAKEOBJDIR}}
ENV.varmisc= FROM_ENV=env
ENV.varmisc+= FROM_ENV_BEFORE=env
ENV.varmisc+= FROM_ENV_AFTER=env