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>
This commit is contained in:
Salvador Cuñat 2018-02-14 18:22:09 +01:00 committed by Dirk Hohndel
parent 142c60ff88
commit d303a589e6

View file

@ -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"
;;
shift;;
-t|--tag) SSRF_TAG="$2"
shift;;
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