xref: /aosp_15_r20/external/libpcap/build_matrix.sh (revision 8b26181f966a6af5cf6981a6f474313de533bb28)
1*8b26181fSAndroid Build Coastguard Worker#!/bin/sh -e
2*8b26181fSAndroid Build Coastguard Worker
3*8b26181fSAndroid Build Coastguard Worker# This script executes the matrix loops, exclude tests and cleaning.
4*8b26181fSAndroid Build Coastguard Worker# The matrix can be configured with the following environment variables: MATRIX_CC,
5*8b26181fSAndroid Build Coastguard Worker# MATRIX_CMAKE and MATRIX_REMOTE.
6*8b26181fSAndroid Build Coastguard Worker: "${MATRIX_CC:=gcc clang}"
7*8b26181fSAndroid Build Coastguard Worker: "${MATRIX_CMAKE:=no yes}"
8*8b26181fSAndroid Build Coastguard Worker: "${MATRIX_REMOTE:=no yes}"
9*8b26181fSAndroid Build Coastguard Worker# Set this variable to "yes" before calling this script to disregard all
10*8b26181fSAndroid Build Coastguard Worker# warnings in a particular environment (CI or a local working copy).  Set it
11*8b26181fSAndroid Build Coastguard Worker# to "yes" in this script or in build.sh when a matrix subset is known to be
12*8b26181fSAndroid Build Coastguard Worker# not warning-free because of the OS, the compiler or whatever other factor
13*8b26181fSAndroid Build Coastguard Worker# that the scripts can detect both in and out of CI.
14*8b26181fSAndroid Build Coastguard Worker: "${LIBPCAP_TAINTED:=no}"
15*8b26181fSAndroid Build Coastguard Worker# Some OSes have native make without parallel jobs support and sometimes have
16*8b26181fSAndroid Build Coastguard Worker# GNU Make available as "gmake".
17*8b26181fSAndroid Build Coastguard Worker: "${MAKE_BIN:=make}"
18*8b26181fSAndroid Build Coastguard Worker# It calls the build.sh script which runs one build with setup environment
19*8b26181fSAndroid Build Coastguard Worker# variables: CC, CMAKE and REMOTE.
20*8b26181fSAndroid Build Coastguard Worker
21*8b26181fSAndroid Build Coastguard Worker. ./build_common.sh
22*8b26181fSAndroid Build Coastguard Workerprint_sysinfo
23*8b26181fSAndroid Build Coastguard Worker# Install directory prefix
24*8b26181fSAndroid Build Coastguard Workerif [ -z "$PREFIX" ]; then
25*8b26181fSAndroid Build Coastguard Worker    PREFIX=`mktempdir libpcap_build_matrix`
26*8b26181fSAndroid Build Coastguard Worker    echo "PREFIX set to '$PREFIX'"
27*8b26181fSAndroid Build Coastguard Worker    export PREFIX
28*8b26181fSAndroid Build Coastguard Workerfi
29*8b26181fSAndroid Build Coastguard WorkerCOUNT=0
30*8b26181fSAndroid Build Coastguard Workerexport LIBPCAP_TAINTED
31*8b26181fSAndroid Build Coastguard Workerif command -v valgrind >/dev/null 2>&1; then
32*8b26181fSAndroid Build Coastguard Worker    VALGRIND_CMD="valgrind --leak-check=full --error-exitcode=1"
33*8b26181fSAndroid Build Coastguard Worker    export VALGRIND_CMD
34*8b26181fSAndroid Build Coastguard Workerfi
35*8b26181fSAndroid Build Coastguard Worker
36*8b26181fSAndroid Build Coastguard Workertouch .devel configure
37*8b26181fSAndroid Build Coastguard Workerfor CC in $MATRIX_CC; do
38*8b26181fSAndroid Build Coastguard Worker    export CC
39*8b26181fSAndroid Build Coastguard Worker    discard_cc_cache
40*8b26181fSAndroid Build Coastguard Worker    if gcc_is_clang_in_disguise; then
41*8b26181fSAndroid Build Coastguard Worker        echo '(skipped)'
42*8b26181fSAndroid Build Coastguard Worker        continue
43*8b26181fSAndroid Build Coastguard Worker    fi
44*8b26181fSAndroid Build Coastguard Worker    for CMAKE in $MATRIX_CMAKE; do
45*8b26181fSAndroid Build Coastguard Worker        export CMAKE
46*8b26181fSAndroid Build Coastguard Worker        for REMOTE in $MATRIX_REMOTE; do
47*8b26181fSAndroid Build Coastguard Worker            export REMOTE
48*8b26181fSAndroid Build Coastguard Worker            COUNT=`increment $COUNT`
49*8b26181fSAndroid Build Coastguard Worker            echo_magenta "===== SETUP $COUNT: CC=$CC CMAKE=$CMAKE REMOTE=$REMOTE =====" >&2
50*8b26181fSAndroid Build Coastguard Worker            # Run one build with setup environment variables: CC, CMAKE and REMOTE
51*8b26181fSAndroid Build Coastguard Worker            run_after_echo ./build.sh
52*8b26181fSAndroid Build Coastguard Worker            echo 'Cleaning...'
53*8b26181fSAndroid Build Coastguard Worker            if [ "$CMAKE" = yes ]; then rm -rf build; else "$MAKE_BIN" distclean; fi
54*8b26181fSAndroid Build Coastguard Worker            purge_directory "$PREFIX"
55*8b26181fSAndroid Build Coastguard Worker            run_after_echo git status -suall
56*8b26181fSAndroid Build Coastguard Worker            # Cancel changes in configure
57*8b26181fSAndroid Build Coastguard Worker            run_after_echo git checkout configure
58*8b26181fSAndroid Build Coastguard Worker        done
59*8b26181fSAndroid Build Coastguard Worker    done
60*8b26181fSAndroid Build Coastguard Workerdone
61*8b26181fSAndroid Build Coastguard Workerrun_after_echo rm -rf "$PREFIX"
62*8b26181fSAndroid Build Coastguard Workerecho_magenta "Tested setup count: $COUNT" >&2
63*8b26181fSAndroid Build Coastguard Worker# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
64