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