Travis add debug config
[openjpeg.git] / tools / travis-ci / run.sh
1 #!/bin/bash
2
3 # This script executes the script step when running under travis-ci
4
5 # Set-up some bash options
6 set -o nounset   ## set -u : exit the script if you try to use an uninitialised variable
7 set -o errexit   ## set -e : exit the script if any statement returns a non-true return value
8 set -o pipefail  ## Fail on error in pipe
9
10 # Set-up some variables
11 if [ "${OPJ_CI_BUILD_CONFIGURATION:-}" == "" ]; then
12         export OPJ_CI_BUILD_CONFIGURATION=Release #default
13 fi
14 OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
15
16 if [ "${OPJ_DO_SUBMIT:-}" == "" ]; then
17         OPJ_DO_SUBMIT=0 # Do not flood cdash by default
18 fi
19 if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
20         OPJ_OWNER=$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')
21         OPJ_SITE="${OPJ_OWNER}.travis-ci.org"
22         if [ "${OPJ_OWNER}" == "uclouvain" ]; then
23                 OPJ_DO_SUBMIT=1
24         fi
25 else
26         OPJ_SITE="$(hostname)"
27 fi
28
29 if [ "${TRAVIS_OS_NAME:-}" == "" ]; then
30   # Let's guess OS for testing purposes
31         echo "Guessing OS"
32         if uname -s | grep -i Darwin &> /dev/null; then
33                 TRAVIS_OS_NAME=osx
34         elif uname -s | grep -i Linux &> /dev/null; then
35                 TRAVIS_OS_NAME=linux
36                 if [ "${CC:-}" == "" ]; then
37                         # default to gcc
38                         export CC=gcc
39                 fi
40         else
41                 echo "Failed to guess OS"; exit 1
42         fi
43         echo "${TRAVIS_OS_NAME}"
44 fi
45
46 if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
47         OPJ_OS_NAME=$(sw_vers -productName | tr -d ' ')$(sw_vers -productVersion | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
48         OPJ_CC_VERSION=$(xcodebuild -version | grep -i xcode)
49         OPJ_CC_VERSION=xcode${OPJ_CC_VERSION:6}
50 elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
51         OPJ_OS_NAME=linux
52         if which lsb_release > /dev/null; then
53                 OPJ_OS_NAME=$(lsb_release -si)$(lsb_release -sr | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
54         fi
55         if [ "${CC}" == "gcc" ]; then
56                 OPJ_CC_VERSION=gcc$(${CC} --version | head -1 | sed 's/.*\ \([0-9.]*[0-9]\)/\1/')
57         elif [ "${CC}" == "clang" ]; then
58                 OPJ_CC_VERSION=clang$(${CC} --version | grep version | sed 's/.*version \([^0-9.]*[0-9.]*\).*/\1/')
59         else
60                 echo "Compiler not supported: ${CC}"; exit 1
61         fi
62 else
63         echo "OS not supported: ${TRAVIS_OS_NAME}"; exit 1
64 fi
65
66 if [ "${OPJ_CI_ARCH:-}" == "" ]; then
67         echo "Guessing build architecture"
68         MACHINE_ARCH=$(uname -m)
69         if [ "${MACHINE_ARCH}" == "x86_64" ]; then
70                 export OPJ_CI_ARCH=x86_64
71         fi
72         echo "${OPJ_CI_ARCH}"
73 fi
74
75 if [ "${TRAVIS_BRANCH:-}" == "" ]; then
76         echo "Guessing branch"
77         TRAVIS_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]') #default to master
78 fi
79
80 OPJ_BUILDNAME=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}-${TRAVIS_BRANCH}
81 if [ "${TRAVIS_PULL_REQUEST:-}" != "false" ] && [ "${TRAVIS_PULL_REQUEST:-}" != "" ]; then
82         OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${TRAVIS_PULL_REQUEST}
83 fi
84 OPJ_BUILDNAME=${OPJ_BUILDNAME}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
85
86 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ] && [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ] && [ -d kdu ]; then
87         echo "
88 Testing will use Kakadu trial binaries. Here's the copyright notice from kakadu:
89 Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
90 You are free to trial these executables and even to re-distribute them,
91 so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
92 Note: Binaries can only be used for non-commercial purposes.
93 "
94 fi
95
96 set -x
97 # This will print configuration
98 # travis-ci doesn't dump cmake version in system info, let's print it 
99 cmake --version
100
101 export OPJ_SITE=${OPJ_SITE}
102 export OPJ_BUILDNAME=${OPJ_BUILDNAME}
103 export OPJ_SOURCE_DIR=${OPJ_SOURCE_DIR}
104 export OPJ_BUILD_CONFIGURATION=${OPJ_CI_BUILD_CONFIGURATION}
105 export OPJ_DO_SUBMIT=${OPJ_DO_SUBMIT}
106
107 ctest -S ${OPJ_SOURCE_DIR}/tools/ctest_scripts/travis-ci.cmake -V