diff options
author | Paul Loberg <pallo@fourc.eu> | 2017-11-02 12:03:59 +0100 |
---|---|---|
committer | Paul Loberg <pallo@fourc.eu> | 2017-11-02 12:03:59 +0100 |
commit | cdf5989d58c8afd836ccdc4a16c093046182c569 (patch) | |
tree | eedf4a071a515c97f4dc8b5e1af5287f82888083 | |
parent | d608694a3a948d31c1046039e0b0dcea41301fa2 (diff) |
Handle missing source and build directories, as well as paths with whitespace.
-rwxr-xr-x | bootstrap-cpp.sh | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/bootstrap-cpp.sh b/bootstrap-cpp.sh index 0b1d5751e96..47d2a82622a 100755 --- a/bootstrap-cpp.sh +++ b/bootstrap-cpp.sh @@ -5,9 +5,10 @@ usage() { echo "Usage: $0 <source-dir> <build-dir>" >&2 } +# Parse arguments if [ $# -eq 2 ]; then - SOURCE_DIR=$(realpath $1) - BUILD_DIR=$(realpath $2) + SOURCE_DIR="$1" + BUILD_DIR="$2" elif [[ $# -eq 1 && ( "$1" = "-h" || "$1" = "--help" )]]; then usage exit 0 @@ -17,10 +18,23 @@ else exit 1 fi -mkdir -p "${BUILD_DIR}" +# Check the source directory +if [ ! -d "$SOURCE_DIR" ] ; then + echo "Source dir $SOURCE_DIR not found" >&2 + exit 1 +fi +SOURCE_DIR=$(realpath "${SOURCE_DIR}") + +# Check (and possibly create) the build directory +mkdir -p "${BUILD_DIR}" || { + echo "Failed to create build directory" >&2 + exit 1 +} +BUILD_DIR=$(realpath "${BUILD_DIR}") +# Build it source /opt/rh/devtoolset-6/enable || true cd "${SOURCE_DIR}" -sh ./bootstrap.sh full +bash ./bootstrap.sh full cd "${BUILD_DIR}" -sh ${SOURCE_DIR}/bootstrap-cmake.sh ${SOURCE_DIR} +bash ${SOURCE_DIR}/bootstrap-cmake.sh "${SOURCE_DIR}" |