2019-06-10 16:50:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# detect CI
|
|
|
|
if [ -n "${TRAVIS-}" ]; then
|
|
|
|
# Travis-CI
|
|
|
|
CI_NAME="$(echo "$TRAVIS_OS_NAME" | tr '[:upper:]' '[:lower:]')"
|
|
|
|
CI_BUILD_DIR="$TRAVIS_BUILD_DIR"
|
|
|
|
elif [ "$SYSTEM_COLLECTIONID" != "" ]; then
|
|
|
|
# Azure Pipelines
|
|
|
|
CI_NAME="$(echo "$AGENT_OS" | tr '[:upper:]' '[:lower:]')"
|
|
|
|
CI_BUILD_DIR="$BUILD_SOURCESDIRECTORY"
|
2019-09-12 19:47:23 +02:00
|
|
|
elif [ "$HOME" != "" ]; then
|
|
|
|
# GitHub Actions
|
|
|
|
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
|
|
CI_BUILD_DIR="$GITHUB_WORKSPACE"
|
2019-06-10 16:50:22 +02:00
|
|
|
else
|
|
|
|
# for executing in non ci environment
|
|
|
|
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
|
|
fi
|
|
|
|
|
2019-06-19 19:04:54 +02:00
|
|
|
# set environment variables if not exists
|
|
|
|
[ -z "${BUILD_TYPE}" ] && BUILD_TYPE="Debug"
|
2019-06-10 16:50:22 +02:00
|
|
|
|
2019-07-09 23:07:31 +02:00
|
|
|
# Determine cmake build type; tag builds are Release, else Debug (-dev appends to platform)
|
2019-09-12 19:47:23 +02:00
|
|
|
if [[ $BUILD_SOURCEBRANCH == *"refs/tags"* || $GITHUB_REF == *"refs/tags"* ]]; then
|
2019-06-10 16:50:22 +02:00
|
|
|
BUILD_TYPE=Release
|
2019-07-09 23:07:31 +02:00
|
|
|
else
|
|
|
|
PLATFORM=${PLATFORM}-dev
|
2019-06-10 16:50:22 +02:00
|
|
|
fi
|
|
|
|
|
2019-06-19 19:04:54 +02:00
|
|
|
# Build the package on osx or linux
|
2019-06-10 16:50:22 +02:00
|
|
|
if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then
|
|
|
|
# compile prepare
|
|
|
|
mkdir build || exit 1
|
|
|
|
cd build
|
2019-07-09 23:07:31 +02:00
|
|
|
cmake -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ../ || exit 2
|
2019-06-19 19:04:54 +02:00
|
|
|
make -j $(sysctl -n hw.ncpu) package || exit 3
|
2019-07-09 23:07:31 +02:00
|
|
|
cd ${CI_BUILD_DIR} && source /${CI_BUILD_DIR}/test/testrunner.sh || exit 4
|
2019-06-10 16:50:22 +02:00
|
|
|
exit 0;
|
2019-07-09 23:07:31 +02:00
|
|
|
exit 1 || { echo "---> Hyperion compilation failed! Abort"; exit 5; }
|
2019-06-10 16:50:22 +02:00
|
|
|
elif [[ "$CI_NAME" == 'linux' ]]; then
|
|
|
|
echo "Compile Hyperion with DOCKER_TAG = ${DOCKER_TAG} and friendly name DOCKER_NAME = ${DOCKER_NAME}"
|
|
|
|
# take ownership of deploy dir
|
|
|
|
mkdir ${CI_BUILD_DIR}/deploy
|
|
|
|
|
|
|
|
# run docker
|
|
|
|
docker run --rm \
|
|
|
|
-v "${CI_BUILD_DIR}/deploy:/deploy" \
|
|
|
|
-v "${CI_BUILD_DIR}:/source:ro" \
|
|
|
|
hyperionproject/hyperion-ci:$DOCKER_TAG \
|
2019-06-19 19:04:54 +02:00
|
|
|
/bin/bash -c "mkdir hyperion.ng && cp -r source/. /hyperion.ng &&
|
|
|
|
cd /hyperion.ng && mkdir build && cd build &&
|
|
|
|
cmake -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DDOCKER_PLATFORM=${DOCKER_TAG} ../ || exit 2 &&
|
|
|
|
make -j $(nproc) package || exit 3 &&
|
|
|
|
cp /hyperion.ng/build/bin/h* /deploy/ 2>/dev/null || : &&
|
|
|
|
cp /hyperion.ng/build/Hyperion.NG-* /deploy/ 2>/dev/null || : &&
|
2019-07-09 23:07:31 +02:00
|
|
|
cd /hyperion.ng && source /hyperion.ng/test/testrunner.sh || exit 4 &&
|
2019-06-10 16:50:22 +02:00
|
|
|
exit 0;
|
2019-07-09 23:07:31 +02:00
|
|
|
exit 1 " || { echo "---> Hyperion compilation failed! Abort"; exit 5; }
|
2019-06-10 16:50:22 +02:00
|
|
|
|
|
|
|
# overwrite file owner to current user
|
|
|
|
sudo chown -fR $(stat -c "%U:%G" ${CI_BUILD_DIR}/deploy) ${CI_BUILD_DIR}/deploy
|
|
|
|
fi
|