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 # -t (--tag) A git valid tag, commit, etc in subsurface tree
# -j (--jobs) Desired build parallelism, integer. # -j (--jobs) Desired build parallelism, integer.
# -b (--build) Cmake build type, valid values Debug or Release # -b (--build) Cmake build type, valid values Debug or Release
# -y Assume "yes" in prompt. Useful in automated builds
# Examples: # Examples:
# $ ./subsurface/scripts/build-smtk2ssrf.sh # $ ./subsurface/scripts/build-smtk2ssrf.sh
# No flags, will build a Release version, with -j4 parallelism in the # No flags, will build a Release version, with -j4 parallelism in the
@ -31,6 +32,7 @@ RELEASE=Release
BASEDIR="$(pwd)" BASEDIR="$(pwd)"
INSTALL_ROOT="$BASEDIR"/install-root INSTALL_ROOT="$BASEDIR"/install-root
SSRF_PATH="$BASEDIR"/subsurface SSRF_PATH="$BASEDIR"/subsurface
AUTO="${TRAVIS:-false}"
# Display an error message if we need to bail out # Display an error message if we need to bail out
# #
@ -39,33 +41,39 @@ function aborting() {
exit 1 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 # check for arguments and set options if any
# #
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case $1 in case $1 in
-c|--cli) CLI="ON" -c|--cli) CLI="ON"
;; shift;;
-t|--tag) SSRF_TAG="$2" -t|--tag) SSRF_TAG="$2"
shift;; shift 2;;
-j|--jobs) JOBS=-j"$2" -j|--jobs) JOBS=-j"$2"
shift;; shift 2;;
-b|--build) RELEASE="$2" -b|--build) RELEASE="$2"
shift 2;;
-y) AUTO="true"
shift;; shift;;
*) aborting "Wrong parameter $1"
esac esac
shift
done 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 <<" echo ">> Building smtk2ssrf <<"
# Check if we are in a sane environment # 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 # Check if mdbtools devel package is avaliable, if it is not, download
# and build it. # 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 " echo "----> Downloading/Updating mdbtools "
if [ -d "$BASEDIR"/mdbtools ]; then if [ -d "$BASEDIR"/mdbtools ]; then
cd "$BASEDIR"/mdbtools || aborting "Couldn't cd into $BASEDIR/mdbtools" cd "$BASEDIR"/mdbtools || aborting "Couldn't cd into $BASEDIR/mdbtools"
git pull --rebase git pull --rebase || aborting "Problem downloading/updating mdbtools"
else 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 fi
[[ $? -ne 0 ]] && aborting "Problem downloading/updating mdbtools"
echo "----> Building mdbtools ..." echo "----> Building mdbtools ..."
echo "----> This will display a lot of errors and warnings" 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 ./configure --prefix "$INSTALL_ROOT" --disable-man --disable-gmdb2 >/dev/null
make "$JOBS">/dev/null || aborting "Building mdbtools failed" make "$JOBS">/dev/null || aborting "Building mdbtools failed"
make install make install
else
echo "----> Mdbtools already installed: $(pkg-config --print-provides libmdb)"
fi fi
# Build bare metal Subsurface. # 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" cd "$SSRF_PATH"/smtk-import || aborting "Couldnt cd into $SSRF_PATH/smtk-import"
mkdir -p build mkdir -p build
cd build || aborting "Couldn't cd into $SSRF_PATH/smtk-import/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" \ # Install on automatic builds
-DCOMMANDLINE=${CLI:-OFF} \ if [ "$AUTO" == "true" ]; then
.. || aborting "Cmake incomplete" LIBRARY_PATH=$INSTALL_ROOT/lib make install
else
make "$JOBS" || aborting "Failed to build smtk2ssrf" printf "
>> Building smtk2ssrf completed <<
printf " >> Executable placed in %s/smtk-import/build <<
>> Building smtk2ssrf completed << >> To install system-wide, move there and run sudo make install <<\n" "$SSRF_PATH"
>> Executable placed in %s/smtk-import/build << fi
>> To install system-wide, move there and run sudo make install <<\n" "$SSRF_PATH"