Skip to content

Commit

Permalink
refs #203
Browse files Browse the repository at this point in the history
- updated travis' build method (using BUILD script)
  • Loading branch information
HerbertKoelman committed Oct 27, 2019
1 parent 002f3ed commit 421c670
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 19 deletions.
20 changes: 1 addition & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,8 @@ addons:
- doxygen
- graphviz

matrix:
include:
- name: coverage jobs
env:
BUILD_DIRECTORY=cmake-gcov-build
CMAKE_COMMAND_LINE_ARGS="-DGCOV=yes"
MAKE_TARGETS="all test"
- name: sonar code quality checks
env:
BUILD_DIRECTORY=cmake-sonar-build
CMAKE_COMMAND_LINE_ARGS="-DSONAR=yes"
MAKE_TARGETS="code-quality"
- name: default
env:
BUILD_DIRECTORY=cmake-default-build
CMAKE_COMMAND_LINE_ARGS="-DCMAKE_BUILD_TYPE=Release"
MAKE_TARGETS="all doxygen package"

script:
- mkdir $BUILD_DIRECTORY && cd $BUILD_DIRECTORY && cmake $CMAKE_COMMAND_LINE_ARGS .. && make $MAKE_TARGETS
- ./BUILD -S

after_success:
# create gcov files
Expand Down
76 changes: 76 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash

# does actual build.
#
cmake_build(){

echo "cd cmake-build && cmake $cmake_args .. && make $make_args "
[ -d cmake-build ] && ( cd cmake-build && cmake $cmake_args .. && make $make_args )

}

# build command usage message
#
usage(){
echo "usage: `basename $0` [-G] [-S] [-T <build_type>]"
echo
echo "Build this module."
echo
echo "-S setup things to run SONAR"
echo "-G setup things to compile with coverage options and libs"
echo "-T build type (Release, Debug, ...)"
echo

exit 99
}

set_current_branch(){
if [ -z "$TRAVIS_BRANCH" ]
then
current_branch=`git rev-parse --abbrev-ref HEAD -- | head -1`
else
if [ -z "$TRAVIS_TAG" ]
then
[ -z "$TRAVIS_PULL_REQUEST_BRANCH" ] && current_branch=$TRAVIS_BRANCH || current_branch=$TRAVIS_PULL_REQUEST_BRANCH
else
current_branch="master"
fi
fi
}

set_current_branch

if [ "$current_branch" == "master" ]
then
cmake_build_type="-DCMAKE_BUILD_TYPE=Release"
else
cmake_build_type="-DCMAKE_BUILD_TYPE=Debug"
fi

make_args="all test"

while getopts "SGT:" option
do
case $option in
S) cmake_sonar_option="-DSONAR=yes" ; cmake_gcov_option="-DCOVERAGE=yes" ; make_args="code-quality";;
G) cmake_gcov_option="-DCOVERAGE=yes" ; make_args="$make_args coverage";;
T) cmake_build_type="-DCMAKE_BUILD_TYPE=$OPTARG" ;;
*) usage ;; # display usage and exit
esac
done

cmake_args="$cmake_build_type $cmake_gcov_option $cmake_sonar_option"

echo "##############################################################################"
echo "#"
[ ! -z "$TRAVIS_BRANCH" ] && echo -e "# Running on Travis (TRAVIS_BRANCH: $TRAVIS_BRANCH, TRAVIS_TAG: $TRAVIS_TAG, TRAVIS_PULL_REQUEST_BRANCH: $TRAVIS_PULL_REQUEST_BRANCH)\n#"
echo "# Project: cpp-pthread"
echo "# Build date: `date`"
echo "# Build directory: cmake-build"
echo "# Build options: $cmake_args"
echo "# GIT current branch: [$current_branch]"
echo "#"
echo "##############################################################################"

[ -d cmake-build ] && (rm -Rf cmake-build/* && cmake_build ) || ( mkdir cmake-build && cmake_build )

0 comments on commit 421c670

Please sign in to comment.