Print this page
9831 bldenv should adapt to nightly debug settings


   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  25 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  26 # Copyright 2014 Garrett D'Amore <garrett@damore.org>

  27 #
  28 # Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
  29 # before spawning a shell for doing a release-style builds interactively
  30 # and incrementally.
  31 #
  32 
  33 function fatal_error
  34 {
  35         print -u2 "${progname}: $*"
  36         exit 1
  37 }
  38 
  39 function usage
  40 {
  41     OPTIND=0
  42     getopts -a "${progname}" "${USAGE}" OPT '-?'
  43     exit 2
  44 }
  45 
  46 typeset -r USAGE=$'+


  52     doing interactive and incremental builds in a workspace
  53     already built with nightly(1). bldenv spawns a shell set up
  54     with the same environment variables taken from an env_file,
  55     as prepared for use with nightly(1).]
  56 [+?In addition to running a shell for interactive use, bldenv
  57     can optionally run a single command in the given environment,
  58     in the vein of sh -c or su -c. This is useful for
  59     scripting, when an interactive shell would not be. If the
  60     command is composed of multiple shell words or contains
  61     other shell metacharacters, it must be quoted appropriately.]
  62 [+?bldenv is particularly useful for testing Makefile targets
  63     like clobber, install and _msg, which otherwise require digging
  64     through large build logs to figure out what is being
  65     done.]
  66 [+?By default, bldenv will invoke the shell specified in
  67     $SHELL. If $SHELL is not set or is invalid, csh will be
  68     used.]
  69 [c?force the use of csh, regardless of the  value  of $SHELL.]
  70 [f?invoke csh with the -f (fast-start) option. This option is valid
  71     only if $SHELL is unset or if it points to csh.]
  72 [d?set up environment for doing DEBUG builds (default is non-DEBUG)]

  73 [t?set up environment to use the tools in usr/src/tools (this is the
  74     default, use +t to use the tools from /opt/onbld)]
  75 
  76 <env_file> [command]
  77 
  78 [+EXAMPLES]{
  79     [+?Example 1: Interactive use]{
  80         [+?Use bldenv to spawn a shell to perform  a  DEBUG  build  and
  81             testing of the  Makefile  targets  clobber and install for
  82             usr/src/cmd/true.]
  83         [+\n% rlogin wopr-2 -l gk
  84 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
  85 Build type   is  DEBUG
  86 RELEASE      is  5.10
  87 VERSION      is  wopr-2::on10-se::11/01/2001
  88 RELEASE_DATE is  May 2004
  89 The top-level `setup\' target is available to build headers
  90 and tools.
  91 Using /usr/bin/tcsh as shell.
  92 {root::wopr-2::49}


 110 [+SEE ALSO?\bnightly\b(1)]
 111 '
 112 
 113 # main
 114 builtin basename
 115 
 116 # boolean flags (true/false)
 117 typeset flags=(
 118         typeset c=false
 119         typeset f=false
 120         typeset d=false
 121         typeset O=false
 122         typeset o=false
 123         typeset t=true
 124         typeset s=(
 125                 typeset e=false
 126                 typeset h=false
 127                 typeset d=false
 128                 typeset o=false
 129         )


 130 )
 131 
 132 typeset progname="$(basename -- "${0}")"
 133 
 134 OPTIND=1
 135 SUFFIX="-nd"
 136 
 137 while getopts -a "${progname}" "${USAGE}" OPT ; do 
 138     case ${OPT} in
 139           c)    flags.c=true  ;;
 140           +c)   flags.c=false ;;
 141           f)    flags.f=true  ;;
 142           +f)   flags.f=false ;;
 143           d)    flags.d=true  SUFFIX=""    ;;
 144           +d)   flags.d=false SUFFIX="-nd" ;;
 145           t)    flags.t=true  ;;
 146           +t)   flags.t=false ;;
 147           \?)   usage ;;
 148     esac
 149 done
 150 shift $((OPTIND-1))
 151 
 152 # test that the path to the environment-setting file was given
 153 if (( $# < 1 )) ; then
 154         usage
 155 fi
 156 
 157 # force locale to C
 158 export \
 159         LANG=C \
 160         LC_ALL=C \
 161         LC_COLLATE=C \
 162         LC_CTYPE=C \
 163         LC_MESSAGES=C \
 164         LC_MONETARY=C \


 218 fi
 219 shift
 220 
 221 # contents of stdenv.sh inserted after next line:
 222 # STDENV_START
 223 # STDENV_END
 224 
 225 # Check if we have sufficient data to continue...
 226 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
 227 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
 228 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
 229 
 230 # must match the getopts in nightly.sh
 231 OPTIND=1
 232 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
 233 while getopts '+0ABCDdFfGIilMmNnpRrtUuwW' FLAG $NIGHTLY_OPTIONS
 234 do
 235         case "$FLAG" in
 236           t)    flags.t=true  ;;
 237           +t)   flags.t=false ;;

 238           *)    ;;
 239         esac
 240 done
 241 







 242 POUND_SIGN="#"
 243 # have we set RELEASE_DATE in our env file?
 244 if [ -z "$RELEASE_DATE" ]; then
 245         RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
 246 fi
 247 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
 248 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
 249 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
 250 export DEV_CM RELEASE_DATE POUND_SIGN
 251 
 252 print 'Build type   is  \c'
 253 if ${flags.d} ; then
 254         print 'DEBUG'

 255         unset RELEASE_BUILD
 256         unset EXTRA_OPTIONS
 257         unset EXTRA_CFLAGS
 258 else
 259         # default is a non-DEBUG build
 260         print 'non-DEBUG'

 261         export RELEASE_BUILD=
 262         unset EXTRA_OPTIONS
 263         unset EXTRA_CFLAGS
 264 fi
 265 
 266 # update build-type variables
 267 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
 268 
 269 #       Set PATH for a build
 270 PATH="/opt/onbld/bin:/opt/onbld/bin/${MACH}:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/etc:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
 271 if [[ "${SUNWSPRO}" != "" ]]; then 
 272         export PATH="${SUNWSPRO}/bin:$PATH" 
 273 fi 
 274 
 275 if [[ -n "${MAKE}" ]]; then
 276         if [[ -x "${MAKE}" ]]; then
 277                 export PATH="$(dirname -- "${MAKE}"):$PATH"
 278         else
 279                 print "\$MAKE (${MAKE}) is not a valid executible"
 280                 exit 1  




   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  25 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  26 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
  27 # Copyright 2018 Joyent, Inc.
  28 #
  29 # Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
  30 # before spawning a shell for doing a release-style builds interactively
  31 # and incrementally.
  32 #
  33 
  34 function fatal_error
  35 {
  36         print -u2 "${progname}: $*"
  37         exit 1
  38 }
  39 
  40 function usage
  41 {
  42     OPTIND=0
  43     getopts -a "${progname}" "${USAGE}" OPT '-?'
  44     exit 2
  45 }
  46 
  47 typeset -r USAGE=$'+


  53     doing interactive and incremental builds in a workspace
  54     already built with nightly(1). bldenv spawns a shell set up
  55     with the same environment variables taken from an env_file,
  56     as prepared for use with nightly(1).]
  57 [+?In addition to running a shell for interactive use, bldenv
  58     can optionally run a single command in the given environment,
  59     in the vein of sh -c or su -c. This is useful for
  60     scripting, when an interactive shell would not be. If the
  61     command is composed of multiple shell words or contains
  62     other shell metacharacters, it must be quoted appropriately.]
  63 [+?bldenv is particularly useful for testing Makefile targets
  64     like clobber, install and _msg, which otherwise require digging
  65     through large build logs to figure out what is being
  66     done.]
  67 [+?By default, bldenv will invoke the shell specified in
  68     $SHELL. If $SHELL is not set or is invalid, csh will be
  69     used.]
  70 [c?force the use of csh, regardless of the  value  of $SHELL.]
  71 [f?invoke csh with the -f (fast-start) option. This option is valid
  72     only if $SHELL is unset or if it points to csh.]
  73 [d?set up environment for doing DEBUG builds. The default is non-DEBUG,
  74     unless the -F flag is specified in the nightly file.]
  75 [t?set up environment to use the tools in usr/src/tools (this is the
  76     default, use +t to use the tools from /opt/onbld)]
  77 
  78 <env_file> [command]
  79 
  80 [+EXAMPLES]{
  81     [+?Example 1: Interactive use]{
  82         [+?Use bldenv to spawn a shell to perform  a  DEBUG  build  and
  83             testing of the  Makefile  targets  clobber and install for
  84             usr/src/cmd/true.]
  85         [+\n% rlogin wopr-2 -l gk
  86 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
  87 Build type   is  DEBUG
  88 RELEASE      is  5.10
  89 VERSION      is  wopr-2::on10-se::11/01/2001
  90 RELEASE_DATE is  May 2004
  91 The top-level `setup\' target is available to build headers
  92 and tools.
  93 Using /usr/bin/tcsh as shell.
  94 {root::wopr-2::49}


 112 [+SEE ALSO?\bnightly\b(1)]
 113 '
 114 
 115 # main
 116 builtin basename
 117 
 118 # boolean flags (true/false)
 119 typeset flags=(
 120         typeset c=false
 121         typeset f=false
 122         typeset d=false
 123         typeset O=false
 124         typeset o=false
 125         typeset t=true
 126         typeset s=(
 127                 typeset e=false
 128                 typeset h=false
 129                 typeset d=false
 130                 typeset o=false
 131         )
 132         typeset d_set=false
 133         typeset DF_build=false
 134 )
 135 
 136 typeset progname="$(basename -- "${0}")"
 137 
 138 OPTIND=1

 139 
 140 while getopts -a "${progname}" "${USAGE}" OPT ; do
 141     case ${OPT} in
 142           c)    flags.c=true  ;;
 143           +c)   flags.c=false ;;
 144           f)    flags.f=true  ;;
 145           +f)   flags.f=false ;;
 146           d)    flags.d=true ; flags.d_set=true ;;
 147           +d)   flags.d=false ; flags.d_set=true ;;
 148           t)    flags.t=true  ;;
 149           +t)   flags.t=false ;;
 150           \?)   usage ;;
 151     esac
 152 done
 153 shift $((OPTIND-1))
 154 
 155 # test that the path to the environment-setting file was given
 156 if (( $# < 1 )) ; then
 157         usage
 158 fi
 159 
 160 # force locale to C
 161 export \
 162         LANG=C \
 163         LC_ALL=C \
 164         LC_COLLATE=C \
 165         LC_CTYPE=C \
 166         LC_MESSAGES=C \
 167         LC_MONETARY=C \


 221 fi
 222 shift
 223 
 224 # contents of stdenv.sh inserted after next line:
 225 # STDENV_START
 226 # STDENV_END
 227 
 228 # Check if we have sufficient data to continue...
 229 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
 230 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
 231 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
 232 
 233 # must match the getopts in nightly.sh
 234 OPTIND=1
 235 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
 236 while getopts '+0ABCDdFfGIilMmNnpRrtUuwW' FLAG $NIGHTLY_OPTIONS
 237 do
 238         case "$FLAG" in
 239           t)    flags.t=true  ;;
 240           +t)   flags.t=false ;;
 241           F)    flags.DF_build=true ;;
 242           *)    ;;
 243         esac
 244 done
 245 
 246 # DEBUG is a little bit complicated.  First, bldenv -d/+d over-rides
 247 # the env file.  Otherwise, we'll default to DEBUG iff we are *not*
 248 # building non-DEBUG bits at all.
 249 if [ "${flags.d_set}" != "true" ] && "${flags.DF_build}"; then
 250         flags.d=true
 251 fi
 252 
 253 POUND_SIGN="#"
 254 # have we set RELEASE_DATE in our env file?
 255 if [ -z "$RELEASE_DATE" ]; then
 256         RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
 257 fi
 258 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
 259 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
 260 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
 261 export DEV_CM RELEASE_DATE POUND_SIGN
 262 
 263 print 'Build type   is  \c'
 264 if ${flags.d} ; then
 265         print 'DEBUG'
 266         SUFFIX=""
 267         unset RELEASE_BUILD
 268         unset EXTRA_OPTIONS
 269         unset EXTRA_CFLAGS
 270 else
 271         # default is a non-DEBUG build
 272         print 'non-DEBUG'
 273         SUFFIX="-nd"
 274         export RELEASE_BUILD=
 275         unset EXTRA_OPTIONS
 276         unset EXTRA_CFLAGS
 277 fi
 278 
 279 # update build-type variables
 280 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
 281 
 282 #       Set PATH for a build
 283 PATH="/opt/onbld/bin:/opt/onbld/bin/${MACH}:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/etc:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
 284 if [[ "${SUNWSPRO}" != "" ]]; then
 285         export PATH="${SUNWSPRO}/bin:$PATH"
 286 fi
 287 
 288 if [[ -n "${MAKE}" ]]; then
 289         if [[ -x "${MAKE}" ]]; then
 290                 export PATH="$(dirname -- "${MAKE}"):$PATH"
 291         else
 292                 print "\$MAKE (${MAKE}) is not a valid executible"
 293                 exit 1