bfd8b749351fa61c901fc7445423be9dfe1b9f80
[platform/upstream/libffi.git] / .travis / build.sh
1 #!/bin/bash
2
3 set -x
4
5 if [ -z ${QEMU_CPU+x} ]; then
6     export SET_QEMU_CPU=
7 else
8     export SET_QEMU_CPU="-e QEMU_CPU=${QEMU_CPU}"
9 fi
10
11 # Default to podman where available, docker otherwise.
12 # Override by setting the DOCKER environment variable.
13 if test -z "$DOCKER"; then
14   which podman > /dev/null 2>&1
15   if [ $? != 0 ]; then
16     export DOCKER=docker
17   else
18     export DOCKER=podman
19   fi
20 fi
21
22 function build_cfarm()
23 {
24     curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee build.log
25     echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
26     echo $(tail build.log | grep '^==LOGFILE==')
27     echo $(tail build.log | grep '^==LOGFILE==' | cut -b13-)
28     echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
29     curl -u ${CFARM_AUTH} "$(tail build.log | grep '^== LOGFILE ==' | cut -b13-)" > libffi.log
30
31     ./rlgl l https://rl.gl
32     ID=$(./rlgl start)
33     ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git libffi.log
34     exit $?
35 }
36
37 function build_linux()
38 {
39     ./autogen.sh
40     ./configure ${HOST+--host=$HOST} ${CONFIGURE_OPTIONS}
41     make
42     make dist
43     make check RUNTESTFLAGS="-a $RUNTESTFLAGS"
44
45     ./rlgl l https://rl.gl
46     ID=$(./rlgl start)
47     ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log
48     exit $?
49 }
50
51 function build_foreign_linux()
52 {
53     ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh
54
55     ./rlgl l https://rl.gl
56     ID=$(./rlgl start)
57     ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log
58     exit $?
59 }
60
61 function build_cross_linux()
62 {
63     ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh
64
65     ./rlgl l https://rl.gl
66     ID=$(./rlgl start)
67     ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log
68     exit $?
69 }
70
71 function build_ios()
72 {
73     which python
74 # export PYTHON_BIN=/usr/local/bin/python
75     ./generate-darwin-source-and-headers.py --only-ios
76     xcodebuild -showsdks
77     xcodebuild -project libffi.xcodeproj -target "libffi-iOS" -configuration Release -sdk iphoneos11.4
78     exit $?
79 }
80
81 function build_macosx()
82 {
83     which python
84 # export PYTHON_BIN=/usr/local/bin/python
85     ./generate-darwin-source-and-headers.py --only-osx
86     xcodebuild -showsdks
87     xcodebuild -project libffi.xcodeproj -target "libffi-Mac" -configuration Release -sdk macosx10.13
88     exit $?
89 }
90
91 case "$HOST" in
92     arm-apple-darwin*)
93         ./autogen.sh
94         build_ios
95         ;;
96     x86_64-apple-darwin*)
97         ./autogen.sh
98         build_macosx
99         ;;
100     arm32v7-linux-gnu)
101         ./autogen.sh
102         build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest 
103         ;;
104     aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu)
105         build_cfarm
106         ;;
107     m68k-linux-gnu )
108         ./autogen.sh
109         GCC_OPTIONS=-mcpu=547x build_cross_linux
110         ;;
111     alpha-linux-gnu | sh4-linux-gnu | s390x-linux-gnu )
112         ./autogen.sh
113         build_cross_linux
114         ;;
115     *)
116         ./autogen.sh
117         build_linux
118         ;;
119 esac