1#!/bin/bash
2
3case "$1" in
4    "before_install")
5	;;
6    "install")
7	case "${TRAVIS_OS_NAME}" in
8	    "osx")
9		brew update
10		brew install binutils
11
12		case "${CC}" in
13		    "gcc-"*)
14			which ${CC} || brew install $(echo "${CC}" | sed 's/\-/@/') || brew link --overwrite $(echo "${CC}" | sed 's/\-/@/')
15			;;
16		esac
17
18		case "${BUILD_SYSTEM}" in
19		    "bazel")
20			brew install bazel
21			;;
22		esac
23		;;
24	    "linux")
25		case "${CC}" in
26		    "pgcc")
27			wget 'https://raw.githubusercontent.com/nemequ/pgi-travis/de6212d94fd0e7d07a6ef730c23548c337c436a7/install-pgi.sh'
28			echo 'acd3ef995ad93cfb87d26f65147395dcbedd4c3c844ee6ec39616f1a347c8df5  install-pgi.sh' | sha256sum -c --strict || exit 1
29			/bin/sh install-pgi.sh
30			;;
31		esac
32		;;
33	esac
34	;;
35    "script")
36	case "${BUILD_SYSTEM}" in
37	    "cmake")
38		mkdir builddir && cd builddir
39		CMAKE_FLAGS=
40		if [ "${CROSS_COMPILE}" = "yes" ]; then
41		    CMAKE_FLAGS="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RC_COMPILER=${RC_COMPILER}"
42		fi
43		cmake ${CMAKE_FLAGS} -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DENABLE_SANITIZER="${SANITIZER}" -DCMAKE_C_FLAGS="${CFLAGS}" .. || exit 1
44		make VERBOSE=1 || exit 1
45		ctest -V || exit 1
46		;;
47	    "python")
48		python setup.py test
49		;;
50	    "maven")
51		cd java/org/brotli
52		mvn install && cd integration && mvn verify
53		;;
54	    "autotools")
55		./bootstrap && ./configure && make
56		;;
57	    "fuzz")
58		./c/fuzz/test_fuzzer.sh
59		;;
60	    "bazel")
61		bazel build -c opt ...:all &&
62		cd go && bazel test -c opt ...:all && cd .. &&
63		cd java && bazel test -c opt ...:all && cd .. &&
64		cd js && bazel test -c opt ...:all && cd .. &&
65		cd research && bazel build -c opt ...:all && cd ..
66		;;
67	esac
68	;;
69    "after_success")
70	;;
71    "before_deploy")
72	case "${BUILD_SYSTEM}" in
73	    "bazel")
74		export RELEASE_DATE=`date +%Y-%m-%d`
75		perl -p -i -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' scripts/.bintray.json
76		zip -j9 brotli.zip bazel-bin/libbrotli*.a bazel-bin/libbrotli*.so bazel-bin/brotli
77		;;
78	esac
79	;;
80esac
81