Latest dirdeps.mk and meta.stage.mk
Add support for dirdeps cache and allow full path as key for STAGE_AS_*
This commit is contained in:
parent
3b33c213ef
commit
71edef51db
@ -1,4 +1,4 @@
|
||||
# $Id: dirdeps.mk,v 1.38 2014/11/20 22:22:30 sjg Exp $
|
||||
# $Id: dirdeps.mk,v 1.53 2015/05/24 07:08:24 sjg Exp $
|
||||
|
||||
# Copyright (c) 2010-2013, Juniper Networks, Inc.
|
||||
# All rights reserved.
|
||||
@ -123,6 +123,12 @@ _DIRDEP_USE_LEVEL?= 0
|
||||
.if !target(_DIRDEP_USE)
|
||||
# do some setup we only need once
|
||||
_CURDIR ?= ${.CURDIR}
|
||||
_OBJDIR ?= ${.OBJDIR}
|
||||
|
||||
now_utc = ${%s:L:gmtime}
|
||||
.if !defined(start_utc)
|
||||
start_utc := ${now_utc}
|
||||
.endif
|
||||
|
||||
# make sure these are empty to start with
|
||||
_DEP_TARGET_SPEC =
|
||||
@ -334,6 +340,70 @@ _only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}}
|
||||
DIRDEPS ?= ${RELDIR}
|
||||
.endif # target
|
||||
|
||||
# if repeatedly building the same target,
|
||||
# we can avoid the overhead of re-computing the tree dependencies.
|
||||
MK_DIRDEPS_CACHE ?= no
|
||||
BUILD_DIRDEPS_CACHE ?= no
|
||||
BUILD_DIRDEPS ?= yes
|
||||
|
||||
.if !defined(NO_DIRDEPS)
|
||||
.if ${MK_DIRDEPS_CACHE} == "yes"
|
||||
# this is where we will cache all our work
|
||||
DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
|
||||
|
||||
# just ensure this exists
|
||||
build-dirdeps:
|
||||
|
||||
M_oneperline = @x@\\${.newline} $$x@
|
||||
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "no"
|
||||
.if !target(dirdeps-cached)
|
||||
# we do this via sub-make
|
||||
BUILD_DIRDEPS = no
|
||||
|
||||
dirdeps: dirdeps-cached
|
||||
dirdeps-cached: ${DIRDEPS_CACHE} .MAKE
|
||||
@echo "${TRACER}Using ${DIRDEPS_CACHE}"
|
||||
@MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \
|
||||
dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no
|
||||
|
||||
# these should generally do
|
||||
BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE}
|
||||
BUILD_DIRDEPS_TARGETS ?= ${.TARGETS}
|
||||
|
||||
# we need the .meta file to ensure we update if
|
||||
# any of the Makefile.depend* changed.
|
||||
# We do not want to compare the command line though.
|
||||
${DIRDEPS_CACHE}: .META .NOMETA_CMP
|
||||
+@{ echo '# Autogenerated - do NOT edit!'; echo; \
|
||||
echo 'BUILD_DIRDEPS=no'; echo; \
|
||||
echo '.include <dirdeps.mk>'; \
|
||||
} > ${.TARGET}.new
|
||||
+@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \
|
||||
DIRDEPS="${DIRDEPS}" \
|
||||
MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \
|
||||
${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \
|
||||
.MAKE.DEPENDFILE=.none \
|
||||
3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g' >> ${.TARGET}.new && \
|
||||
mv ${.TARGET}.new ${.TARGET}
|
||||
|
||||
.endif
|
||||
.elif !target(_count_dirdeps)
|
||||
# we want to capture the dirdeps count in the cache
|
||||
.END: _count_dirdeps
|
||||
_count_dirdeps: .NOMETA
|
||||
@echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3
|
||||
|
||||
.endif
|
||||
.elif !make(dirdeps) && !target(_count_dirdeps)
|
||||
beforedirdeps: _count_dirdeps
|
||||
_count_dirdeps: .NOMETA
|
||||
@echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"
|
||||
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if ${BUILD_DIRDEPS} == "yes"
|
||||
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
|
||||
_debug_reldir = 1
|
||||
.else
|
||||
@ -453,8 +523,14 @@ _build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
|
||||
# but if we want to count the number of Makefile.depend* read, we do.
|
||||
.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == ""
|
||||
.if !empty(_build_dirs)
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
||||
x!= { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \
|
||||
echo 'dirdeps: ${_build_dirs:${M_oneperline}}'; echo; } >&3; echo
|
||||
x!= { ${_build_dirs:@x@${target($x):?:echo '$x: _DIRDEP_USE';}@} echo; } >&3; echo
|
||||
.else
|
||||
# this makes it all happen
|
||||
dirdeps: ${_build_dirs}
|
||||
.endif
|
||||
${_build_dirs}: _DIRDEP_USE
|
||||
|
||||
.if ${_debug_reldir}
|
||||
@ -469,13 +545,21 @@ ${_build_dirs}: _DIRDEP_USE
|
||||
.if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
|
||||
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q}
|
||||
.endif
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
||||
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$q:${M_oneperline}}'; echo; } >&3; echo
|
||||
.else
|
||||
${_this_dir}.$m: ${_build_dirs:M*.$q}
|
||||
.endif
|
||||
.endfor
|
||||
.endif
|
||||
.if ${_debug_reldir}
|
||||
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m}
|
||||
.endif
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
||||
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m:${M_oneperline}}'; echo; } >&3; echo
|
||||
.else
|
||||
${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
.endif
|
||||
@ -514,6 +598,7 @@ _DEP_MACHINE := ${d:E:C/,.*//}
|
||||
.endfor
|
||||
|
||||
.endif # -V
|
||||
.endif # BUILD_DIRDEPS
|
||||
|
||||
.elif ${.MAKE.LEVEL} > 42
|
||||
.error You should have stopped recursing by now.
|
||||
@ -524,7 +609,7 @@ _DEP_RELDIR := ${DEP_RELDIR}
|
||||
.endif
|
||||
|
||||
# bootstrapping new dependencies made easy?
|
||||
.if make(bootstrap*) && !target(bootstrap)
|
||||
.if (make(bootstrap) || make(bootstrap-recurse)) && !target(bootstrap)
|
||||
|
||||
.if exists(${.CURDIR}/${.MAKE.DEPENDFILE:T})
|
||||
# stop here
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: meta.stage.mk,v 1.34 2014/11/20 22:40:08 sjg Exp $
|
||||
# $Id: meta.stage.mk,v 1.35 2015/05/20 06:40:33 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2011, Simon J. Gerraty
|
||||
#
|
||||
@ -218,7 +218,7 @@ STAGE_AS.$s ?= ${.ALLSRC:N.dirdep}
|
||||
|
||||
stage_as: stage_as.$s
|
||||
stage_as.$s: .dirdep
|
||||
@${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:T}:U${f:T}}@}
|
||||
@${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}
|
||||
@touch $@
|
||||
|
||||
.endfor
|
||||
@ -238,7 +238,9 @@ staging:
|
||||
# generally we want staging to wait until everything else is done
|
||||
STAGING_WAIT ?= .WAIT
|
||||
|
||||
.if ${.MAKE.LEVEL} > 0
|
||||
all: ${STAGING_WAIT} staging
|
||||
.endif
|
||||
|
||||
.if exists(${.PARSEDIR}/stage-install.sh) && !defined(STAGE_INSTALL)
|
||||
# this will run install(1) and then followup with .dirdep files.
|
||||
|
Loading…
x
Reference in New Issue
Block a user