Commit 0b1c7610 authored by mark's avatar mark
Browse files

STYLE: provide 'die' as alternative to 'usage'

- make option parsing more consistent
parent b66ec91d
......@@ -69,17 +69,16 @@ do
;;
-f | -force)
forceOpt=true
shift
;;
[1-9]* | qt-[1-9]*)
qtVERSION="${1%%/}";
qtVERSION="${qtVERSION#qt-}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
#------------------------------------------------------------------------------
......
......@@ -61,6 +61,17 @@ then
fi
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error: see '${0##*/} -help' for usage"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
exit 1
}
# Test if it matches "*-none"
_foamIsNone()
{
......
......@@ -90,23 +90,19 @@ do
;;
lib|libso)
targetType="$1"
shift
;;
libccmio-[1-9]*)
ccmioPACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
# warn if unavailable
if [ ! -d ${ccmioPACKAGE} ]
then
usage "missing source directory '$ccmioPACKAGE'"
fi
# assert: directory must be available
[ -d "${ccmioPACKAGE}" ] || die "missing source directory '$ccmioPACKAGE'"
#------------------------------------------------------------------------------
......
......@@ -106,40 +106,32 @@ do
;;
-gcc)
export CXX=g++ # use g++
shift
;;
-sys*)
gmpPACKAGE="gmp-system"
mpfrPACKAGE="mpfr-system"
boostPACKAGE="boost-system"
shift
;;
gmp-[4-9]* | gmp-system)
gmpPACKAGE="${1%%/}"
shift
;;
mpfr-[2-9]* | mpfr-system)
mpfrPACKAGE="${1%%/}"
shift
;;
CGAL-[0-9]*)
cgalPACKAGE="${1%%/}"
shift
;;
boost-[0-9]* | boost_[0-9]* | boost-system )
boostPACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
if [ -z "$cgalPACKAGE" ]
then
usage "The cgal-VERSION was not specified"
fi
[ -n "$cgalPACKAGE" ] || die "The cgal-VERSION was not specified"
#------------------------------------------------------------------------------
#
......
......@@ -74,16 +74,15 @@ do
-gcc)
export CC=gcc # use gcc
export CXX=g++ # use g++
shift
;;
cmake-[1-9]*)
cmakePACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
......
......@@ -91,41 +91,32 @@ do
;;
-no-multi*)
GCC_BUILD_OPTIONS="--disable-multilib"
shift
;;
-sys*)
gmpPACKAGE="gmp-system"
mpfrPACKAGE="mpfr-system"
mpcPACKAGE="mpc-system"
shift
;;
gmp-[4-9]* | gmp-system)
gmpPACKAGE="${1%%/}"
shift
;;
mpfr-[2-9]* | mpfr-system)
mpfrPACKAGE="${1%%/}"
shift
;;
mpc-[0-9]* | mpc-system)
mpcPACKAGE="${1%%/}"
shift
;;
gcc-[4-9]*)
gccPACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
if [ -z "$gccPACKAGE" ]
then
usage "Please specify gcc-VERSION"
exit 1
fi
[ -n "$gccPACKAGE" ] || die "The gcc-VERSION was not specified"
cat<<SUMMARY
GCC configuration
......@@ -143,7 +134,7 @@ case "$WM_ARCH_OPTION" in
ABI=$WM_ARCH_OPTION
;;
*)
usage "Please set WM_ARCH_OPTION to either 32 or 64'$*'"
die "The WM_ARCH_OPTION ($WM_ARCH_OPTION) must be 32 or 64"
;;
esac
......
......@@ -69,12 +69,12 @@ do
;;
gperftools-[0-9]* | gperftools-svn*)
gperftoolsPACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
#------------------------------------------------------------------------------
......
......@@ -86,19 +86,15 @@ do
;;
llvm-[0-9]* | llvm-svn*)
llvmPACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
if [ -z "$llvmPACKAGE" ]
then
die "The llvm-VERSION was not specified"
exit 1
fi
[ -n "$llvmPACKAGE" ] || die "The llvm-VERSION was not specified"
#------------------------------------------------------------------------------
# build/install without compiler name
......
......@@ -78,6 +78,7 @@ CMAKE_PATH=""
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
......@@ -159,138 +160,118 @@ do
;;
[A-Z]*=*) # cmake variables
addCMakeVariable "$1"
shift
;;
-gcc)
export CXX=g++ # use g++
shift
;;
-patch) # stage 0: patch sources
runPATCH=true
unset runDEFAULT
shift
;;
-no-patch)
runPATCH=false
shift
;;
-config) # stage 1: config only
runCONFIG=true
unset runDEFAULT
shift
;;
-no-config)
runCONFIG=false
shift
;;
-make) # stage 2: make only
runMAKE=true
unset runDEFAULT
shift
;;
-no-make)
runMAKE=false
shift
;;
-install) # stage 3: install only
runINSTALL=true
unset runDEFAULT
shift
;;
-no-install)
runINSTALL=false
shift
;;
-rebuild) # shortcut for rebuilding
runMAKE=true
runINSTALL=true
unset runDEFAULT
shift
;;
-mesa)
withMESA=true
shift
;;
-no-mesa)
withMESA=false
shift
;;
-mesa-include)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_INCLUDE="$2"
shift 2
shift
;;
-mesa-lib)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_LIBRARY="$2"
shift 2
shift
;;
-mpi)
withMPI=true
shift
;;
-no-mpi)
withMPI=false
shift
;;
-python)
withPYTHON=true
shift
;;
-no-python)
withPYTHON=false
shift
;;
-python-lib)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
PYTHON_LIBRARY="$2"
shift 2
shift
;;
-cmake)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
CMAKE_PATH=$2
shift 2
shift
;;
-qmake)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
QMAKE_PATH=$2
shift 2
shift
;;
-qt)
withQT=true
shift
;;
-no-qt)
withQT=false
shift
;;
-qt-[1-9]*)
QMAKE_PATH="$installBASE/${1##-}"
shift
;;
-verbose)
withVERBOSE=true
shift
;;
-version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
setVersion "$2"
shift 2
shift
;;
-major)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
export ParaView_MAJOR="$2"
shift 2
shift
;;
-buildType)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
buildType="$2"
shift 2
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
......
......@@ -78,6 +78,7 @@ CMAKE_PATH=""
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
......@@ -156,124 +157,106 @@ do
;;
[A-Z]*=*) # cmake variables
addCMakeVariable "$1"
shift
;;
-gcc)
export CXX=g++ # use g++
shift
;;
-config) # stage 1: config only
runCONFIG=true
unset runDEFAULT
shift
;;
-no-config)
runCONFIG=false
shift
;;
-make) # stage 2: make only
runMAKE=true
unset runDEFAULT
shift
;;
-no-make)
runMAKE=false
shift
;;
-install) # stage 3: install only
runINSTALL=true
unset runDEFAULT
shift
;;
-no-install)
runINSTALL=false
shift
;;
-rebuild) # shortcut for rebuilding
runMAKE=true
runINSTALL=true
unset runDEFAULT
shift
;;
-mesa)
withMESA=true
shift
;;
-no-mesa)
withMESA=false
shift
;;
-mesa-include)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_INCLUDE="$2"
shift 2
shift
;;
-mesa-lib)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_LIBRARY="$2"
shift 2
shift
;;
-mpi)
withMPI=true
shift
;;
-no-mpi)
withMPI=false
shift
;;
-python)
withPYTHON=true
shift
;;
-no-python)
withPYTHON=false
shift
;;
-python-lib)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
PYTHON_LIBRARY="$2"
shift 2
shift
;;
-cmake)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
CMAKE_PATH=$2
shift 2
shift
;;
-qmake)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
QMAKE_PATH=$2
shift 2
shift
;;
-qt)
withQT=true
shift
;;
-no-qt)
withQT=false
shift
;;
-qt-[1-9]*)
QMAKE_PATH="$installBASE/${1##-}"
shift
;;
-verbose)
withVERBOSE=true
shift
;;
-version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
setVersion "$2"
shift 2
shift
;;
-major)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
export ParaView_MAJOR="$2"
shift 2
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
......
......@@ -73,17 +73,16 @@ do
;;
-gcc)
export CXX=g++ # use g++
shift
;;
[1-9]* | qt-[1-9]*)
qtVERSION="${1%%/}";
qtVERSION="${qtVERSION#qt-}"
shift
;;
*)
usage "unknown option/argument: '$*'"
die "unknown option/argument: '$1'"
;;
esac
shift
done
#------------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment