Print this page
9831 bldenv should adapt to nightly debug settings
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/bldenv.sh
+++ new/usr/src/tools/scripts/bldenv.sh
1 1 #!/usr/bin/ksh93
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 26 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
27 +# Copyright 2018 Joyent, Inc.
27 28 #
28 29 # Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
29 30 # before spawning a shell for doing a release-style builds interactively
30 31 # and incrementally.
31 32 #
32 33
33 34 function fatal_error
34 35 {
35 36 print -u2 "${progname}: $*"
36 37 exit 1
37 38 }
38 39
39 40 function usage
40 41 {
41 42 OPTIND=0
42 43 getopts -a "${progname}" "${USAGE}" OPT '-?'
43 44 exit 2
44 45 }
45 46
46 47 typeset -r USAGE=$'+
47 48 [-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
48 49 [-author?OS/Net community <tools-discuss@opensolaris.org>]
49 50 [+NAME?bldenv - spawn shell for interactive incremental OS-Net
50 51 consolidation builds]
51 52 [+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
52 53 doing interactive and incremental builds in a workspace
53 54 already built with nightly(1). bldenv spawns a shell set up
54 55 with the same environment variables taken from an env_file,
55 56 as prepared for use with nightly(1).]
56 57 [+?In addition to running a shell for interactive use, bldenv
57 58 can optionally run a single command in the given environment,
58 59 in the vein of sh -c or su -c. This is useful for
59 60 scripting, when an interactive shell would not be. If the
60 61 command is composed of multiple shell words or contains
61 62 other shell metacharacters, it must be quoted appropriately.]
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
62 63 [+?bldenv is particularly useful for testing Makefile targets
63 64 like clobber, install and _msg, which otherwise require digging
64 65 through large build logs to figure out what is being
65 66 done.]
66 67 [+?By default, bldenv will invoke the shell specified in
67 68 $SHELL. If $SHELL is not set or is invalid, csh will be
68 69 used.]
69 70 [c?force the use of csh, regardless of the value of $SHELL.]
70 71 [f?invoke csh with the -f (fast-start) option. This option is valid
71 72 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 +[d?set up environment for doing DEBUG builds. The default is non-DEBUG,
74 + unless the -F flag is specified in the nightly file.]
73 75 [t?set up environment to use the tools in usr/src/tools (this is the
74 76 default, use +t to use the tools from /opt/onbld)]
75 77
76 78 <env_file> [command]
77 79
78 80 [+EXAMPLES]{
79 81 [+?Example 1: Interactive use]{
80 82 [+?Use bldenv to spawn a shell to perform a DEBUG build and
81 83 testing of the Makefile targets clobber and install for
82 84 usr/src/cmd/true.]
83 85 [+\n% rlogin wopr-2 -l gk
84 86 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
85 87 Build type is DEBUG
86 88 RELEASE is 5.10
87 89 VERSION is wopr-2::on10-se::11/01/2001
88 90 RELEASE_DATE is May 2004
89 91 The top-level `setup\' target is available to build headers
90 92 and tools.
91 93 Using /usr/bin/tcsh as shell.
92 94 {root::wopr-2::49}
93 95 {root::wopr-2::49} cd $SRC/cmd/true
94 96 {root::wopr-2::50} make
95 97 {root::wopr-2::51} make clobber
96 98 /usr/bin/rm -f true true.po
97 99 {root::wopr-2::52} make
98 100 /usr/bin/rm -f true
99 101 cat true.sh > true
100 102 chmod +x true
101 103 {root::wopr-2::53} make install
102 104 install -s -m 0555 -u root -g bin -f /export0/jg/on10-se/proto/root_sparc/usr/bin true
103 105 `install\' is up to date.]
104 106 }
105 107 [+?Example 2: Non-interactive use]{
106 108 [+?Invoke bldenv to create SUNWonbld with a single command:]
107 109 [+\nexample% bldenv onnv_06 \'cd $SRC/tools && make pkg\']
108 110 }
109 111 }
110 112 [+SEE ALSO?\bnightly\b(1)]
111 113 '
112 114
113 115 # main
114 116 builtin basename
115 117
116 118 # boolean flags (true/false)
117 119 typeset flags=(
118 120 typeset c=false
119 121 typeset f=false
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
120 122 typeset d=false
121 123 typeset O=false
122 124 typeset o=false
123 125 typeset t=true
124 126 typeset s=(
125 127 typeset e=false
126 128 typeset h=false
127 129 typeset d=false
128 130 typeset o=false
129 131 )
132 + typeset d_set=false
133 + typeset DF_build=false
130 134 )
131 135
132 136 typeset progname="$(basename -- "${0}")"
133 137
134 138 OPTIND=1
135 -SUFFIX="-nd"
136 139
137 -while getopts -a "${progname}" "${USAGE}" OPT ; do
140 +while getopts -a "${progname}" "${USAGE}" OPT ; do
138 141 case ${OPT} in
139 142 c) flags.c=true ;;
140 143 +c) flags.c=false ;;
141 144 f) flags.f=true ;;
142 145 +f) flags.f=false ;;
143 - d) flags.d=true SUFFIX="" ;;
144 - +d) flags.d=false SUFFIX="-nd" ;;
146 + d) flags.d=true ; flags.d_set=true ;;
147 + +d) flags.d=false ; flags.d_set=true ;;
145 148 t) flags.t=true ;;
146 149 +t) flags.t=false ;;
147 150 \?) usage ;;
148 151 esac
149 152 done
150 153 shift $((OPTIND-1))
151 154
152 155 # test that the path to the environment-setting file was given
153 156 if (( $# < 1 )) ; then
154 157 usage
155 158 fi
156 159
157 160 # force locale to C
158 161 export \
159 162 LANG=C \
160 163 LC_ALL=C \
161 164 LC_COLLATE=C \
162 165 LC_CTYPE=C \
163 166 LC_MESSAGES=C \
164 167 LC_MONETARY=C \
165 168 LC_NUMERIC=C \
166 169 LC_TIME=C
167 170
168 171 # clear environment variables we know to be bad for the build
169 172 unset \
170 173 LD_OPTIONS \
171 174 LD_LIBRARY_PATH \
172 175 LD_AUDIT \
173 176 LD_BIND_NOW \
174 177 LD_BREADTH \
175 178 LD_CONFIG \
176 179 LD_DEBUG \
177 180 LD_FLAGS \
178 181 LD_LIBRARY_PATH_64 \
179 182 LD_NOVERSION \
180 183 LD_ORIGIN \
181 184 LD_LOADFLTR \
182 185 LD_NOAUXFLTR \
183 186 LD_NOCONFIG \
184 187 LD_NODIRCONFIG \
185 188 LD_NOOBJALTER \
186 189 LD_PRELOAD \
187 190 LD_PROFILE \
188 191 CONFIG \
189 192 GROUP \
190 193 OWNER \
191 194 REMOTE \
192 195 ENV \
193 196 ARCH \
194 197 CLASSPATH
195 198
196 199 #
197 200 # Setup environment variables
198 201 #
199 202 if [[ -f /etc/nightly.conf ]]; then
200 203 source /etc/nightly.conf
201 204 fi
202 205
203 206 if [[ -f "$1" ]]; then
204 207 if [[ "$1" == */* ]]; then
205 208 source "$1"
206 209 else
207 210 source "./$1"
208 211 fi
209 212 else
210 213 if [[ -f "/opt/onbld/env/$1" ]]; then
211 214 source "/opt/onbld/env/$1"
212 215 else
213 216 printf \
214 217 'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
215 218 "$1" "$1"
216 219 exit 1
217 220 fi
218 221 fi
219 222 shift
220 223
221 224 # contents of stdenv.sh inserted after next line:
222 225 # STDENV_START
223 226 # STDENV_END
224 227
225 228 # Check if we have sufficient data to continue...
226 229 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
227 230 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
228 231 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
229 232
230 233 # must match the getopts in nightly.sh
231 234 OPTIND=1
232 235 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
233 236 while getopts '+0ABCDdFfGIilMmNnpRrtUuwW' FLAG $NIGHTLY_OPTIONS
234 237 do
235 238 case "$FLAG" in
236 239 t) flags.t=true ;;
237 240 +t) flags.t=false ;;
241 + F) flags.DF_build=true ;;
238 242 *) ;;
239 243 esac
240 244 done
241 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 +
242 253 POUND_SIGN="#"
243 254 # have we set RELEASE_DATE in our env file?
244 255 if [ -z "$RELEASE_DATE" ]; then
245 256 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
246 257 fi
247 258 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
248 259 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
249 260 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
250 261 export DEV_CM RELEASE_DATE POUND_SIGN
251 262
252 263 print 'Build type is \c'
253 264 if ${flags.d} ; then
254 265 print 'DEBUG'
266 + SUFFIX=""
255 267 unset RELEASE_BUILD
256 268 unset EXTRA_OPTIONS
257 269 unset EXTRA_CFLAGS
258 270 else
259 271 # default is a non-DEBUG build
260 272 print 'non-DEBUG'
273 + SUFFIX="-nd"
261 274 export RELEASE_BUILD=
262 275 unset EXTRA_OPTIONS
263 276 unset EXTRA_CFLAGS
264 277 fi
265 278
266 279 # update build-type variables
267 280 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
268 281
269 -# Set PATH for a build
282 +# Set PATH for a build
270 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:."
271 -if [[ "${SUNWSPRO}" != "" ]]; then
272 - export PATH="${SUNWSPRO}/bin:$PATH"
273 -fi
284 +if [[ "${SUNWSPRO}" != "" ]]; then
285 + export PATH="${SUNWSPRO}/bin:$PATH"
286 +fi
274 287
275 288 if [[ -n "${MAKE}" ]]; then
276 289 if [[ -x "${MAKE}" ]]; then
277 290 export PATH="$(dirname -- "${MAKE}"):$PATH"
278 291 else
279 292 print "\$MAKE (${MAKE}) is not a valid executible"
280 - exit 1
293 + exit 1
281 294 fi
282 295 fi
283 296
284 297 TOOLS="${SRC}/tools"
285 298 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
286 299
287 300 if "${flags.t}" ; then
288 301 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
289 302
290 303 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
291 304 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
292 305 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
293 306
294 307 export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
295 308 export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
296 309 export NDRGEN="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ndrgen"
297 310
298 311 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
299 312 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
300 313 export PATH
301 314 fi
302 315
303 316 export DMAKE_MODE=${DMAKE_MODE:-parallel}
304 317
305 318 #
306 319 # Work around folks who have historically used GCC_ROOT and convert it to
307 320 # GNUC_ROOT. We leave GCC_ROOT in the environment for now (though this could
308 321 # mess up the case where multiple different gcc versions are being used to
309 322 # shadow).
310 323 #
311 324 if [[ -n "${GCC_ROOT}" ]]; then
312 325 export GNUC_ROOT=${GCC_ROOT}
313 326 fi
314 327
315 328 DEF_STRIPFLAG="-s"
316 329
317 330 TMPDIR="/tmp"
318 331
319 332 export \
320 333 PATH TMPDIR \
321 334 POUND_SIGN \
322 335 DEF_STRIPFLAG \
323 336 RELEASE_DATE
324 337 unset \
325 338 CFLAGS \
326 339 LD_LIBRARY_PATH
327 340
328 341 # a la ws
329 342 ENVLDLIBS1=
330 343 ENVLDLIBS2=
331 344 ENVLDLIBS3=
332 345 ENVCPPFLAGS1=
333 346 ENVCPPFLAGS2=
334 347 ENVCPPFLAGS3=
335 348 ENVCPPFLAGS4=
336 349 PARENT_ROOT=
337 350 PARENT_TOOLS_ROOT=
338 351
339 352 if [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
340 353 printf \
341 354 'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
342 355 "$MULTI_PROTO"
343 356 export MULTI_PROTO="no"
344 357 fi
345 358
346 359 [[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
347 360
348 361 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
349 362 ENVCPPFLAGS1="-I$ROOT/usr/include"
350 363 MAKEFLAGS=e
351 364
352 365 export \
353 366 ENVLDLIBS1 \
354 367 ENVLDLIBS2 \
355 368 ENVLDLIBS3 \
356 369 ENVCPPFLAGS1 \
357 370 ENVCPPFLAGS2 \
358 371 ENVCPPFLAGS3 \
359 372 ENVCPPFLAGS4 \
360 373 MAKEFLAGS \
361 374 PARENT_ROOT \
362 375 PARENT_TOOLS_ROOT
363 376
364 377 printf 'RELEASE is %s\n' "$RELEASE"
365 378 printf 'VERSION is %s\n' "$VERSION"
366 379 printf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
367 380
368 381 if [[ -f "$SRC/Makefile" ]] && egrep -s '^setup:' "$SRC/Makefile" ; then
369 382 print "The top-level 'setup' target is available \c"
370 383 print "to build headers and tools."
371 384 print ""
372 385
373 386 elif "${flags.t}" ; then
374 387 printf \
375 388 'The tools can be (re)built with the install target in %s.\n\n' \
376 389 "${TOOLS}"
377 390 fi
378 391
379 392 #
380 393 # place ourselves in a new task, respecting BUILD_PROJECT if set.
381 394 #
382 395 /usr/bin/newtask -c $$ ${BUILD_PROJECT:+-p$BUILD_PROJECT}
383 396
384 397 if [[ "${flags.c}" == "false" && -x "$SHELL" && \
385 398 "$(basename -- "${SHELL}")" != "csh" ]]; then
386 399 # $SHELL is set, and it's not csh.
387 400
388 401 if "${flags.f}" ; then
389 402 print 'WARNING: -f is ignored when $SHELL is not csh'
390 403 fi
391 404
392 405 printf 'Using %s as shell.\n' "$SHELL"
393 406 exec "$SHELL" ${@:+-c "$@"}
394 407
395 408 elif "${flags.f}" ; then
396 409 print 'Using csh -f as shell.'
397 410 exec csh -f ${@:+-c "$@"}
398 411
399 412 else
400 413 print 'Using csh as shell.'
401 414 exec csh ${@:+-c "$@"}
402 415 fi
403 416
404 417 # not reached
↓ open down ↓ |
114 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX