Skip to content

Commit

Permalink
CI: Better error handling in script
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Apr 18, 2024
1 parent 39535e9 commit 3c5ce3c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 57 deletions.
42 changes: 21 additions & 21 deletions cmake-config
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ INSTALL_PATH=${INSTALL_PATH:-${ACCESS}}

function check_valid()
{
if [ "${!1}" == "YES" ] || [ "${!1}" == "ON" ]; then
echo "YES"
return 1
if [ "${!1}" == "YES" ] || [ "${!1}" == "ON" ] || [ "${!1}" == "yes" ] || [ "${!1}" == "on" ]; then
echo "YES"
return 0
fi
if [ "${!1}" == "NO" ] || [ "${!1}" == "OFF" ]; then
echo "NO"
return 1
if [ "${!1}" == "NO" ] || [ "${!1}" == "OFF" ] || [ "${!1}" == "no" ] || [ "${!1}" == "off" ]; then
echo "NO"
return 0
fi
echo "Invalid value for $1 (${!1}) -- Must be ON, YES, NO, or OFF"
printf "\n${txtred}ERROR: Invalid value for $1 (${!1}) -- Must be ON, YES, NO, or OFF\n\n${txtrst}" >& 2
exit 1
}
### Possible subset of what is built ---
APPLICATIONS=${APPLICATIONS:-YES}
APPLICATIONS=$(check_valid APPLICATIONS)
APPLICATIONS=$(check_valid APPLICATIONS) || exit

LEGACY=${LEGACY:-YES}
LEGACY=$(check_valid LEGACY)
LEGACY=$(check_valid LEGACY) || exit

FORTRAN=${FORTRAN:-YES}
FORTRAN=$(check_valid FORTRAN)
FORTRAN=$(check_valid FORTRAN) || exit

ZOLTAN=${ZOLTAN:-YES}
ZOLTAN=$(check_valid ZOLTAN)
ZOLTAN=$(check_valid ZOLTAN) || exit

### TPLs --
### Make sure these point to the locations to find the libraries and includes in lib and include
Expand Down Expand Up @@ -94,7 +94,7 @@ then
fi
fi

MPI=$(check_valid MPI)
MPI=$(check_valid MPI) || exit
echo "${txtgrn}MPI set to ${MPI}${txtrst}"

if [ "${MPI}" == "NO" ]
Expand Down Expand Up @@ -263,15 +263,15 @@ GENERATOR=${GENERATOR:-"Unix Makefiles"}
# -DCMAKE_EXE_LINKER_FLAGS:STRING="-lxl -lxlopt"

CRAY="${CRAY:-NO}"
CRAY=$(check_valid CRAY)
CRAY=$(check_valid CRAY) || exit

if [ "${CRAY}" == "YES" ]
then
SHARED="${SHARED:-NO}"
else
SHARED="${SHARED:-YES}"
fi
SHARED=$(check_valid SHARED)
SHARED=$(check_valid SHARED) || exit

if [ "${CRAY}" == "YES" ] && [ "${SHARED}" == "NO" ]
then
Expand All @@ -291,14 +291,14 @@ BUILD_TYPE="${BUILD_TYPE:-RELEASE}"

if [ ! -z ${DEBUG+x} ]
then
if [ "${DEBUG}" == "ON" ] || [ "${DEBUG}" == "YES" ]
if [ "${DEBUG}" == "ON" ] || [ "${DEBUG}" == "YES" ] || [ "${DEBUG}" == "on" ] || [ "${DEBUG}" == "yes" ]
then
BUILD_TYPE="DEBUG"
elif [ "${DEBUG}" == "OFF" ] || [ "${DEBUG}" == "NO" ]
elif [ "${DEBUG}" == "OFF" ] || [ "${DEBUG}" == "NO" ] || [ "${DEBUG}" == "off" ] || [ "${DEBUG}" == "no" ]
then
BUILD_TYPE="RELEASE"
else
echo "ERROR: Invalid value for DEBUG ('$DEBUG'). Must be 'ON', 'OFF', 'YES', 'NO'."
echo "${txtred}\nERROR: Invalid value for DEBUG ('$DEBUG') -- Must be ON, YES, NO, or OFF\n${txtrst}" >& 2
exit
fi
fi
Expand All @@ -308,11 +308,11 @@ fi
### which provides X11/Xlib.h and the libX11, then change the "YES"
### below to "NO". It will disable blot and fastq
HAVE_X11=${HAVE_X11:-YES}
HAVE_X11=$(check_valid HAVE_X11)
HAVE_X11=$(check_valid HAVE_X11) || exit

