From nobody Sat Apr 23 21:44:24 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AFA771999F25; Sat, 23 Apr 2022 21:44:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Km4YN4V9tz4snT; Sat, 23 Apr 2022 21:44:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650750264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rhGdsTCKWNtZZehMblU4BmFMDWpJ+boatZs18+pdsG8=; b=ksfComK54CsbTQFFEq8tSMYj3FojygUXHOcsQ9pI5smWqEM4Un9t6iN1FuBOAiVM16jBnv cDG9kVUgb8Pa63hJx2hc/7cMVGgJltbJU3MLRbLvjPdVfRl5I22W3Khwhz/l+STTRpiP0C w+nybBRXXd87TrLP5qDwZ7YUU0wVlpEXm4G5mDLxJy8+cViXcV+ehOIhJP4MaOyRgOm2y/ oyz1jb4s8YIGhRELdH+Ea+K6psIMfOSuJh+64/JFVROJck2bvtIs2wL+YmIWp164tmooxi KYyHyn2R+pZcW6Em9FOsRYiH7cK1dCZXmKyfeYBujlAxu+hYUEY+hk8+dCKpPA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 79F6719C97; Sat, 23 Apr 2022 21:44:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23NLiOF2042365; Sat, 23 Apr 2022 21:44:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23NLiOeD042364; Sat, 23 Apr 2022 21:44:24 GMT (envelope-from git) Date: Sat, 23 Apr 2022 21:44:24 GMT Message-Id: <202204232144.23NLiOeD042364@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Simon J. Gerraty" Subject: git: 525d1e204bbc - main - Update dirdeps.mk List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 525d1e204bbc1779c4094384a417004591c3610f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650750264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rhGdsTCKWNtZZehMblU4BmFMDWpJ+boatZs18+pdsG8=; b=rmHgCpmfp6/iDjdcIXzwTfjHUUEvWTlB4Wg8MIhFDd7K3PCyGWXP+qIuvm3XhU1aUdV9/j CB8ScWy9aoNXzcrfgIGdAful/oLpyqLyqLdxhAeWZFTj1SJCrhWkoKfivXCbUzZe0NJkL1 RqHMoNIAQ7AfuRuMH6tZt342MTaCZREfkvfuN+pbOxgWICguLWn41u/oi/YQZRmFsUcJZm oXPBZYURS6Ys9NQ52BGz7mX7vSRIzP0JEbMIFVNPFau99KZYkbc62dkjQ+FFyxOl8HfwMh Kc7C7iD9wMrLchHxEb6NPhzPYDe1jUlwNNVDNAH6W2G4VtFflXBiisEVUd28aw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650750264; a=rsa-sha256; cv=none; b=TEaia+x73oq6gvGbtJiQUR1EUCY3lNR324XU4KWUvyRcPqKcHQRdt1uIs9ABqyLwec/4Dd QOUul7xVtLesjNsXXuV69HalnwdL6PMyxrPh1KUisy9Qbav25yhuEXDJHV6bKHeuxDB14R GAlMQp9UXOdSb0QE7yKebSn59MNnS5djQCgjVK+wg6jvxevTCnSsO0JdFJwI9X0JbBjP7t 9CjZZUe3F7qUbcnCLww+DcUM5syvyGmuCjdi96/mKzS9sR7AbYPBm1z9w9lbsfmsRN1vcQ eP8iDNA1msf/AFkvPj37iOuS/AYSCDzVAFxy3k3MoL5DFsCg4E2tpQN75jd6Wg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=525d1e204bbc1779c4094384a417004591c3610f commit 525d1e204bbc1779c4094384a417004591c3610f Author: Simon J. Gerraty AuthorDate: 2022-04-23 21:44:17 +0000 Commit: Simon J. Gerraty CommitDate: 2022-04-23 21:44:17 +0000 Update dirdeps.mk Latest dirdeps.mk is far more efficient when generating DIRDEPS_CACHE. Update dirdeps-options.mk to allow DEP_RELDIR to factor into option processing. This is not very interesting if all options are global. --- share/mk/dirdeps-options.mk | 10 +++-- share/mk/dirdeps.mk | 102 +++++++++++++++++++++++++------------------- 2 files changed, 64 insertions(+), 48 deletions(-) diff --git a/share/mk/dirdeps-options.mk b/share/mk/dirdeps-options.mk index bf5bb964ab47..b31d2033ae98 100644 --- a/share/mk/dirdeps-options.mk +++ b/share/mk/dirdeps-options.mk @@ -1,7 +1,6 @@ -# $FreeBSD$ -# $Id: dirdeps-options.mk,v 1.18 2020/12/22 18:10:34 sjg Exp $ +# $Id: dirdeps-options.mk,v 1.20 2022/03/17 20:11:36 sjg Exp $ # -# @(#) Copyright (c) 2018-2020, Simon J. Gerraty +# @(#) Copyright (c) 2018-2022, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. @@ -55,6 +54,7 @@ DIRDEPS_OPTIONS ?= # :U below avoids potential errors when we := # some options can depend on TARGET_SPEC! DIRDEPS_OPTIONS_QUALIFIER_LIST ?= \ + ${DEP_RELDIR} \ ${DEP_TARGET_SPEC:U${TARGET_SPEC}} \ ${TARGET_SPEC_VARSr:U${TARGET_SPEC_VARS}:@v@${DEP_$v:U${$v}}@} # note that we need to include $o in the variable _o$o @@ -62,7 +62,9 @@ DIRDEPS_OPTIONS_QUALIFIER_LIST ?= \ .for o in ${DIRDEPS_OPTIONS} .undef _o$o .undef _v$o -.for x in ${DIRDEPS_OPTIONS_QUALIFIER_LIST} +.for x in ${DIRDEPS_OPTIONS_QUALIFIER_LIST:S,^,${DEP_RELDIR}.,} \ + ${DIRDEPS_OPTIONS_QUALIFIER_LIST} +#.info MK_$o.$x=${MK_$o.$x:Uundefined} .if defined(MK_$o.$x) _o$o ?= MK_$o.$x _v$o ?= ${MK_$o.$x} diff --git a/share/mk/dirdeps.mk b/share/mk/dirdeps.mk index b0d4a761281e..ee31e47c76c5 100644 --- a/share/mk/dirdeps.mk +++ b/share/mk/dirdeps.mk @@ -1,7 +1,6 @@ -# $FreeBSD$ -# $Id: dirdeps.mk,v 1.147 2021/12/14 02:09:53 sjg Exp $ +# $Id: dirdeps.mk,v 1.151 2022/01/28 01:13:14 sjg Exp $ -# Copyright (c) 2010-2021, Simon J. Gerraty +# Copyright (c) 2010-2022, Simon J. Gerraty # Copyright (c) 2010-2018, Juniper Networks, Inc. # All rights reserved. # @@ -135,6 +134,16 @@ # A list of MACHINEs the current directory should not be # built for. # +# DIRDEPS_EXPORT_VARS (DEP_EXPORT_VARS) +# It is discouraged, but sometimes necessary for a +# Makefile.depend file to influence the environment. +# Doing this is correctly (especially if using DIRDEPS_CACHE) is +# tricky so a Makefile.depend file can set DIRDEPS_EXPORT_VARS +# and dirdeps.mk will do the deed: +# +# MK_UEFI = yes +# DIRDEPS_EXPORT_VARS = MK_UEFI +# # _build_xtra_dirs # local.dirdeps.mk can add targets to this variable. # They will be hooked into the build, but independent of @@ -162,6 +171,8 @@ _DIRDEP_USE_LEVEL?= 0 .if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL} # only the first instance is interested in all this +# the first time we are included the _DIRDEP_USE target will not be defined +# we can use this as a clue to do initialization and other one time things. .if !target(_DIRDEP_USE) # do some setup we only need once @@ -185,6 +196,8 @@ TARGET_MACHINE := ${MACHINE} .endif # disable DIRDEPS_CACHE as it does not like this trick MK_DIRDEPS_CACHE = no +# incase anyone needs to know +_dirdeps_cmdline: .endif # make sure we get the behavior we expect @@ -258,12 +271,36 @@ _machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:T:M*${MACHINE}*} .endif .endif - # this is how we identify non-machine specific dependfiles N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N*${MACHINE}*:${M_ListToSkip}} +# this gets reset for each dirdep we check +DEP_RELDIR ?= ${RELDIR} + +# remember the initial value of DEP_RELDIR - we test for it below. +_DEP_RELDIR := ${DEP_RELDIR} + +# this can cause lots of output! +# set to a set of glob expressions that might match RELDIR +DEBUG_DIRDEPS ?= no + +# make sure this target exists +dirdeps: beforedirdeps .WAIT +beforedirdeps: + .endif # !target(_DIRDEP_USE) +.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != "" +_debug_reldir = 1 +.else +_debug_reldir = 0 +.endif +.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend depend:L:M$x}@} != "" +_debug_search = 1 +.else +_debug_search = 0 +.endif + # First off, we want to know what ${MACHINE} to build for. # This can be complicated if we are using a mixture of ${MACHINE} specific # and non-specific Makefile.depend* @@ -298,26 +335,6 @@ DEP_MACHINE := ${_DEP_TARGET_SPEC} _build_all_dirs = _build_xtra_dirs = -# the first time we are included the _DIRDEP_USE target will not be defined -# we can use this as a clue to do initialization and other one time things. -.if !target(_DIRDEP_USE) -# make sure this target exists -dirdeps: beforedirdeps .WAIT -beforedirdeps: - -# We normally expect to be included by Makefile.depend.* -# which sets the DEP_* macros below. -DEP_RELDIR ?= ${RELDIR} - -# this can cause lots of output! -# set to a set of glob expressions that might match RELDIR -DEBUG_DIRDEPS ?= no - -# remember the initial value of DEP_RELDIR - we test for it below. -_DEP_RELDIR := ${DEP_RELDIR} - -.endif - # DIRDEPS_CACHE can be very handy for debugging. # Also if repeatedly building the same target, # we can avoid the overhead of re-computing the tree dependencies. @@ -330,16 +347,6 @@ BUILD_DIRDEPS ?= yes DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${_TARGETS:U${.TARGETS}:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.} .endif -.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != "" -_debug_reldir = 1 -.else -_debug_reldir = 0 -.endif -.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != "" -_debug_search = 1 -.else -_debug_search = 0 -.endif # pickup customizations # as below you can use !target(_DIRDEP_USE) to protect things @@ -533,7 +540,10 @@ 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} \ + @MAKELEVEL=${.MAKE.LEVEL} \ + TARGET_SPEC=${TARGET_SPEC} \ + ${TARGET_SPEC_VARS:@v@$v=${$v}@} \ + ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \ dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no # leaf makefiles rarely work for building DIRDEPS_CACHE @@ -702,15 +712,18 @@ _build_all_dirs := ${_build_all_dirs:O:u} .if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS:U}} == "" .if !empty(_build_all_dirs) .if ${BUILD_DIRDEPS_CACHE} == "yes" -x!= echo; { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; } >&3 +# we use _cache_script to minimize the number of times we fork the shell +_cache_script = echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; # guard against _new_dirdeps being too big for a single command line _new_dirdeps := ${_build_all_dirs:@x@${target($x):?:$x}@:S,^${SRCTOP}/,,} _cache_xtra_deps := ${_build_xtra_dirs:S,^${SRCTOP}/,,} .export _cache_xtra_deps _new_dirdeps -.if !empty(DEP_EXPORT_VARS) +.if !empty(DIRDEPS_EXPORT_VARS) || !empty(DEP_EXPORT_VARS) # Discouraged, but there are always exceptions. # Handle it here rather than explain how. -x!= echo; { echo; ${DEP_EXPORT_VARS:@v@echo '$v=${$v}';@} echo '.export ${DEP_EXPORT_VARS}'; echo; } >&3 +DIRDEPS_EXPORT_VARS ?= ${DEP_EXPORT_VARS} +_cache_xvars := echo; ${DIRDEPS_EXPORT_VARS:@v@echo '$v = ${$v}';@} echo '.export ${DIRDEPS_EXPORT_VARS}'; echo; +_cache_script += ${_cache_xvars} .endif .else # this makes it all happen @@ -722,16 +735,17 @@ ${_build_all_dirs}: _DIRDEP_USE .info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: needs: ${_build_dirs:S,^${SRCTOP}/,,} .endif -.if !empty(DEP_EXPORT_VARS) -.export ${DEP_EXPORT_VARS} -DEP_EXPORT_VARS= +.if !empty(DIRDEPS_EXPORT_VARS) || !empty(DEP_EXPORT_VARS) +.export ${DIRDEPS_EXPORT_VARS} ${DEP_EXPORT_VARS} +DIRDEPS_EXPORT_VARS = +DEP_EXPORT_VARS = .endif # this builds the dependency graph .for m in ${_machines} .if ${BUILD_DIRDEPS_CACHE} == "yes" && !empty(_build_dirs) _cache_deps = -x!= echo; { echo; echo 'DIRDEPS.${_this_dir}.$m = \'; } >&3 +_cache_script += echo; echo 'DIRDEPS.${_this_dir}.$m = \'; .endif # it would be nice to do :N${.TARGET} .if !empty(__qual_depdirs) @@ -754,10 +768,10 @@ ${_this_dir}.$m: ${_build_dirs:M*.$q} _cache_deps += ${_build_dirs:M*.$m:N${_this_dir}.$m:S,^${SRCTOP}/,,} .if !empty(_cache_deps) .export _cache_deps -x!= echo; for x in $$_cache_deps; do echo " _{SRCTOP}/$$x \\"; done >&3 +_cache_script += for x in $$_cache_deps; do echo " _{SRCTOP}/$$x \\"; done; .endif # anything in _{build,env}_xtra_dirs is hooked to dirdeps: only -x!= echo; { echo; echo '${_this_dir}.$m: $${DIRDEPS.${_this_dir}.$m}'; \ +x!= echo; { echo; ${_cache_script} echo; echo '${_this_dir}.$m: $${DIRDEPS.${_this_dir}.$m}'; \ echo; echo 'dirdeps: ${_this_dir}.$m \'; \ for x in $$_cache_xtra_deps; do echo " _{SRCTOP}/$$x \\"; done; \ echo; for x in $$_new_dirdeps; do echo "_{SRCTOP}/$$x: _DIRDEP_USE"; done; } >&3