pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/wrapper Added wrapper-subr.sh, which provides shell...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0c5640317e63
branches:  trunk
changeset: 521407:0c5640317e63
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Nov 11 07:44:46 2006 +0000

description:
Added wrapper-subr.sh, which provides shell functions that are useful to
make the wrapper code less frightening. For example, instead of

    arg="${arg#-Wl,}"
    $debug_log $wrapperlog "   (transform-sunpro-cc) to: $arg"
    addtocache=yes

one can simply write

    transform_to "${arg-Wl,}"

The functions that are currently implemented are: transform_to,
transform_discard, transform_to_nocache, transform_discard,
transform_pass and transform_pass_unknown.

diffstat:

 mk/wrapper/bsd.wrapper.mk  |  10 +++++++---
 mk/wrapper/wrapper-subr.sh |  41 +++++++++++++++++++++++++++++++++++++++++
 mk/wrapper/wrapper.sh      |   4 +++-
 3 files changed, 51 insertions(+), 4 deletions(-)

diffs (118 lines):

diff -r 506b04c74f97 -r 0c5640317e63 mk/wrapper/bsd.wrapper.mk
--- a/mk/wrapper/bsd.wrapper.mk Sat Nov 11 07:00:57 2006 +0000
+++ b/mk/wrapper/bsd.wrapper.mk Sat Nov 11 07:44:46 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.wrapper.mk,v 1.56 2006/11/02 23:25:00 rillig Exp $
+# $NetBSD: bsd.wrapper.mk,v 1.57 2006/11/11 07:44:46 rillig Exp $
 #
 # Copyright (c) 2005 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -184,6 +184,7 @@
 _WRAP_REORDERLIBS?=            ${WRAPPER_TMPDIR}/reorderlibs
 _WRAP_SCAN?=                   ${WRAPPER_TMPDIR}/scan
 _WRAP_SHELL_LIB?=              ${WRAPPER_TMPDIR}/shell-lib
+_WRAP_SUBR_SH?=                        ${WRAPPER_TMPDIR}/wrapper-subr.sh
 _WRAP_SKIP_TRANSFORM?=         no
 _WRAP_TRANSFORM?=              ${_WRAP_EMPTY_FILE}
 _WRAP_TRANSFORM_SED?=          # empty
@@ -349,7 +350,8 @@
        -e "s|@WRAPPER_SHELL@|${WRAPPER_SHELL:Q}|g"                     \
        -e "s|@_WRAP_LOG@|${_WRAP_LOG:Q}|g"                             \
        -e "s|@_WRAP_REORDERLIBS@|${_WRAP_REORDERLIBS:Q}|g"             \
-       -e "s|@_WRAP_SHELL_LIB@|${_WRAP_SHELL_LIB:Q}|g"
+       -e "s|@_WRAP_SHELL_LIB@|${_WRAP_SHELL_LIB:Q}|g"                 \
+       -e "s|@_WRAP_SUBR_SH@|${_WRAP_SUBR_SH}|g"
 
 .for _wrappee_ in ${_WRAPPEES}
 _WRAP_SUBST_SED.${_wrappee_}=                                          \
@@ -394,6 +396,7 @@
                ${_WRAP_REORDERLIBS}                                    \
                ${_WRAP_SCAN.${_wrappee_}}                              \
                ${_WRAP_SHELL_LIB}                                      \
+               ${_WRAP_SUBR_SH}                                        \
                ${_WRAP_TRANSFORM.${_wrappee_}}
        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
        wrapper="${WRAPPER_${_wrappee_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}"; \
@@ -481,7 +484,8 @@
        transform-mipspro-ucode-cc \
        transform-solaris-gcc \
        transform-sunpro-cc \
-       transform-xlc-cc
+       transform-xlc-cc \
+       wrapper-subr.sh
 ${WRAPPER_TMPDIR}/${w}: ${WRAPPER_SRCDIR}/${w}
        ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
        ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC}                    \
diff -r 506b04c74f97 -r 0c5640317e63 mk/wrapper/wrapper-subr.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/wrapper/wrapper-subr.sh        Sat Nov 11 07:44:46 2006 +0000
@@ -0,0 +1,41 @@
+# $NetBSD: wrapper-subr.sh,v 1.1 2006/11/11 07:44:46 rillig Exp $
+#
+# This file contains shell functions that are useful to the wrapper
+# scripts.
+#
+
+# usage: transform_setname "current-file"
+transform_setname() {
+       wrapsubr_name="$1"
+}
+
+# usage: transform_to "newarg"
+transform_to() {
+       arg="$1"
+       $debug_log $wrapperlog "   ($wrapsubr_name) to: $1"
+       addtocache=yes
+}
+
+# usage: transform_to_nocache "newarg"
+transform_to_nocache() {
+       arg="$1"
+       $debug_log $wrapperlog "   ($wrapsubr_name) to: $1"
+       addtocache=no
+}
+
+# usage: transform_discard
+transform_discard() {
+       transform_to ""
+}
+
+# usage: transform_pass
+transform_pass() {
+       addtocache=yes
+}
+
+# usage: transform_pass_unknown
+transform_pass_unknown() {
+       #echo "warning: $wrapsubr_name: unknown option $arg" 1>/dev/tty
+       addtocache=no
+}
+       
\ No newline at end of file
diff -r 506b04c74f97 -r 0c5640317e63 mk/wrapper/wrapper.sh
--- a/mk/wrapper/wrapper.sh     Sat Nov 11 07:00:57 2006 +0000
+++ b/mk/wrapper/wrapper.sh     Sat Nov 11 07:44:46 2006 +0000
@@ -1,6 +1,6 @@
 #! @WRAPPER_SHELL@
 #
-# $NetBSD: wrapper.sh,v 1.6 2006/10/21 11:42:25 rillig Exp $
+# $NetBSD: wrapper.sh,v 1.7 2006/11/11 07:44:46 rillig Exp $
 #
 # Copyright (c) 2004 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -54,6 +54,7 @@
 scan="@_WRAP_SCAN@"
 transform="@_WRAP_TRANSFORM@"
 transform_sed="@_WRAP_TRANSFORM_SED@"
+wrapper_subr_sh="@_WRAP_SUBR_SH@"
 wrapperlog="${WRAPPER_LOG-@_WRAP_LOG@}"
 skip_transform="${WRAPPER_SKIP_TRANSFORM-@_WRAP_SKIP_TRANSFORM@}"
 debug="${WRAPPER_DEBUG-@WRAPPER_DEBUG@}"
@@ -68,6 +69,7 @@
 Xsed="$sed -e 1s/^X//"
 
 . $shell_lib
+. "$wrapper_subr_sh"
 
 updatecache=${WRAPPER_UPDATE_CACHE-@WRAPPER_UPDATE_CACHE@}
 reorder=${WRAPPER_REORDER-no}



Home | Main Index | Thread Index | Old Index