CONFIG: relocate WM_PROJECT definition in bashrc, cshrc

- locate where the user is less tempted to change it (#1515).
  It really should be considered an invariant environment variable.

STYLE: wmake -help information to stdout, die errors to stderr
This commit is contained in:
Mark Olesen
2019-12-16 10:01:00 +01:00
parent 9edaf8bfa5
commit 193b7dba22
4 changed files with 33 additions and 17 deletions

View File

@ -39,11 +39,12 @@
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset # - local site-specific directory, uses WM_PROJECT_DIR/site if unset
# #
# Note # Note
# Changes made to this bashrc file may be lost with the next upgrade. # Changes made to this file will be lost with the next upgrade.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
export WM_PROJECT=OpenFOAM # [WM_PROJECT_VERSION] - A human-readable version name
# A development version is often named 'com' - as in www.openfoam.com
export WM_PROJECT_VERSION=com export WM_PROJECT_VERSION=com
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -67,7 +68,7 @@ export WM_PRECISION_OPTION=DP
# = 32 | 64 # = 32 | 64
export WM_LABEL_SIZE=32 export WM_LABEL_SIZE=32
# [WM_COMPILE_OPTION] - Optimised, debug, profiling, other: # [WM_COMPILE_OPTION] - Optimised(default), debug, profiling, other:
# = Opt | Debug | Prof # = Opt | Debug | Prof
# Other is processor or packaging specific (eg, OptKNL) # Other is processor or packaging specific (eg, OptKNL)
export WM_COMPILE_OPTION=Opt export WM_COMPILE_OPTION=Opt
@ -82,6 +83,9 @@ export WM_MPLIB=SYSTEMOPENMPI
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# (advanced / legacy) # (advanced / legacy)
# [WM_PROJECT] - This project is "OpenFOAM" - do not change
export WM_PROJECT=OpenFOAM
# [projectDir] - directory containing this OpenFOAM version. # [projectDir] - directory containing this OpenFOAM version.
# \- When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines # \- When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines
# should work when sourced by BASH or ZSH shells. If this however fails, # should work when sourced by BASH or ZSH shells. If this however fails,

View File

@ -39,11 +39,12 @@
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset # - local site-specific directory, uses WM_PROJECT_DIR/site if unset
# #
# Note # Note
# Changes made to this cshrc file may be lost with the next upgrade. # Changes made to this file will be lost with the next upgrade.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
setenv WM_PROJECT OpenFOAM # [WM_PROJECT_VERSION] - A human-readable version name
# A development version is often named 'com' - as in www.openfoam.com
setenv WM_PROJECT_VERSION com setenv WM_PROJECT_VERSION com
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -67,7 +68,7 @@ setenv WM_PRECISION_OPTION DP
# = 32 | 64 # = 32 | 64
setenv WM_LABEL_SIZE 32 setenv WM_LABEL_SIZE 32
# [WM_COMPILE_OPTION] - Optimised, debug, profiling, other: # [WM_COMPILE_OPTION] - Optimised(default), debug, profiling, other:
# = Opt | Debug | Prof # = Opt | Debug | Prof
# Other is processor or packaging specific (eg, OptKNL) # Other is processor or packaging specific (eg, OptKNL)
setenv WM_COMPILE_OPTION Opt setenv WM_COMPILE_OPTION Opt
@ -82,6 +83,9 @@ setenv WM_MPLIB SYSTEMOPENMPI
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# (advanced / legacy) # (advanced / legacy)
# [WM_PROJECT] - This project is "OpenFOAM" - do not change
setenv WM_PROJECT OpenFOAM
# [projectDir] - directory containing this OpenFOAM version. # [projectDir] - directory containing this OpenFOAM version.
# \- When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines # \- When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines
# should work when sourced by CSH or TCSH shells. If this however fails, # should work when sourced by CSH or TCSH shells. If this however fails,

View File

@ -46,7 +46,6 @@ usage() {
Usage: $Script [OPTION] [dir] Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]] $Script [OPTION] target [dir [MakeDir]]
options: options:
-a | -all Same as the 'all' target -a | -all Same as the 'all' target
-s | -silent Ignored - for compatibility with wmake -s | -silent Ignored - for compatibility with wmake

View File

@ -59,15 +59,12 @@
Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions
. "${0%/*}/scripts/wmakeFunctions" # Source wmake functions . "${0%/*}/scripts/wmakeFunctions" # Source wmake functions
unset optHelpFull # Print help to stdout so that it can be captured
usage() { printHelp() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<HELP_HEAD cat<<HELP_HEAD
Usage: $Script [OPTION] [dir] Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]] $Script [OPTION] target [dir [MakeDir]]
options: options:
-s | -silent Quiet mode (does not echo commands) -s | -silent Quiet mode (does not echo commands)
-a | -all wmake all sub-directories, running Allwmake if present -a | -all wmake all sub-directories, running Allwmake if present
@ -77,7 +74,7 @@ options:
-update Update lnInclude dirs, dep files, remove deprecated files/dirs -update Update lnInclude dirs, dep files, remove deprecated files/dirs
HELP_HEAD HELP_HEAD
if [ "$optHelpFull" = true ] if [ -n "$1" ]
then then
cat<<HELP_FULL cat<<HELP_FULL
-debug Define c++DBUG='-DFULLDEBUG -g -O0' as override -debug Define c++DBUG='-DFULLDEBUG -g -O0' as override
@ -123,6 +120,19 @@ HELP_TAIL
exit 1 exit 1
} }
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
# Default make is the "make" in the path # Default make is the "make" in the path
make="make" make="make"
@ -149,11 +159,10 @@ while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-help-f*) # Full help -help-f*) # Full help
optHelpFull=true printHelp -full
usage
;; ;;
-h | -help*) # Short help -h | -help*) # Short help
usage printHelp
;; ;;
-s | -silent) -s | -silent)
export WM_QUIET=true export WM_QUIET=true
@ -224,7 +233,7 @@ do
break break
;; ;;
-*) -*)
usage "unknown option: '$1'" die "unknown option: '$1'"
;; ;;
*) *)
break break