Consolidate the "don't build" optimizations into _SKIP_BUILD.

_SKIP_BUILD will be set when nothing is expected to be built.  This can
be used to optimize some tree-walks and operations which don't need to
load dependency files or generate dependencies via beforebuild-style
hacks.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
This commit is contained in:
bdrewery 2016-11-13 00:11:02 +00:00
parent 44e193847a
commit 1ef06821e2
2 changed files with 22 additions and 8 deletions

View File

@ -77,12 +77,10 @@ _meta_filemon= 1
.endif
# Skip reading .depend when not needed to speed up tree-walks and simple
# lookups. For install, only do this if no other targets are specified.
# lookups. See _SKIP_BUILD logic in bsd.init.mk for more details.
# Also skip generating or including .depend.* files if in meta+filemon mode
# since it will track dependencies itself. OBJS_DEPEND_GUESS is still used.
.if !empty(.MAKEFLAGS:M-V${_V_READ_DEPEND}) || make(obj) || make(clean*) || \
${.TARGETS:M*install*} == ${.TARGETS} || \
make(analyze) || defined(_meta_filemon) || make(print-dir)
.if defined(_SKIP_BUILD) || defined(_meta_filemon)
_SKIP_READ_DEPEND= 1
.if ${MK_DIRDEPS_BUILD} == "no" || make(analyze) || make(print-dir)
.MAKE.DEPENDFILE= /dev/null

View File

@ -16,11 +16,27 @@ __<bsd.init.mk>__:
.include <bsd.own.mk>
.MAIN: all
.if ${.MAKE.LEVEL:U1} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no" && !make(clean*)
# this tells lib.mk and prog.mk to not actually build anything
_SKIP_BUILD = not building at level 0
# Some targets need to know when something may build. This is used to
# optimize targets that are only needed when building something, such as
# (not) reading in depend files. For DIRDEPS_BUILD, it will only calculate
# the dependency graph at .MAKE.LEVEL==0, so nothing should be built there.
# Skip "build" logic if:
# - DIRDEPS_BUILD at MAKELEVEL 0
# - make -V is used without an override
# - make install is used without other targets. This is to avoid breaking
# things like 'make all install' or 'make foo install'.
# - non-build targets are called
.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL:U1} == 0 && \
${BUILD_AT_LEVEL0:Uyes:tl} == "no" && !make(clean*)
_SKIP_BUILD= not building at level 0
.elseif !empty(.MAKEFLAGS:M-V${_V_DO_BUILD}) || \
${.TARGETS:M*install*} == ${.TARGETS} || \
make(clean*) || make(obj) || make(analyze) || make(print-dir) || \
make(destroy*)
# Skip building, but don't show a warning.
_SKIP_BUILD=
.endif
.if ${.MAKE.LEVEL} > 0 && !empty(_SKIP_BUILD)
.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} > 0 && !empty(_SKIP_BUILD)
.warning ${_SKIP_BUILD}
.endif