Add the build_matrix.sh and build.sh scripts
Use them with Travis CI to build with less builders and save CI runtime.
This will currently run five builders: amd64, arm64, ppc64le, s390x and osx.
The build_matrix.sh script executes the matrix loops, exclude tests and
cleaning.
It conditionally builds libpcap running the build.sh script of libpcap.
It calls the build.sh script which runs one build with setup environment
variables: BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
(default: BUILD_LIBPCAP=no, REMOTE=no, CC=gcc, CMAKE=no, CRYPTO=no, SMB=no).
The matrix can be configured with environment variables
MATRIX_BUILD_LIBPCAP, MATRIX_REMOTE, MATRIX_CC, MATRIX_CMAKE, MATRIX_CRYPTO
and MATRIX_SMB
(default: MATRIX_BUILD_LIBPCAP='no yes', MATRIX_REMOTE='no yes',
MATRIX_CC='gcc clang', MATRIX_CMAKE='no yes', MATRIX_CRYPTO='no yes',
MATRIX_SMB='no yes').
These scripts can easily be updated to run new tests (32 bits builds,
sanitizers, coverage, etc).
They can be used locally for build tests or used with other CI systems.
Run examples:
./build_matrix.sh
MATRIX_BUILD_LIBPCAP=yes ./build_matrix.sh
MATRIX_CC=clang ./build_matrix.sh
CC=clang ./build.sh
CMAKE=yes ./build.sh
CC=clang CMAKE=yes CRYPTO=yes ./build.sh
Moreover:
Remove the old workaround PATH=$PATH...
Update the install directory prefix to /tmp/local.
Use vim modeline in the two shell scripts.
2021-02-07 18:22:24 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# This script runs one build with setup environment variables: BUILD_LIBPCAP,
|
2021-02-10 22:10:06 +08:00
|
|
|
# CC, CMAKE, CRYPTO and SMB
|
|
|
|
# (default: BUILD_LIBPCAP=no, CC=gcc, CMAKE=no, CRYPTO=no, SMB=no).
|
Add the build_matrix.sh and build.sh scripts
Use them with Travis CI to build with less builders and save CI runtime.
This will currently run five builders: amd64, arm64, ppc64le, s390x and osx.
The build_matrix.sh script executes the matrix loops, exclude tests and
cleaning.
It conditionally builds libpcap running the build.sh script of libpcap.
It calls the build.sh script which runs one build with setup environment
variables: BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
(default: BUILD_LIBPCAP=no, REMOTE=no, CC=gcc, CMAKE=no, CRYPTO=no, SMB=no).
The matrix can be configured with environment variables
MATRIX_BUILD_LIBPCAP, MATRIX_REMOTE, MATRIX_CC, MATRIX_CMAKE, MATRIX_CRYPTO
and MATRIX_SMB
(default: MATRIX_BUILD_LIBPCAP='no yes', MATRIX_REMOTE='no yes',
MATRIX_CC='gcc clang', MATRIX_CMAKE='no yes', MATRIX_CRYPTO='no yes',
MATRIX_SMB='no yes').
These scripts can easily be updated to run new tests (32 bits builds,
sanitizers, coverage, etc).
They can be used locally for build tests or used with other CI systems.
Run examples:
./build_matrix.sh
MATRIX_BUILD_LIBPCAP=yes ./build_matrix.sh
MATRIX_CC=clang ./build_matrix.sh
CC=clang ./build.sh
CMAKE=yes ./build.sh
CC=clang CMAKE=yes CRYPTO=yes ./build.sh
Moreover:
Remove the old workaround PATH=$PATH...
Update the install directory prefix to /tmp/local.
Use vim modeline in the two shell scripts.
2021-02-07 18:22:24 +08:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# BUILD_LIBPCAP: no or yes
|
|
|
|
BUILD_LIBPCAP=${BUILD_LIBPCAP:-no}
|
|
|
|
# CC: gcc or clang
|
|
|
|
CC=${CC:-gcc}
|
|
|
|
# CMAKE: no or yes
|
|
|
|
CMAKE=${CMAKE:-no}
|
|
|
|
# CRYPTO: no or yes
|
|
|
|
CRYPTO=${CRYPTO:-no}
|
|
|
|
# SMB: no or yes
|
|
|
|
SMB=${SMB:-no}
|
|
|
|
# Install directory prefix
|
|
|
|
PREFIX=/tmp/local
|
|
|
|
# For TESTrun
|
|
|
|
export TCPDUMP_BIN=/tmp/local/bin/tcpdump
|
|
|
|
|
|
|
|
travis_fold() {
|
|
|
|
local action="$1"
|
|
|
|
local name="$2"
|
|
|
|
if [ "$TRAVIS" != true ]; then return; fi
|
|
|
|
echo -ne "travis_fold:$action:$LABEL.script.$name\\r"
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Run a command after displaying it
|
|
|
|
run_after_echo() {
|
|
|
|
echo -n '$ '
|
|
|
|
echo "$@"
|
|
|
|
$@
|
|
|
|
}
|
|
|
|
|
|
|
|
# LABEL is needed to build the travis fold labels
|
2021-02-10 22:10:06 +08:00
|
|
|
LABEL="$BUILD_LIBPCAP.$CC.$CMAKE.$CRYPTO.$SMB"
|
Add the build_matrix.sh and build.sh scripts
Use them with Travis CI to build with less builders and save CI runtime.
This will currently run five builders: amd64, arm64, ppc64le, s390x and osx.
The build_matrix.sh script executes the matrix loops, exclude tests and
cleaning.
It conditionally builds libpcap running the build.sh script of libpcap.
It calls the build.sh script which runs one build with setup environment
variables: BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
(default: BUILD_LIBPCAP=no, REMOTE=no, CC=gcc, CMAKE=no, CRYPTO=no, SMB=no).
The matrix can be configured with environment variables
MATRIX_BUILD_LIBPCAP, MATRIX_REMOTE, MATRIX_CC, MATRIX_CMAKE, MATRIX_CRYPTO
and MATRIX_SMB
(default: MATRIX_BUILD_LIBPCAP='no yes', MATRIX_REMOTE='no yes',
MATRIX_CC='gcc clang', MATRIX_CMAKE='no yes', MATRIX_CRYPTO='no yes',
MATRIX_SMB='no yes').
These scripts can easily be updated to run new tests (32 bits builds,
sanitizers, coverage, etc).
They can be used locally for build tests or used with other CI systems.
Run examples:
./build_matrix.sh
MATRIX_BUILD_LIBPCAP=yes ./build_matrix.sh
MATRIX_CC=clang ./build_matrix.sh
CC=clang ./build.sh
CMAKE=yes ./build.sh
CC=clang CMAKE=yes CRYPTO=yes ./build.sh
Moreover:
Remove the old workaround PATH=$PATH...
Update the install directory prefix to /tmp/local.
Use vim modeline in the two shell scripts.
2021-02-07 18:22:24 +08:00
|
|
|
if [ "$CMAKE" = no ]; then
|
|
|
|
echo '$ ./configure [...]'
|
|
|
|
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
|
|
|
|
else
|
|
|
|
./configure --disable-local-libpcap --with-crypto="$CRYPTO" --enable-smb="$SMB" --prefix=$PREFIX
|
|
|
|
fi
|
|
|
|
travis_fold end configure
|
|
|
|
else
|
|
|
|
rm -rf build
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
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
|
|
|
|
else
|
|
|
|
cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" -DCMAKE_INSTALL_PREFIX=$PREFIX ..
|
|
|
|
fi
|
|
|
|
travis_fold end cmake
|
|
|
|
fi
|
|
|
|
run_after_echo "make -s clean"
|
|
|
|
run_after_echo "make -s CFLAGS=-Werror"
|
|
|
|
echo '$ make install'
|
|
|
|
travis_fold start make_install
|
|
|
|
make install
|
|
|
|
travis_fold end make_install
|
|
|
|
run_after_echo "$TCPDUMP_BIN --version"
|
|
|
|
run_after_echo "$TCPDUMP_BIN -h"
|
|
|
|
run_after_echo "$TCPDUMP_BIN -D"
|
|
|
|
system=$(uname -s)
|
|
|
|
if [ "$system" = Linux ]; then
|
|
|
|
run_after_echo "ldd $TCPDUMP_BIN"
|
|
|
|
fi
|
|
|
|
if [ "$TRAVIS" = true ]; then
|
|
|
|
if [ -n "$LD_LIBRARY_PATH" ]; then
|
|
|
|
run_after_echo "sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH $TCPDUMP_BIN -J"
|
|
|
|
run_after_echo "sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH $TCPDUMP_BIN -L"
|
|
|
|
else
|
|
|
|
run_after_echo "sudo $TCPDUMP_BIN -J"
|
|
|
|
run_after_echo "sudo $TCPDUMP_BIN -L"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "$BUILD_LIBPCAP" = yes ]; then
|
|
|
|
run_after_echo "make check"
|
|
|
|
fi
|
|
|
|
if [ "$CMAKE" = no ]; then
|
|
|
|
system=$(uname -s)
|
|
|
|
if [ "$system" = Darwin ] || [ "$system" = Linux ]; then
|
|
|
|
run_after_echo "make releasetar"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "$TRAVIS" = true ]; then
|
|
|
|
if [ "$TRAVIS_OS_NAME" = linux ] && [ "$TRAVIS_CPU_ARCH" != ppc64le ] && [ "$TRAVIS_CPU_ARCH" != s390x ] && [ "$TRAVIS_CPU_ARCH" != arm64 ]; then
|
|
|
|
if [ -n "$LD_LIBRARY_PATH" ]; then
|
|
|
|
run_after_echo "sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH $TCPDUMP_BIN -#n -c 10"
|
|
|
|
else
|
|
|
|
run_after_echo "sudo $TCPDUMP_BIN -#n -c 10"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# The DEBUG_BUILD variable is not set by default to avoid Travis error message:
|
|
|
|
# "The job exceeded the maximum log length, and has been terminated."
|
|
|
|
# Setting it needs to reduce the matrix cases.
|
|
|
|
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
|
|
|
|
travis_fold end cat_makefile
|
|
|
|
echo '$ cat config.h'
|
|
|
|
travis_fold start cat_config_h
|
|
|
|
cat config.h
|
|
|
|
travis_fold end cat_config_h
|
|
|
|
if [ "$CMAKE" = no ]; then
|
|
|
|
echo '$ cat config.log'
|
|
|
|
travis_fold start cat_config_log
|
|
|
|
cat config.log
|
|
|
|
travis_fold end cat_config_log
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
|