From: Denis Ovsienko Date: Sun, 21 Mar 2021 00:26:58 +0000 (+0000) Subject: CI: Refine the build matrix scripts. [skip appveyor] X-Git-Tag: tcpdump-4.99.1~44 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/b7c039fdd2b726fd2ef5b036423d9a481c4dbe4a CI: Refine the build matrix scripts. [skip appveyor] Reproduce the recent improvements made in tcpslice and libpcap. (cherry picked from commit 75e92bef0055f2c44eb19e0545b3f6501d0bd316) --- diff --git a/.cirrus.yml b/.cirrus.yml index af3c993a..97af62b4 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -23,7 +23,6 @@ freebsd_task: MAKEFLAGS: -j 4 MATRIX_CC: clang gcc10 script: - - freebsd-version - pkg install -qy git autoconf gcc10 - pkg install -qy bash cmake # for build_matrix.sh and build.sh - pkg install -qy pkgconf # for cmake, replaces pkg-config @@ -61,7 +60,6 @@ macos_task: # "cpu" and "memory" are invalid keywords for macOS tasks now env: MAKEFLAGS: '-j 12' - MATRIX_CC: clang # GCC is a symlink to Clang in macOS script: - brew update >/dev/null - brew install libsmi | grep -v '%' diff --git a/.travis.yml b/.travis.yml index 03262b5d..73d902ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,8 +44,6 @@ addons: - libpcap-dev script: - - uname -a - - date - gem install travis-conditions - apt list --installed 'lib*-dev' - (cd .. && echo '$ git clone [...] libpcap.git' && git clone --depth 3 --branch=master --quiet git://github.com/the-tcpdump-group/libpcap.git) diff --git a/build.sh b/build.sh index c237fe83..eae8765d 100755 --- a/build.sh +++ b/build.sh @@ -12,6 +12,9 @@ BUILD_LIBPCAP=${BUILD_LIBPCAP:-no} REMOTE=${REMOTE:-no} # CC: gcc or clang CC=${CC:-gcc} +# GCC and Clang recognize --version and print to stdout. Sun compilers +# recognize -V and print to stderr. +"$CC" --version 2>/dev/null || "$CC" -V || : # CMAKE: no or yes CMAKE=${CMAKE:-no} # CRYPTO: no or yes @@ -19,13 +22,16 @@ CRYPTO=${CRYPTO:-no} # SMB: no or yes SMB=${SMB:-no} # Install directory prefix -PREFIX=/tmp/local +if [ -z "$PREFIX" ]; then + PREFIX=$(mktemp -d -t tcpdump_build_XXXXXXXX) + echo "PREFIX set to '$PREFIX'" +fi # For TESTrun -export TCPDUMP_BIN=$PREFIX/bin/tcpdump +export TCPDUMP_BIN="$PREFIX/bin/tcpdump" travis_fold() { - local action="$1" - local name="$2" + local action=${1:?} + local name=${2:?} if [ "$TRAVIS" != true ]; then return; fi echo -ne "travis_fold:$action:$LABEL.script.$name\\r" sleep 1 @@ -45,10 +51,10 @@ if [ "$CMAKE" = no ]; then travis_fold start configure if [ "$BUILD_LIBPCAP" = yes ]; then echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH" - ./configure --with-crypto="$CRYPTO" --enable-smb="$SMB" --prefix=$PREFIX - export LD_LIBRARY_PATH=$PREFIX/lib + ./configure --with-crypto="$CRYPTO" --enable-smb="$SMB" --prefix="$PREFIX" + export LD_LIBRARY_PATH="$PREFIX/lib" else - ./configure --disable-local-libpcap --with-crypto="$CRYPTO" --enable-smb="$SMB" --prefix=$PREFIX + ./configure --disable-local-libpcap --with-crypto="$CRYPTO" --enable-smb="$SMB" --prefix="$PREFIX" fi travis_fold end configure else @@ -58,10 +64,10 @@ else echo '$ cmake [...]' travis_fold start cmake if [ "$BUILD_LIBPCAP" = yes ]; then - cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=$PREFIX .. - export LD_LIBRARY_PATH=$PREFIX/lib + cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" -DCMAKE_PREFIX_PATH="$PREFIX" -DCMAKE_INSTALL_PREFIX="$PREFIX" .. + export LD_LIBRARY_PATH="$PREFIX/lib" else - cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" -DCMAKE_INSTALL_PREFIX=$PREFIX .. + cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" -DCMAKE_INSTALL_PREFIX="$PREFIX" .. fi travis_fold end cmake fi @@ -111,11 +117,7 @@ fi if [ "$TRAVIS" = true ] && [ -n "$DEBUG_BUILD" ] ; then echo '$ cat Makefile [...]' travis_fold start cat_makefile - if [ "$CMAKE" = no ]; then - sed -n '1,/DO NOT DELETE THIS LINE -- mkdep uses it/p' < Makefile - else - cat Makefile - fi + sed '/DO NOT DELETE THIS LINE -- mkdep uses it/q' < Makefile travis_fold end cat_makefile echo '$ cat config.h' travis_fold start cat_config_h @@ -128,4 +130,7 @@ if [ "$TRAVIS" = true ] && [ -n "$DEBUG_BUILD" ] ; then travis_fold end cat_config_log fi fi +if [ "$DELETE_PREFIX" = yes ]; then + rm -rf "$PREFIX" +fi # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent : diff --git a/build_matrix.sh b/build_matrix.sh index 2be11f03..44cd06ff 100755 --- a/build_matrix.sh +++ b/build_matrix.sh @@ -16,13 +16,19 @@ set -e # ANSI color escape sequences ANSI_MAGENTA="\\033[35;1m" ANSI_RESET="\\033[0m" +uname -a +date # Install directory prefix -PREFIX=/tmp/local +if [ -z "$PREFIX" ]; then + PREFIX=$(mktemp -d -t tcpdump_build_matrix_XXXXXXXX) + echo "PREFIX set to '$PREFIX'" + export PREFIX +fi COUNT=0 travis_fold() { - local action="$1" - local name="$2" + local action=${1:?} + local name=${2:?} if [ "$TRAVIS" != true ]; then return; fi echo -ne "travis_fold:$action:$LABEL.script.$name\\r" sleep 1 @@ -38,8 +44,11 @@ echo_magenta() { build_tcpdump() { for CC in ${MATRIX_CC:-gcc clang}; do export CC - # Exclude gcc on OSX (it is just an alias for clang) - if [ "$CC" = gcc ] && [ "$TRAVIS_OS_NAME" = osx ]; then continue; fi + # Exclude gcc on macOS (it is just an alias for clang). + if [ "$CC" = gcc ] && [ "$(uname -s)" = Darwin ]; then + echo '(skipped)' + continue + fi for CMAKE in ${MATRIX_CMAKE:-no yes}; do export CMAKE for CRYPTO in ${MATRIX_CRYPTO:-no yes}; do @@ -56,7 +65,7 @@ build_tcpdump() { echo 'Cleaning...' travis_fold start cleaning if [ "$CMAKE" = yes ]; then rm -rf build; else make distclean; fi - rm -rf $PREFIX/bin/tcpdump* + rm -rf "$PREFIX"/bin/tcpdump* git status -suall # Cancel changes in configure git checkout configure @@ -70,7 +79,7 @@ build_tcpdump() { choose_libpcap() { if [ "$BUILD_LIBPCAP" = no ]; then echo_magenta 'Use system libpcap' - rm -rf $PREFIX + rm -rf "$PREFIX"/* make -C ../libpcap distclean || : else # Build libpcap with autoconf @@ -91,7 +100,7 @@ export BUILD_LIBPCAP choose_libpcap # Set PKG_CONFIG_PATH for configure when building libpcap if [ "$CMAKE" != no ]; then - export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig + export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" fi build_tcpdump done @@ -101,6 +110,6 @@ export BUILD_LIBPCAP fi done -rm -rf $PREFIX +rm -rf "$PREFIX" echo_magenta "Tested setup count: $COUNT" # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :