• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2
3# This script executes the matrix loops, exclude tests and cleaning.
4# The matrix can be configured with environment variables MATRIX_CC,
5# MATRIX_CMAKE and MATRIX_REMOTE (default: MATRIX_CC='gcc clang',
6# MATRIX_CMAKE='no yes', MATRIX_REMOTE='no yes').
7# It calls the build.sh script which runs one build with setup environment
8# variables : CC, CMAKE and REMOTE (default: CC=gcc, CMAKE=no, REMOTE=no).
9
10set -e
11
12# ANSI color escape sequences
13ANSI_MAGENTA="\\033[35;1m"
14ANSI_RESET="\\033[0m"
15uname -a
16date
17# Install directory prefix
18if [ -z "$PREFIX" ]; then
19    PREFIX=$(mktemp -d -t libpcap_build_matrix_XXXXXXXX)
20    echo "PREFIX set to '$PREFIX'"
21    export PREFIX
22fi
23COUNT=0
24
25travis_fold() {
26    local action=${1:?}
27    local name=${2:?}
28    if [ "$TRAVIS" != true ]; then return; fi
29    echo -ne "travis_fold:$action:$LABEL.script.$name\\r"
30    sleep 1
31}
32
33# Display text in magenta
34echo_magenta() {
35    echo -ne "$ANSI_MAGENTA"
36    echo "$@"
37    echo -ne "$ANSI_RESET"
38}
39
40touch .devel configure
41for CC in ${MATRIX_CC:-gcc clang}; do
42    export CC
43    # Exclude gcc on macOS (it is just an alias for clang).
44    if [ "$CC" = gcc ] && [ "$(uname -s)" = Darwin ]; then
45        echo '(skipped)'
46        continue
47    fi
48    for CMAKE in ${MATRIX_CMAKE:-no yes}; do
49        export CMAKE
50        for REMOTE in ${MATRIX_REMOTE:-no yes}; do
51            export REMOTE
52            COUNT=$((COUNT+1))
53            echo_magenta "===== SETUP $COUNT: CC=$CC CMAKE=$CMAKE REMOTE=$REMOTE ====="
54            # LABEL is needed to build the travis fold labels
55            LABEL="$CC.$CMAKE.$REMOTE"
56            # Run one build with setup environment variables: CC, CMAKE and REMOTE
57            ./build.sh
58            echo 'Cleaning...'
59            travis_fold start cleaning
60            if [ "$CMAKE" = yes ]; then rm -rf build; else make distclean; fi
61            rm -rf "${PREFIX:?}"/*
62            git status -suall
63            # Cancel changes in configure
64            git checkout configure
65            travis_fold end cleaning
66        done
67    done
68done
69rm -rf "$PREFIX"
70echo_magenta "Tested setup count: $COUNT"
71# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
72