2016-06-28 21:53:08 +02:00
|
|
|
#!/bin/bash
|
2016-07-13 16:20:15 +02:00
|
|
|
|
|
|
|
# for executing in non travis environment
|
2016-11-20 22:57:19 +01:00
|
|
|
[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
2016-07-13 16:20:15 +02:00
|
|
|
|
2016-11-20 22:57:19 +01:00
|
|
|
PLATFORM=x86
|
|
|
|
BUILD_TYPE=Debug
|
2019-01-06 19:49:56 +01:00
|
|
|
PACKAGES=""
|
2016-07-13 16:20:15 +02:00
|
|
|
|
2016-08-28 15:10:43 +02:00
|
|
|
# Detect number of processor cores
|
2016-11-20 22:57:19 +01:00
|
|
|
# default is 4 jobs
|
|
|
|
if [[ "$TRAVIS_OS_NAME" == 'osx' || "$TRAVIS_OS_NAME" == 'darwin' ]]
|
|
|
|
then
|
|
|
|
JOBS=$(sysctl -n hw.ncpu)
|
|
|
|
PLATFORM=osx
|
|
|
|
elif [[ "$TRAVIS_OS_NAME" == 'linux' ]]
|
|
|
|
then
|
|
|
|
JOBS=$(nproc)
|
2016-06-28 21:53:08 +02:00
|
|
|
fi
|
2019-01-06 19:49:56 +01:00
|
|
|
echo "compile jobs: ${JOBS:=4}"
|
2016-06-28 21:53:08 +02:00
|
|
|
|
2019-01-06 19:49:56 +01:00
|
|
|
# Determine cmake build type; tag builds are Release, else Debug
|
2016-11-20 22:57:19 +01:00
|
|
|
[ -n "${TRAVIS_TAG:-}" ] && BUILD_TYPE=Release
|
|
|
|
|
2019-01-06 19:49:56 +01:00
|
|
|
# Determine package creation; True for cron and tag builds
|
|
|
|
[ "${TRAVIS_EVENT_TYPE:-}" == 'cron' ] || [ -n "${TRAVIS_TAG:-}" ] && PACKAGES=package
|
2016-08-28 15:10:43 +02:00
|
|
|
|
2019-01-06 19:49:56 +01:00
|
|
|
# Determie -dev appends to platform;
|
2017-08-01 15:42:36 +02:00
|
|
|
[ "${TRAVIS_EVENT_TYPE:-}" != 'cron' -a -z "${TRAVIS_TAG:-}" ] && PLATFORM=${PLATFORM}-dev
|
2016-11-20 22:57:19 +01:00
|
|
|
|
2019-01-06 19:49:56 +01:00
|
|
|
# Build the package on osx
|
|
|
|
if [[ "$TRAVIS_OS_NAME" == 'osx' || "$TRAVIS_OS_NAME" == 'darwin' ]]
|
2017-08-12 07:55:32 +02:00
|
|
|
then
|
2019-01-06 19:49:56 +01:00
|
|
|
# compile prepare
|
|
|
|
mkdir build || exit 1
|
|
|
|
cd build
|
|
|
|
cmake -DPLATFORM=$PLATFORM -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=/usr .. || exit 2
|
|
|
|
make -j ${JOBS} || exit 3
|
2017-08-12 07:55:32 +02:00
|
|
|
fi
|
2016-11-20 22:57:19 +01:00
|
|
|
|
2019-01-06 19:49:56 +01:00
|
|
|
# Build the package with docker
|
2016-11-20 22:57:19 +01:00
|
|
|
if [[ $TRAVIS_OS_NAME == 'linux' ]]
|
|
|
|
then
|
2019-01-06 19:49:56 +01:00
|
|
|
echo "Compile Hyperion with DOCKER_TAG = ${DOCKER_TAG} and friendly name DOCKER_NAME = ${DOCKER_NAME}"
|
|
|
|
# take ownership of deploy dir
|
|
|
|
mkdir $TRAVIS_BUILD_DIR/deploy
|
|
|
|
# run docker
|
|
|
|
docker run --rm \
|
|
|
|
-v "${TRAVIS_BUILD_DIR}/deploy:/deploy" \
|
|
|
|
-v "${TRAVIS_BUILD_DIR}:/source:ro" \
|
|
|
|
hyperionorg/hyperion-ci:$DOCKER_TAG \
|
|
|
|
/bin/bash -c "mkdir build && cp -r /source/. /build &&
|
|
|
|
cd /build && mkdir build && cd build &&
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. || exit 2 &&
|
|
|
|
make -j $(nproc) ${PACKAGES} || exit 3 &&
|
|
|
|
echo '---> Copy binaries and packages to host folder: ${TRAVIS_BUILD_DIR}/deploy' &&
|
|
|
|
cp -v /build/build/bin/h* /deploy/ 2>/dev/null || : &&
|
|
|
|
cp -v /build/build/Hyperion-* /deploy/ 2>/dev/null || : &&
|
|
|
|
exit 0;
|
|
|
|
exit 1 " || { echo "---> Hyperion compilation failed! Abort"; exit 4; }
|
2016-07-13 16:20:15 +02:00
|
|
|
|
2019-01-06 19:49:56 +01:00
|
|
|
# overwrite file owner to current user
|
|
|
|
sudo chown -fR $(stat -c "%U:%G" $TRAVIS_BUILD_DIR/deploy) $TRAVIS_BUILD_DIR/deploy
|
|
|
|
fi
|