3 # This script executes the script step when running under travis-ci
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
10 # Set-up some variables
11 OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
13 OPJ_DO_SUBMIT=0 # Do not flood cdash
14 if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
15 OPJ_OWNER=$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')
16 OPJ_SITE="${OPJ_OWNER}.travis-ci.org"
17 if [ "${OPJ_OWNER}" == "uclouvain" ]; then
21 OPJ_SITE="$(hostname)"
24 if [ "${TRAVIS_OS_NAME:-}" == "" ]; then
25 # Let's guess OS for testing purposes
27 if uname -s | grep -i Darwin &> /dev/null; then
29 elif uname -s | grep -i Linux &> /dev/null; then
31 if [ "${CC:-}" == "" ]; then
36 echo "Failed to guess OS"; exit 1
38 echo "${TRAVIS_OS_NAME}"
41 if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
42 OPJ_OS_NAME=$(sw_vers -productName | tr -d ' ')$(sw_vers -productVersion | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
43 OPJ_CC_VERSION=$(xcodebuild -version | grep -i xcode)
44 OPJ_CC_VERSION=xcode${OPJ_CC_VERSION:6}
45 elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
47 if which lsb_release > /dev/null; then
48 OPJ_OS_NAME=$(lsb_release -si)$(lsb_release -sr | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
50 if [ "${CC}" == "gcc" ]; then
51 OPJ_CC_VERSION=gcc$(${CC} --version | head -1 | sed 's/.*\ \([0-9.]*[0-9]\)/\1/')
52 elif [ "${CC}" == "clang" ]; then
53 OPJ_CC_VERSION=clang$(${CC} --version | grep version | sed 's/.*version \([^0-9.]*[0-9.]*\).*/\1/')
55 echo "Compiler not supported: ${CC}"
58 echo "OS not supported: ${TRAVIS_OS_NAME}"
61 if [ "${TRAVIS_BRANCH:-}" == "" ]; then
62 echo "Guessing branch"
63 TRAVIS_BRANCH=$(git -C ../openjpeg branch | grep '*' | tr -d '*[[:blank:]]') #default to master
66 OPJ_BUILDNAME=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${TRAVIS_BRANCH}
67 if [ "${TRAVIS_PULL_REQUEST:-}" != "false" ] && [ "${TRAVIS_PULL_REQUEST:-}" != "" ]; then
68 OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${TRAVIS_PULL_REQUEST}
70 OPJ_BUILDNAME=${OPJ_BUILDNAME}-Release-3rdP
72 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ] && [ -d kdu ]; then
74 Testing will use Kakadu trial binaries. Here's the copyright notice from kakadu:
75 Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
76 You are free to trial these executables and even to re-distribute them,
77 so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
78 Note: Binaries can only be used for non-commercial purposes.
83 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ] && [ -d kdu ]; then
84 if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
85 export LD_LIBRARY_PATH=${PWD}/kdu:${LD_LIBRARY_PATH}
87 export PATH=${PWD}/kdu:${PATH}
92 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_CODEC=ON -DBUILD_THIRDPARTY=ON -DBUILD_TESTING=ON -DOPJ_DATA_ROOT=${PWD}/../data -DJPYLYZER_EXECUTABLE=${PWD}/../jpylyzer/jpylyzer/jpylyzer.py -DSITE=${OPJ_SITE} -DBUILDNAME=${OPJ_BUILDNAME} ${OPJ_SOURCE_DIR}
93 ctest -D ExperimentalStart
94 ctest -D ExperimentalBuild -V
95 ctest -D ExperimentalTest -j2 || true
96 ctest -D ExperimentalSubmit || true