gtsam/.travis.sh

115 lines
2.4 KiB
Bash
Raw Normal View History

2019-05-31 15:48:51 +08:00
#!/bin/bash
2020-03-27 04:03:51 +08:00
# install TBB with _debug.so files
function install_tbb()
{
TBB_BASEURL=https://github.com/oneapi-src/oneTBB/releases/download
TBB_VERSION=4.4.2
TBB_DIR=tbb44_20151115oss
TBB_SAVEPATH="/tmp/tbb.tgz"
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
OS_SHORT="lin"
TBB_LIB_DIR="intel64/gcc4.4"
SUDO="sudo"
elif [ "$TRAVIS_OS_NAME" == "osx" ]; then
OS_SHORT="lin"
TBB_LIB_DIR=""
SUDO=""
fi
wget "${TBB_BASEURL}/${TBB_VERSION}/${TBB_DIR}_${OS_SHORT}.tgz" -O $TBB_SAVEPATH
tar -C /tmp -xf $TBB_SAVEPATH
2020-03-27 06:00:47 +08:00
TBBROOT=/tmp/$TBB_DIR
# Copy the needed files to the correct places.
# This works correctly for travis builds, instead of setting path variables.
# This is what Homebrew does to install TBB on Macs
$SUDO cp -R $TBBROOT/lib/$TBB_LIB_DIR/* /usr/local/lib/
$SUDO cp -R $TBBROOT/include/ /usr/local/include/
2020-03-27 06:00:47 +08:00
2020-03-27 04:03:51 +08:00
}
# common tasks before either build or test
2019-12-11 23:31:43 +08:00
function configure()
{
set -e # Make sure any error makes the script to return an error code
set -x # echo
2019-05-31 15:48:51 +08:00
SOURCE_DIR=`pwd`
BUILD_DIR=build
2019-05-31 15:48:51 +08:00
#env
git clean -fd || true
rm -fr $BUILD_DIR || true
mkdir $BUILD_DIR && cd $BUILD_DIR
2020-03-28 18:56:58 +08:00
install_tbb
2019-05-31 15:48:51 +08:00
if [ ! -z "$GCC_VERSION" ]; then
2019-12-11 23:31:43 +08:00
export CC=gcc-$GCC_VERSION
export CXX=g++-$GCC_VERSION
2019-05-31 15:48:51 +08:00
fi
2019-12-11 23:31:43 +08:00
# GTSAM_BUILD_WITH_MARCH_NATIVE=OFF: to avoid crashes in builder VMs
cmake $SOURCE_DIR \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
-DGTSAM_BUILD_TESTS=${GTSAM_BUILD_TESTS:-OFF} \
-DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \
2020-03-27 01:38:17 +08:00
-DGTSAM_WITH_TBB=${GTSAM_WITH_TBB:-OFF} \
2019-12-24 01:21:34 +08:00
-DGTSAM_USE_QUATERNIONS=${GTSAM_USE_QUATERNIONS:-OFF} \
2019-12-11 23:31:43 +08:00
-DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \
2020-07-23 05:32:07 +08:00
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=${GTSAM_ALLOW_DEPRECATED_SINCE_V41:-OFF} \
2019-12-11 23:31:43 +08:00
-DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \
2020-06-18 04:02:24 +08:00
-DCMAKE_VERBOSE_MAKEFILE=OFF
}
2019-12-11 23:31:43 +08:00
# common tasks after either build or test
function finish ()
{
# Print ccache stats
ccache -s
cd $SOURCE_DIR
}
# compile the code with the intent of populating the cache
function build ()
{
2019-12-11 23:31:43 +08:00
export GTSAM_BUILD_EXAMPLES_ALWAYS=ON
export GTSAM_BUILD_TESTS=OFF
2019-05-31 15:48:51 +08:00
2019-12-11 23:31:43 +08:00
configure
2019-05-31 15:48:51 +08:00
2019-12-11 23:31:43 +08:00
make -j2
2019-05-31 15:48:51 +08:00
finish
}
2019-05-31 15:48:51 +08:00
# run the tests
function test ()
{
2019-12-11 23:31:43 +08:00
export GTSAM_BUILD_EXAMPLES_ALWAYS=OFF
export GTSAM_BUILD_TESTS=ON
2019-06-03 06:12:08 +08:00
2019-12-11 23:31:43 +08:00
configure
# Actual build:
make -j2 check
finish
2019-05-31 15:48:51 +08:00
}
# select between build or test
case $1 in
-b)
build
;;
2019-12-11 23:31:43 +08:00
-t)
test
;;
esac