Scripts in wmake: cleaned up options and -help

This commit is contained in:
Chris Greenshields 2017-05-31 16:54:49 +01:00
parent 8d2e5ecae8
commit 853fa4d5d3
13 changed files with 147 additions and 94 deletions

View file

@ -39,15 +39,20 @@ Script=${0##*/}
# Source the wmake functions
. ${0%/*}/scripts/wmakeFunctions
usage() {
error() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
usage() {
cat<<USAGE
Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]]
options:
-s | -silent Ignored - for compatibility with wmake
-silent | -s Ignored - for compatibility with wmake
-help Print the usage
Clean up the wmake control directory Make/\$WM_OPTIONS and remove the
@ -64,7 +69,6 @@ The targets correspond to a subset of the 'wmake' special targets:
that refer to no-longer-existing source code.
USAGE
exit 1
}
@ -76,13 +80,13 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
usage && exit 0
;;
-s | -silent) # Ignored - for compatibility with wmake
shift
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -277,7 +281,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage MakeDir
unset Script usage error MakeDir
#------------------------------------------------------------------------------

View file

@ -52,7 +52,7 @@ then
echo
echo " Delete all the lnInclude directories in the tree"
echo
exit 1
exit 0
fi

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -48,9 +48,14 @@
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
usage() {
cat<<USAGE
Usage: $Script [ -current | -all ]
$Script <platform> [ ... <platformN> ]
@ -67,7 +72,6 @@ Usage: $Script [ -current | -all ]
are deleted.
USAGE
exit 1
}
# Print help message
@ -77,7 +81,7 @@ fi
# Check the script is executed from the project top-level directory
[ "$PWD" = "$WM_PROJECT_DIR" ] || \
usage "Not in the project top-level directory " $WM_PROJECT_DIR
error "Not in the project top-level directory " $WM_PROJECT_DIR
# Get the platforms from the arguments
platforms="$@"
@ -121,7 +125,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script platforms
unset Script platforms error usage
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -41,19 +41,24 @@ Script=${0##*/}
. ${0%/*}/scripts/wmakeFunctions
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script <file>
options:
-help Print the usage
Find the dep-file corresponding to <file> in the current directory
and print the path.
USAGE
exit 1
}
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
@ -63,10 +68,10 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
usage && exit 0
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -112,7 +117,7 @@ echo $objectsDir/$fileName.dep
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage error
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -58,25 +58,30 @@ Script=${0##*/}
# Source the wmake functions
. ${0%/*}/scripts/wmakeFunctions
usage() {
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
usage() {
cat<<USAGE
Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]]
options:
-s | -silent Quiet mode (does not echo commands)
-a | -all wmake all sub-directories, running Allwmake if present
-q | -queue wmakeCollect all sub-directories, running Allwmake if present
-k or -non-stop Compile without stopping when errors occur
-silent | -s Quiet mode (does not echo commands)
-all | -a wmake all sub-directories, running Allwmake if present
-queue | -q wmakeCollect all sub-directories, running Allwmake if present
-non-stop | -k Compile without stopping when errors occur
-j Compile using all local cores/hyperthreads
-jN or -j N Compile using N cores/hyperthreads
-j <N> | -j<N> Compile using N cores/hyperthreads
-no-scheduler Compile without wmakeScheduler
-update Update lnInclude directories, dep files, remove deprecated
files and directories
-h | -help Print the usage
-help | -h Print the usage
A general, easy-to-use make system for multi-platform development
@ -97,7 +102,6 @@ or a special target:
objects Compile but not link
USAGE
exit 1
}
@ -135,7 +139,7 @@ do
case "$1" in
# Print help
-h | -help)
usage
usage && exit 0
;;
-s | -silent)
export WM_QUIET=1
@ -181,7 +185,7 @@ do
break
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -470,7 +474,7 @@ exec $make -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage useAllCores update expandPath findTarget
unset Script usage error useAllCores update expandPath findTarget
#------------------------------------------------------------------------------

View file

@ -37,15 +37,13 @@ Script=${0##*/}
unset quietOpt
usage() {
[ "$quietOpt" = true ] && exit 1
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] dirName
options:
-q | -quiet suppress all normal output
-quiet | -q suppress all normal output
-help | -h print the usage
Check that the current working directory is the directory <dir>
@ -53,6 +51,13 @@ options:
Exit status 1 on error
USAGE
}
error() {
[ "$quietOpt" = true ] && exit 1
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
@ -65,14 +70,14 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
usage && exit 0
;;
-q | -quiet)
quietOpt=true
shift
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -81,7 +86,7 @@ do
done
[ "$#" -eq 1 ] || usage
[ "$#" -eq 1 ] || error
# Set dirName to <dir>
dirName="$1"
@ -115,7 +120,7 @@ exit 1
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage error
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -35,8 +35,6 @@
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] <command>
@ -44,7 +42,7 @@ Usage: $Script [OPTION] <command>
options:
-clean Clean-up before compilation (removes old makefiles)
-kill Clean-up after termination (removes makefiles)
-h | -help Print the usage
-help | -h Print the usage
Collecting scheduler for fast parallel compilation of large numbers of object
files. Can be used in compiling OpenFOAM by setting the WM_SCHEDULER variable.
@ -65,6 +63,12 @@ Typical usage for compiling OpenFOAM:
wmake -queue or wmake -q
USAGE
}
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
@ -75,14 +79,14 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
usage && exit 0
;;
-kill | -clean)
cleanup="true"
shift
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
break
;;
*)
@ -166,7 +170,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage error
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -36,18 +36,23 @@
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script
options:
-help | -h Print the usage
Scan current directory for directories and source files
and construct 'Make/files' and 'Make/options'
USAGE
exit 1
}
error() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
@ -57,10 +62,10 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help) # Provide immediate help
usage
usage && exit 0
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -69,7 +74,7 @@ do
done
# No arguments
[ "$#" -eq 0 ] || usage "unexpected arguments: '$*'"
[ "$#" -eq 0 ] || error "unexpected arguments: '$*'"
#------------------------------------------------------------------------------
@ -106,7 +111,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage error
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -41,16 +41,14 @@
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] dir
options:
-u | -update update
-s | -silent use 'silent' mode (do not echo command)
-help print the usage
-update | -u update
-silent | -s use 'silent' mode (do not echo command)
-help | -h print the usage
Link all the source files in the <dir> into <dir>/lnInclude
@ -59,9 +57,14 @@ Note
and changes the default linking from 'ln -s' to 'ln -sf'.
USAGE
exit 1
}
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
@ -79,7 +82,7 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help) # Provide immediate help
usage
usage && exit 0
;;
-u | -update)
update=true
@ -91,7 +94,7 @@ do
shift
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -103,7 +106,7 @@ if [ $# -eq 1 ]
then
baseDir=$1
else
usage "Error: incorrect number of arguments"
error "Error: incorrect number of arguments"
fi
@ -172,7 +175,7 @@ find .. $findOpt \
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage error
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -36,20 +36,24 @@
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] [dir1 .. dirN]
options:
-j Compile using all local cores/hyperthreads
-jN or -j N Compile using N cores/hyperthreads
-h | -help Print the usage
-j <N> | -j<N> Compile using N cores/hyperthreads
-help | -h Print the usage
Find directories with a 'Make/files' that contains a 'LIB =' directive
and execute 'wmakeLnInclude -update' for each one
USAGE
}
error() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
@ -68,7 +72,7 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help) # Provide immediate help
usage
usage && exit 0
;;
-u | -update)
wmLnOpt="-update"
@ -84,7 +88,7 @@ do
nCores=${1#-j}
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -164,7 +168,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage error
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -35,19 +35,17 @@
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION]
options:
-check check the git head commit vs. \$WM_PROJECT_DIR/.build
(exit code 0 for no changes)
-help print the usage
-major report \$WM_PROJECT_VERSION only and exit
-update update \$WM_PROJECT_DIR/.build from the git information
-pkg TAG specify packager/release tag ('none' marks an empty packager)
-pkg <TAG> specify packager/release tag ('none' marks an empty packager)
-short report short version information (ie, without pkg tag)
-version VER specify an alternative version
-version <VER> specify an alternative version
Print the version used when building the project, in this order of precedence:
* the git head commit (prefixed with \$WM_PROJECT_VERSION)
@ -55,9 +53,14 @@ Print the version used when building the project, in this order of precedence:
* \$WM_PROJECT_VERSION
USAGE
exit 1
}
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
@ -68,7 +71,7 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
usage && exit 0
;;
-c | -check)
checkOnly=true
@ -83,7 +86,7 @@ do
shift
;;
-pkg | -package)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || error "'$1' option requires an argument"
# Mark empty as 'none', disallow '!' in string
package=$(echo "${2:-none}" | sed -e 's/!//g')
shift 2
@ -93,12 +96,12 @@ do
shift
;;
-v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || error "'$1' option requires an argument"
version="$2"
shift 2
;;
*)
usage "unknown option/argument: '$*'"
error "unknown option/argument: '$*'"
;;
esac
done

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -84,9 +84,14 @@ Usage:
Must be executed in the project top-level directory: $WM_PROJECT_DIR
USAGE
exit 1
}
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
@ -103,7 +108,7 @@ do
case "$1" in
# Print help
-h | -help)
usage
usage && exit 0
;;
# Non-stop compilation, ignoring errors
-a | -all | all)
@ -119,7 +124,7 @@ do
shift
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -229,7 +234,7 @@ esac
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage rmdepMode all
unset Script usage error rmdepMode all
#------------------------------------------------------------------------------

View file

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -41,17 +41,24 @@ Script=${0##*/}
. ${0%/*}/scripts/wmakeFunctions
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [file]
options:
-all | -a non-stop compilation, ignoring errors
-help print the usage
Remove all .o files or remove .o file corresponding to <file>
USAGE
exit 1
}
error() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
usage
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
@ -64,7 +71,7 @@ while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
usage && exit 0
;;
# Non-stop compilation, ignoring errors
-a | -all | all)
@ -72,7 +79,7 @@ do
shift
;;
-*)
usage "unknown option: '$*'"
error "unknown option: '$*'"
;;
*)
break
@ -110,7 +117,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage error
#------------------------------------------------------------------------------