Skip to content

Commit 656f5b8

Browse files
Merge pull request #103 from HerbertKoelman/192-handle-travis-branch-issue
handle travis branch issue
2 parents ddc30f0 + 13d39c3 commit 656f5b8

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

BUILD

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#
55
cmake_build(){
66

7-
echo "[ -d $cmake_build_dir ] && ( cd $cmake_build_dir && cmake $cmake_args .. && make $make_args )"
8-
[ -d $cmake_build_dir ] && ( cd $cmake_build_dir && cmake $cmake_args .. && make $make_args )
7+
echo "cd cmake-build && cmake $cmake_args .. && make $make_args "
8+
[ -d cmake-build ] && ( cd cmake-build && cmake $cmake_args .. && make $make_args )
99

1010
}
1111

@@ -24,14 +24,27 @@ usage(){
2424
exit 99
2525
}
2626

27-
git_current_branch=`git rev-parse --abbrev-ref HEAD -- | head -1`
27+
set_current_branch(){
28+
if [ -z "$TRAVIS_BRANCH" ]
29+
then
30+
current_branch=`git rev-parse --abbrev-ref HEAD -- | head -1`
31+
else
32+
if [ -z "$TRAVIS_TAG" ]
33+
then
34+
[ -z "$TRAVIS_PULL_REQUEST_BRANCH" ] && current_branch=$TRAVIS_BRANCH || current_branch=$TRAVIS_PULL_REQUEST_BRANCH
35+
else
36+
current_branch="master"
37+
fi
38+
fi
39+
}
40+
41+
set_current_branch
2842

29-
if [ "$git_current_branch" == "master" ]
43+
if [ "$current_branch" == "master" ]
3044
then
3145
cmake_build_type="-DCMAKE_BUILD_TYPE=Release"
3246
else
3347
cmake_build_type="-DCMAKE_BUILD_TYPE=Debug"
34-
cmake_build_dir=cmake-build
3548
fi
3649

3750
make_args="all test"
@@ -50,13 +63,14 @@ cmake_args="$cmake_build_type $cmake_gcov_option $cmake_sonar_option"
5063

5164
echo "##############################################################################"
5265
echo "#"
66+
[ ! -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#"
5367
echo "# Project: cpp-pthread"
5468
echo "# Build date: `date`"
55-
echo "# Build directory: $cmake_build_dir"
69+
echo "# Build directory: cmake-build"
5670
echo "# Build options: $cmake_args"
57-
echo "# GIT current branch: [$git_current_branch]"
71+
echo "# GIT current branch: [$current_branch]"
5872
echo "#"
5973
echo "##############################################################################"
6074

61-
[ -d $cmake_build_dir ] && (rm -Rf $cmake_build_dir/* && cmake_build ) || ( mkdir $cmake_build_dir && cmake_build )
75+
[ -d cmake-build ] && (rm -Rf cmake-build/* && cmake_build ) || ( mkdir cmake-build && cmake_build )
6276

0 commit comments

Comments
 (0)