pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/buildlink3 mk: buildlink3 performance improvements.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/9514e3a438a1
branches:  trunk
changeset: 388592:9514e3a438a1
user:      jperkin <jperkin%pkgsrc.org@localhost>
date:      Wed Nov 23 11:04:42 2022 +0000

description:
mk: buildlink3 performance improvements.

Inline commands into the same ${RUN} where appropriate.  Use a single mkdir
for multiple directories rather than a command per directory.  Test for the
directory before calling mkdir where it may already exist to avoid an
unnecessary exec. Remove useless use of cat(1).

Saves around 20 execs per build.

diffstat:

 mk/buildlink3/bsd.buildlink3.mk |  55 ++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 27 deletions(-)

diffs (119 lines):

diff -r 20616b4a2f0a -r 9514e3a438a1 mk/buildlink3/bsd.buildlink3.mk
--- a/mk/buildlink3/bsd.buildlink3.mk   Wed Nov 23 11:00:04 2022 +0000
+++ b/mk/buildlink3/bsd.buildlink3.mk   Wed Nov 23 11:04:42 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.buildlink3.mk,v 1.251 2022/11/23 10:57:59 jperkin Exp $
+# $NetBSD: bsd.buildlink3.mk,v 1.252 2022/11/23 11:04:42 jperkin Exp $
 #
 # Copyright (c) 2004 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -575,14 +575,14 @@
 .PHONY: buildlink-directories
 do-buildlink: buildlink-directories
 buildlink-directories:
-       ${RUN}${MKDIR} ${BUILDLINK_DIR}
-       ${RUN}${MKDIR} ${BUILDLINK_BINDIR}
+       ${RUN}                                                          \
+       ${MKDIR} ${BUILDLINK_DIR} ${BUILDLINK_BINDIR}                   \
+                ${BUILDLINK_DIR}/include ${BUILDLINK_DIR}/lib
 .if defined(USE_X11) && ${X11_TYPE} != "modular"
-       ${RUN}${RM} -f ${BUILDLINK_X11_DIR}
-       ${RUN}${LN} -sf ${BUILDLINK_DIR} ${BUILDLINK_X11_DIR}
+       ${RUN}                                                          \
+       ${RM} -f ${BUILDLINK_X11_DIR};                                  \
+       ${LN} -sf ${BUILDLINK_DIR} ${BUILDLINK_X11_DIR}
 .endif
-       ${RUN}${MKDIR} ${BUILDLINK_DIR}/include
-       ${RUN}${MKDIR} ${BUILDLINK_DIR}/lib
 
 # The following variables are all optionally defined and control which
 # package files are symlinked into ${BUILDLINK_DIR} and how their names
@@ -627,8 +627,7 @@
 
 .PHONY: buildlink-${_pkg_}-cookie
 buildlink-${_pkg_}-cookie:
-       ${RUN}                                  \
-       ${TOUCH} ${TOUCH_FLAGS} ${_BLNK_COOKIE.${_pkg_}}
+       ${RUN} ${TOUCH} ${TOUCH_FLAGS} ${_BLNK_COOKIE.${_pkg_}}
 
 BUILDLINK_CONTENTS_FILTER.${_pkg_}?=                                   \
        ${EGREP} '(include.*/|\.h$$|\.idl$$|\.pc$$|/lib[^/]*\.[^/]*$$|lib/cmake/|share/cmake/)'
@@ -636,7 +635,7 @@
 BUILDLINK_FILES_CMD.${_pkg_}?=                                         \
        ${_BLNK_PKG_INFO.${_pkg_}} -f ${BUILDLINK_PKGNAME.${_pkg_}} |   \
        ${SED} -n '/File:/s/^[  ]*File:[        ]*//p' |                \
-       ${BUILDLINK_CONTENTS_FILTER.${_pkg_}} | ${CAT}
+       ${BUILDLINK_CONTENTS_FILTER.${_pkg_}}
 
 # _BLNK_FILES_CMD.<pkg> combines BUILDLINK_FILES_CMD.<pkg> and
 # BUILDLINK_FILES.<pkg> into one command that outputs all of the files
@@ -657,8 +656,8 @@
                ${ERROR_MSG} "${BUILDLINK_API_DEPENDS.${_pkg_}} is not installed; can't buildlink files."; \
                exit 1;                                                 \
                ;;                                                      \
-       esac
-       ${RUN} [ ${X11BASE:Q}"" ] || {                                  \
+       esac;                                                           \
+       [ ${X11BASE:Q}"" ] || {                                         \
                ${ERROR_MSG} "[bsd.buildlink3.mk] X11BASE is not set correctly."; \
                exit 1;                                                 \
        }
@@ -1175,8 +1174,9 @@
 _WRAP_EXTRA_ARGS.SHLIBTOOL+=   ${_BLNK_LDFLAGS}
 
 ${WRAPPER_TMPDIR}/libtool-fix-la: ${BUILDLINK_SRCDIR}/libtool-fix-la
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${CAT} ${.ALLSRC}                 \
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${CAT} ${.ALLSRC}                                               \
                | ${SED} -e "s|@_BLNK_WRAP_LT_UNTRANSFORM_SED@|"${_BLNK_WRAP_LT_UNTRANSFORM_SED:Q}"|g" \
                         -e "s|@BUILDLINK_DIR@|${BUILDLINK_DIR}|g"      \
                         -e "s|@LOCALBASE@|${LOCALBASE}|g"              \
@@ -1190,32 +1190,33 @@
                | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
 
 ${WRAPPER_TMPDIR}/buildcmd-libtool: ${BUILDLINK_SRCDIR}/buildcmd-libtool
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${CAT} ${.ALLSRC}                 \
-               | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${CAT} ${.ALLSRC} | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
 
 ${WRAPPER_TMPDIR}/cleanup-libtool:                                     \
                ${BUILDLINK_SRCDIR}/cleanup-libtool                     \
                ${_BLNK_LIBTOOL_FIX_LA}
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}                                  \
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
        ${CAT} ${BUILDLINK_SRCDIR}/cleanup-libtool                      \
                | ${SED} -e "s|@_BLNK_LIBTOOL_FIX_LA@|"${_BLNK_LIBTOOL_FIX_LA:Q}"|g" \
                | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
 
 ${WRAPPER_TMPDIR}/cmd-sink-libtool: ${BUILDLINK_SRCDIR}/cmd-sink-libtool
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${CAT} ${.ALLSRC}                 \
-               | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${CAT} ${.ALLSRC} | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
 
 ${WRAPPER_TMPDIR}/scan-libtool: ${BUILDLINK_SRCDIR}/scan-libtool
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${CAT} ${.ALLSRC}                 \
-               | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${CAT} ${.ALLSRC} | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
 
 ${WRAPPER_TMPDIR}/transform-libtool: ${BUILDLINK_SRCDIR}/transform-libtool
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${CAT} ${.ALLSRC}                 \
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${CAT} ${.ALLSRC}                                               \
                | ${SED} -e "s|@BUILDLINK_DIR@|${BUILDLINK_DIR}|g"      \
                         -e "s|@WRKSRC@|${WRKSRC}|g"                    \
                         -e "s|@BASENAME@|"${BASENAME:Q}"|g"            \



Home | Main Index | Thread Index | Old Index