1#!/bin/bash 2 3set -x 4 5if [ -z ${QEMU_CPU+x} ]; then 6 export SET_QEMU_CPU= 7else 8 export SET_QEMU_CPU="-e QEMU_CPU=${QEMU_CPU}" 9fi 10 11# Default to podman where available, docker otherwise. 12# Override by setting the DOCKER environment variable. 13if 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 20fi 21 22function 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 37function 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 51function 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 61function 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 71function build_cross() 72{ 73 ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} 74 ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh 75 76 ./rlgl l https://rl.gl 77 ID=$(./rlgl start) 78 ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log 79 exit $? 80} 81 82function build_ios() 83{ 84 which python 85# export PYTHON_BIN=/usr/local/bin/python 86 ./generate-darwin-source-and-headers.py --only-ios 87 xcodebuild -showsdks 88 xcodebuild -project libffi.xcodeproj -target "libffi-iOS" -configuration Release -sdk iphoneos11.4 89 exit $? 90} 91 92function build_macosx() 93{ 94 which python 95# export PYTHON_BIN=/usr/local/bin/python 96 ./generate-darwin-source-and-headers.py --only-osx 97 xcodebuild -showsdks 98 xcodebuild -project libffi.xcodeproj -target "libffi-Mac" -configuration Release -sdk macosx10.13 99 exit $? 100} 101 102case "$HOST" in 103 arm-apple-darwin*) 104 ./autogen.sh 105 build_ios 106 ;; 107 x86_64-apple-darwin*) 108 ./autogen.sh 109 build_macosx 110 ;; 111 arm32v7-linux-gnu) 112 ./autogen.sh 113 build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest 114 ;; 115 aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) 116 build_cfarm 117 ;; 118 bfin-elf ) 119 ./autogen.sh 120 GCC_OPTIONS=-msim build_cross 121 ;; 122 m32r-elf ) 123 ./autogen.sh 124 build_cross 125 ;; 126 or1k-elf ) 127 ./autogen.sh 128 build_cross 129 ;; 130 m68k-linux-gnu ) 131 ./autogen.sh 132 GCC_OPTIONS=-mcpu=547x build_cross_linux 133 ;; 134 alpha-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) 135 ./autogen.sh 136 build_cross_linux 137 ;; 138 *) 139 ./autogen.sh 140 build_linux 141 ;; 142esac 143