pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk mk: Improve makevars generation performance.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/041e0caeaf03
branches:  trunk
changeset: 388579:041e0caeaf03
user:      jperkin <jperkin%pkgsrc.org@localhost>
date:      Wed Nov 23 10:16:44 2022 +0000

description:
mk: Improve makevars generation performance.

Ironically, for something that was designed to improve performance, the way
the previous version of this worked actually made builds slower!

Use bmake loop expansions, remove useless use of cat, and reduce ${RUN}
calls to not only simplify the code but make it significantly faster.

diffstat:

 mk/bsd.pkg.mk |  31 +++++++++++--------------------
 1 files changed, 11 insertions(+), 20 deletions(-)

diffs (45 lines):

diff -r 651bdd5d688a -r 041e0caeaf03 mk/bsd.pkg.mk
--- a/mk/bsd.pkg.mk     Wed Nov 23 10:07:30 2022 +0000
+++ b/mk/bsd.pkg.mk     Wed Nov 23 10:16:44 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.pkg.mk,v 1.2042 2022/11/03 08:26:10 jperkin Exp $
+#      $NetBSD: bsd.pkg.mk,v 1.2043 2022/11/23 10:16:44 jperkin Exp $
 #
 # This file is in the public domain.
 #
@@ -812,25 +812,16 @@
 #
 .for _phase_ in ${_ALL_PHASES}
 ${_MAKEVARS_MK.${_phase_}}: ${WRKDIR}
-       ${RUN}${RM} -f ${.TARGET}.tmp
-.  for _var_ in ${MAKEVARS:O:u}
-.    if defined(${_var_})
-       ${RUN}                                  \
-       ${ECHO} ${_var_}"=      "${${_var_}:Q} >> ${.TARGET}.tmp
-.    endif
-.  endfor
-       ${RUN}                                  \
-       if ${TEST} -f ${.TARGET}.tmp; then                              \
-               ( ${ECHO} ".if !defined(_MAKEVARS_MK)";                 \
-                 ${ECHO} "_MAKEVARS_MK=        defined";               \
-                 ${ECHO} "";                                           \
-                 ${CAT} ${.TARGET}.tmp;                                \
-                 ${ECHO} "";                                           \
-                 ${ECHO} ".endif # _MAKEVARS_MK";                      \
-               ) > ${.TARGET};                                         \
-               ${RM} -f ${.TARGET}.tmp;                                \
-       fi
-       ${RUN}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
+       ${RUN} {                                                        \
+               ${ECHO} ".if !defined(_MAKEVARS_MK)";                   \
+               ${ECHO} "_MAKEVARS_MK=  defined";                       \
+               ${ECHO} "";                                             \
+               ${MAKEVARS:O:u:@_v_@                                    \
+                       ${${_v_}:D${ECHO} ${_v_}"=      "${${_v_}:Q};}  \
+               @}                                                      \
+               ${ECHO} "";                                             \
+               ${ECHO} ".endif # _MAKEVARS_MK";                        \
+       } > ${.TARGET}
 .endfor
 
 .if make(pbulk-index) || make(pbulk-index-item) || make(pbulk-save-wrkdir)



Home | Main Index | Thread Index | Old Index