summaryrefslogtreecommitdiffstats
path: root/scripts/smtk2ssrf-build.sh
diff options
context:
space:
mode:
authorGravatar Salvador Cuñat <salvador.cunat@gmail.com>2018-02-14 18:22:09 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-02-24 13:42:01 -0800
commitd303a589e682857f83d8c3ec5ea09a35bc00e7dd (patch)
treebcee422caffc90d1b6833cf2c64cae0701f29a7f /scripts/smtk2ssrf-build.sh
parent142c60ff888cf86e4125b7396f7c6b7734131343 (diff)
downloadsubsurface-d303a589e682857f83d8c3ec5ea09a35bc00e7dd.tar.gz
smtk-import: fit build script to run in travis builds
Set an "automatic" mode via parameter (or auto detected if running in travis environment) to skip the user prompt. Install the built binary, in automated builds, under the usual INSTALL_ROOT folder. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Diffstat (limited to 'scripts/smtk2ssrf-build.sh')
-rwxr-xr-xscripts/smtk2ssrf-build.sh74
1 files changed, 43 insertions, 31 deletions
diff --git a/scripts/smtk2ssrf-build.sh b/scripts/smtk2ssrf-build.sh
index 59d8037a9..e42917c79 100755
--- a/scripts/smtk2ssrf-build.sh
+++ b/scripts/smtk2ssrf-build.sh
@@ -6,6 +6,7 @@
# -t (--tag) A git valid tag, commit, etc in subsurface tree
# -j (--jobs) Desired build parallelism, integer.
# -b (--build) Cmake build type, valid values Debug or Release
+# -y Assume "yes" in prompt. Useful in automated builds
# Examples:
# $ ./subsurface/scripts/build-smtk2ssrf.sh
# No flags, will build a Release version, with -j4 parallelism in the
@@ -31,6 +32,7 @@ RELEASE=Release
BASEDIR="$(pwd)"
INSTALL_ROOT="$BASEDIR"/install-root
SSRF_PATH="$BASEDIR"/subsurface
+AUTO="${TRAVIS:-false}"
# Display an error message if we need to bail out
#
@@ -39,33 +41,39 @@ function aborting() {
exit 1
}
-printf "
-***** WARNING *****
-Please, note that this script will render your Subsurface binary unusable.
-So, if you are using the binary placed in build directory, you will need
-to rebuild it after running this script.
-
-Proceed? [y/n]\n"
-
-read -rs _proceed
-[[ $_proceed != "y" && $_proceed != "Y" ]] && exit 0
-
# check for arguments and set options if any
#
while [ $# -gt 0 ]; do
case $1 in
-c|--cli) CLI="ON"
- ;;
- -t|--tag) SSRF_TAG="$2"
shift;;
+ -t|--tag) SSRF_TAG="$2"
+ shift 2;;
-j|--jobs) JOBS=-j"$2"
- shift;;
+ shift 2;;
-b|--build) RELEASE="$2"
+ shift 2;;
+ -y) AUTO="true"
shift;;
+ *) aborting "Wrong parameter $1"
esac
- shift
done
+if [ "$AUTO" == "true" ]; then
+ _proceed="y"
+else
+ printf "
+ ***** WARNING *****
+ Please, note that this script will render your Subsurface binary unusable.
+ So, if you are using the binary placed in build directory, you will need
+ to rebuild it after running this script.
+
+ Proceed? [y/n]\n"
+
+ read -rs _proceed
+fi
+[[ $_proceed != "y" && $_proceed != "Y" ]] && exit 0
+
echo ">> Building smtk2ssrf <<"
# Check if we are in a sane environment
@@ -92,15 +100,17 @@ fi
# Check if mdbtools devel package is avaliable, if it is not, download
# and build it.
#
-if ! pkg-config --exists libmdb; then
+if pkg-config --exists libmdb; then
+ echo "----> Mdbtools already installed: $(pkg-config --print-provides libmdb)"
+else
echo "----> Downloading/Updating mdbtools "
if [ -d "$BASEDIR"/mdbtools ]; then
cd "$BASEDIR"/mdbtools || aborting "Couldn't cd into $BASEDIR/mdbtools"
- git pull --rebase
+ git pull --rebase || aborting "Problem downloading/updating mdbtools"
else
- git clone https://github.com/brianb/mdbtools.git "$BASEDIR"/mdbtools
+ git clone https://github.com/brianb/mdbtools.git "$BASEDIR"/mdbtools || \
+ aborting "Problem downloading/updating mdbtools"
fi
- [[ $? -ne 0 ]] && aborting "Problem downloading/updating mdbtools"
echo "----> Building mdbtools ..."
echo "----> This will display a lot of errors and warnings"
@@ -109,8 +119,6 @@ if ! pkg-config --exists libmdb; then
./configure --prefix "$INSTALL_ROOT" --disable-man --disable-gmdb2 >/dev/null
make "$JOBS">/dev/null || aborting "Building mdbtools failed"
make install
-else
- echo "----> Mdbtools already installed: $(pkg-config --print-provides libmdb)"
fi
# Build bare metal Subsurface.
@@ -166,14 +174,18 @@ echo "----> Building smtk2ssrf SmartTrak divelogs importer"
cd "$SSRF_PATH"/smtk-import || aborting "Couldnt cd into $SSRF_PATH/smtk-import"
mkdir -p build
cd build || aborting "Couldn't cd into $SSRF_PATH/smtk-import/build"
+_CMAKE_OPTS=( "-DCMAKE_BUILD_TYPE=$RELEASE" "-DCOMMANDLINE=${CLI:-OFF}" )
+[[ $AUTO == "true" ]] && _CMAKE_OPTS+=( "-DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT" )
+cmake "${_CMAKE_OPTS[@]}" .. || aborting "cmake incomplete"
+make clean
+LIBRARY_PATH=$INSTALL_ROOT/lib make "$JOBS" || aborting "Failed to build smtk2ssrf"
-cmake -DCMAKE_BUILD_TYPE="$RELEASE" \
- -DCOMMANDLINE=${CLI:-OFF} \
- .. || aborting "Cmake incomplete"
-
-make "$JOBS" || aborting "Failed to build smtk2ssrf"
-
-printf "
->> Building smtk2ssrf completed <<
->> Executable placed in %s/smtk-import/build <<
->> To install system-wide, move there and run sudo make install <<\n" "$SSRF_PATH"
+# Install on automatic builds
+if [ "$AUTO" == "true" ]; then
+ LIBRARY_PATH=$INSTALL_ROOT/lib make install
+else
+ printf "
+ >> Building smtk2ssrf completed <<
+ >> Executable placed in %s/smtk-import/build <<
+ >> To install system-wide, move there and run sudo make install <<\n" "$SSRF_PATH"
+fi