### Set to ON to enable the building of a thread-safe version of the Exodus and IOSS libraries.
THREADSAFE=${THREADSAFE:-NO}
THREADSAFE=$(check_valid THREADSAFE)
THREADSAFE=$(check_valid THREADSAFE) || exit

function check_enable()
{
Expand Down Expand Up @@ -415,7 +415,7 @@ fi

# Only run doxygen if me and on master branch...
DOXYGEN=${DOXYGEN:-NO}
DOXYGEN=$(check_valid DOXYGEN)
DOXYGEN=$(check_valid DOXYGEN) || exit

if [[ "$DOXYGEN" == "NO" && "$OS" == "Darwin" && "$MPI" == "NO" ]] ; then
branch=$(git branch |grep \* |cut -c3-)
Expand All @@ -428,7 +428,7 @@ fi
FC=${FC:-gfortran}

EXTRA_WARNINGS=${EXTRA_WARNINGS:-NO}
EXTRA_WARNINGS=$(check_valid EXTRA_WARNINGS)
EXTRA_WARNINGS=$(check_valid EXTRA_WARNINGS) || exit

SANITIZER=${SANITIZER:-NO}

Expand Down
72 changes: 36 additions & 36 deletions install-tpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ function check_exec()

function check_valid()
{
if [ "${!1}" == "YES" ] || [ "${!1}" == "ON" ]; then
if [ "${!1}" == "YES" ] || [ "${!1}" == "ON" ] || [ "${!1}" == "yes" ] || [ "${!1}" == "on" ]; then
echo "YES"
return 1
return 0
fi
if [ "${!1}" == "NO" ] || [ "${!1}" == "OFF" ]; then
if [ "${!1}" == "NO" ] || [ "${!1}" == "OFF" ] || [ "${!1}" == "no" ] || [ "${!1}" == "off" ]; then
echo "NO"
return 1
return 0
fi
echo "${txtred}Invalid value for $1 (${!1}) -- Must be ON, YES, NO, or OFF${txtrst}"
printf "${txtred}\nERROR: Invalid value for $1 (${!1}) -- Must be ON, YES, NO, or OFF\n\n${txtrst}" >& 2
exit 1
}

#By default, download and then install.
DOWNLOAD=${DOWNLOAD:-YES}
DOWNLOAD=$(check_valid DOWNLOAD)
DOWNLOAD=$(check_valid DOWNLOAD) || exit

BUILD=${BUILD:-YES}
BUILD=$(check_valid BUILD)
BUILD=$(check_valid BUILD) || exit

# Force downloading and installation even if the TPL already exists in lib/include
FORCE=${FORCE:-NO}
FORCE=$(check_valid FORCE)
FORCE=$(check_valid FORCE) || exit

DEBUG=${DEBUG:-NO}
DEBUG=$(check_valid DEBUG)
DEBUG=$(check_valid DEBUG) || exit

# Shared libraries or static libraries?
# For CRAY, must explicitly specify SHARED=YES, or it will default to NO
Expand All @@ -60,106 +60,106 @@ then
else
SHARED="${SHARED:-YES}"
fi
SHARED=$(check_valid SHARED)
SHARED=$(check_valid SHARED) || exit

# Enable Burst-Buffer support in PnetCDF?
BB=${BB:-NO}
BB=$(check_valid BB)
BB=$(check_valid BB) || exit

CRAY=${CRAY:-NO}
CRAY=$(check_valid CRAY)
CRAY=$(check_valid CRAY) || exit

MPI=${MPI:-NO}
MPI=$(check_valid MPI)
MPI=$(check_valid MPI) || exit

# Which TPLS? (NetCDF always, but can be disabled if using an external version, PnetCDF if MPI=ON)
NETCDF=${NETCDF:-YES}
NETCDF=$(check_valid NETCDF)
NETCDF=$(check_valid NETCDF) || exit
PNETCDF=${PNETCDF:-${MPI}}
PNETCDF=$(check_valid PNETCDF)
PNETCDF=$(check_valid PNETCDF) || exit
HDF5=${HDF5:-YES}
HDF5=$(check_valid HDF5)
HDF5=$(check_valid HDF5) || exit
CGNS=${CGNS:-${HDF5}}
CGNS=$(check_valid CGNS)
CGNS=$(check_valid CGNS) || exit

MATIO=${MATIO:-YES}
MATIO=$(check_valid MATIO)
MATIO=$(check_valid MATIO) || exit

PARMETIS=${PARMETIS:-NO}
PARMETIS=$(check_valid PARMETIS)
PARMETIS=$(check_valid PARMETIS) || exit

METIS=${METIS:-NO}
METIS=$(check_valid METIS)
METIS=$(check_valid METIS) || exit

if [ "$PARMETIS" == "YES" ]
then
METIS="YES"
fi

FMT=${FMT:-YES}
FMT=$(check_valid FMT)
FMT=$(check_valid FMT) || exit

GNU_PARALLEL=${GNU_PARALLEL:-YES}
GNU_PARALLEL=$(check_valid GNU_PARALLEL)
GNU_PARALLEL=$(check_valid GNU_PARALLEL) || exit

USE_ZLIB_NG=${USE_ZLIB_NG:-NO}
USE_ZLIB_NG=$(check_valid USE_ZLIB_NG)
USE_ZLIB_NG=$(check_valid USE_ZLIB_NG) || exit

if [ "${USE_ZLIB_NG}" == "YES" ]
then
export NEEDS_ZLIB="YES"
fi

NEEDS_ZLIB=${NEEDS_ZLIB:-NO}
NEEDS_ZLIB=$(check_valid NEEDS_ZLIB)
NEEDS_ZLIB=$(check_valid NEEDS_ZLIB) || exit

NEEDS_SZIP=${NEEDS_SZIP:-NO}
NEEDS_SZIP=$(check_valid NEEDS_SZIP)
NEEDS_SZIP=$(check_valid NEEDS_SZIP) || exit

USE_AEC=${USE_AEC:-NO}
USE_AEC=$(check_valid USE_AEC)
USE_AEC=$(check_valid USE_AEC) || exit

KOKKOS=${KOKKOS:-NO}
KOKKOS=$(check_valid KOKKOS)
KOKKOS=$(check_valid KOKKOS) || exit

H5VERSION=${H5VERSION:-V114}
# Build/Install the HDF5 C++ library?
H5CPP=${H5CPP:-NO}
H5CPP=$(check_valid H5CPP)
H5CPP=$(check_valid H5CPP) || exit

FAODEL=${FAODEL:-NO}
FAODEL=$(check_valid FAODEL)
FAODEL=$(check_valid FAODEL) || exit

BOOST=${BOOST:-NO}
BOOST=$(check_valid BOOST)
BOOST=$(check_valid BOOST) || exit

ADIOS2=${ADIOS2:-NO}
ADIOS2=$(check_valid ADIOS2)
ADIOS2=$(check_valid ADIOS2) || exit

CATALYST2=${CATALYST2:-NO}
CATALYST2=$(check_valid CATALYST2)
CATALYST2=$(check_valid CATALYST2) || exit

GTEST=${GTEST:-${FAODEL}}
GTEST=$(check_valid GTEST)
GTEST=$(check_valid GTEST) || exit

CATCH2=${CATCH2:-YES}
CATCH2=$(check_valid CATCH2)
CATCH2=$(check_valid CATCH2) || exit


SUDO=${SUDO:-}
JOBS=${JOBS:-2}
VERBOSE=${VERBOSE:-1}

USE_PROXY=${USE_PROXY:-NO}
USE_PROXY=$(check_valid USE_PROXY)
USE_PROXY=$(check_valid USE_PROXY) || exit

if [ "${USE_PROXY}" == "YES" ]
then
export http_proxy="http://proxy.sandia.gov:80"
export https_proxy="https://proxy.sandia.gov:80"
fi

pwd
echo "Current Location = $(pwd)"
INSTALL_PATH=${INSTALL_PATH:-${ACCESS}}

if [ "$MPI" == "YES" ] && [ "$CRAY" == "YES" ]
Expand Down

0 comments on commit 3c5ce3c

Please sign in to comment.