chore: Unify build configuration script into one
Earlier ci/meson-build.sh and ci/ci-build.sh. The latter we then renamed to the more descriptive build-configuration-matrix.sh. Both scripts are doing the same thing but for different build systems. So lets merge them together. Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -36,13 +36,13 @@ jobs:
|
||||
buildsystem: meson
|
||||
tests: unit
|
||||
omemo: signal
|
||||
script: ./ci/ci-meson-build.sh
|
||||
script: ./scripts/build-configuration-matrix.sh meson
|
||||
omemo_env: libsignal
|
||||
- flavor: debian
|
||||
buildsystem: meson
|
||||
tests: unit
|
||||
omemo: libomemo
|
||||
script: ./ci/ci-meson-build.sh
|
||||
script: ./scripts/build-configuration-matrix.sh meson
|
||||
omemo_env: libomemo-c
|
||||
|
||||
name: ${{ matrix.flavor }} | ${{ matrix.buildsystem }} | ${{ matrix.tests }} | ${{ matrix.omemo }}
|
||||
|
||||
@@ -214,7 +214,7 @@ In cases where you want to disable automatic formatting for a specific block of
|
||||
## Verification & Testing
|
||||
|
||||
### Running unit tests
|
||||
Run `make check` to run the unit tests with your current configuration or `./scripts/build-configuration-matrix.sh` to check with different switches passed to configure.
|
||||
Run `make check` to run the unit tests with your current configuration or `./scripts/build-configuration-matrix.sh [autotools|meson]` to check with different switches passed to configure.
|
||||
|
||||
### Writing unit tests
|
||||
We use the [cmocka](https://cmocka.org/) testing framework for unit tests.
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
error_handler()
|
||||
{
|
||||
ERR_CODE=$?
|
||||
echo
|
||||
echo "Error ${ERR_CODE} with command '${BASH_COMMAND}' on line ${BASH_LINENO[0]}. Exiting."
|
||||
# Meson logs are stored in the build directory
|
||||
for log in build_run/meson-logs/testlog.txt build_valgrind/meson-logs/testlog.txt; do
|
||||
if [ -f "$log" ]; then
|
||||
echo "--- Meson Test Log ($log) ---"
|
||||
cat "$log"
|
||||
fi
|
||||
done
|
||||
exit ${ERR_CODE}
|
||||
}
|
||||
|
||||
trap error_handler ERR
|
||||
|
||||
tests=(
|
||||
"-Dnotifications=enabled -Dicons-and-clipboard=enabled -Dotr=enabled -Dpgp=enabled -Domemo=enabled -Dc-plugins=enabled -Dpython-plugins=enabled -Dxscreensaver=enabled -Domemo-qrcode=enabled -Dgdk-pixbuf=enabled"
|
||||
""
|
||||
"-Dnotifications=disabled"
|
||||
"-Dicons-and-clipboard=disabled"
|
||||
"-Dotr=disabled"
|
||||
"-Dpgp=disabled"
|
||||
"-Domemo=disabled -Domemo-qrcode=disabled"
|
||||
"-Dpgp=disabled -Dotr=disabled"
|
||||
"-Dpgp=disabled -Dotr=disabled -Domemo=disabled"
|
||||
"-Dpython-plugins=disabled"
|
||||
"-Dc-plugins=disabled"
|
||||
"-Dc-plugins=disabled -Dpython-plugins=disabled"
|
||||
"-Dxscreensaver=disabled"
|
||||
"-Dgdk-pixbuf=disabled"
|
||||
)
|
||||
|
||||
BACKEND_OPT=""
|
||||
if [ -n "${OMEMO_BACKEND}" ]; then
|
||||
BACKEND_OPT="-Domemo-backend=${OMEMO_BACKEND}"
|
||||
fi
|
||||
|
||||
# Run Valgrind check (Only on Linux, on first/full feature set)
|
||||
if [[ "$(uname | tr '[:upper:]' '[:lower:]')" == linux* ]]; then
|
||||
echo "--> Running Valgrind check with full features ${BACKEND_OPT}"
|
||||
|
||||
meson setup build_valgrind ${tests[0]} ${BACKEND_OPT} -Dtests=true -Db_sanitize=address,undefined
|
||||
meson compile -C build_valgrind
|
||||
|
||||
meson test -C build_valgrind "unit tests" --print-errorlogs --wrap=valgrind || echo "Valgrind issues detected"
|
||||
|
||||
rm -rf build_valgrind
|
||||
fi
|
||||
|
||||
# Iterate through all feature combinations
|
||||
for features in "${tests[@]}"
|
||||
do
|
||||
echo "----------------------------------------------------"
|
||||
echo "--> Building with: ${features} ${BACKEND_OPT}"
|
||||
echo "----------------------------------------------------"
|
||||
|
||||
rm -rf build_run
|
||||
|
||||
meson setup build_run ${features} ${BACKEND_OPT} -Dtests=true
|
||||
meson compile -C build_run
|
||||
|
||||
meson test -C build_run "unit tests" --print-errorlogs
|
||||
|
||||
./build_run/profanity -v
|
||||
done
|
||||
@@ -14,10 +14,11 @@ Central validation script mainly for local development.
|
||||
- `--install`: Install the script as a git `pre-commit` hook.
|
||||
|
||||
## `build-configuration-matrix.sh`
|
||||
Exhaustive build configuration matrix testing. It ensures that Profanity compiles and passes unit tests across a variety of feature configurations.
|
||||
Exhaustive build configuration matrix testing. It ensures that Profanity compiles and passes unit tests across a variety of feature configurations for both Autotools and Meson.
|
||||
|
||||
- **Purpose:** Verifies architectural compatibility by testing many combinations of build flags.
|
||||
- **Usage:** `./scripts/build-configuration-matrix.sh`
|
||||
- **Usage:** `./scripts/build-configuration-matrix.sh [autotools|meson] [extra-args]`
|
||||
- **Extra Arguments:** Any arguments passed after the build system are forwarded directly to the configuration command (`./configure` or `meson setup`).
|
||||
- **Environment:** Primarily used in CI (GitHub Actions), but can be run locally to verify all configurations.
|
||||
|
||||
## `changelog-helper.py`
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Exhaustive build configuration matrix testing for Profanity
|
||||
# Supports both Autotools and Meson
|
||||
|
||||
log_content()
|
||||
{
|
||||
set -e
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_content() {
|
||||
echo
|
||||
if [ -f "$1" ]; then
|
||||
echo "Content of $1:"
|
||||
@@ -13,144 +20,184 @@ log_content()
|
||||
fi
|
||||
}
|
||||
|
||||
error_handler()
|
||||
{
|
||||
error_handler() {
|
||||
ERR_CODE=$?
|
||||
echo -e "${RED}Error ${ERR_CODE} with command '${BASH_COMMAND}' on line ${BASH_LINENO[0]}. Exiting.${NC}"
|
||||
|
||||
log_content ./config.log
|
||||
log_content ./test-suite.log
|
||||
log_content ./test-suite-memcheck.log
|
||||
|
||||
echo
|
||||
echo "Error ${ERR_CODE} with command '${BASH_COMMAND}' on line ${BASH_LINENO[0]}. Exiting."
|
||||
echo
|
||||
if [ "$BUILD_SYSTEM" == "autotools" ]; then
|
||||
log_content ./config.log
|
||||
log_content ./test-suite.log
|
||||
log_content ./test-suite-memcheck.log
|
||||
else
|
||||
for log in build_run/meson-logs/testlog.txt build_valgrind/meson-logs/testlog.txt; do
|
||||
if [ -f "$log" ]; then
|
||||
echo "--- Meson Test Log ($log) ---"
|
||||
cat "$log"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
exit ${ERR_CODE}
|
||||
}
|
||||
|
||||
trap error_handler ERR
|
||||
|
||||
num_cores()
|
||||
{
|
||||
# Check for cores, for systems with:
|
||||
# Line 1. Linux w/ coreutils, or...
|
||||
# Line 2. OpenBSD, FreeBSD, NetBSD or macOS, or...
|
||||
# Line 3. Fallback for Linux w/o coreutils (glibc).
|
||||
num_cores() {
|
||||
nproc \
|
||||
|| sysctl -n hw.ncpu \
|
||||
|| getconf _NPROCESSORS_ONLN 2>/dev/null
|
||||
|| getconf _NPROCESSORS_ONLN 2>/dev/null \
|
||||
|| echo 2
|
||||
}
|
||||
|
||||
./bootstrap.sh
|
||||
usage() {
|
||||
echo "Usage: $0 [autotools|meson] [extra-args]"
|
||||
echo ""
|
||||
echo "Run exhaustive build matrix tests for the specified build system."
|
||||
echo "Default build system is 'autotools'."
|
||||
echo ""
|
||||
echo "Extra arguments are passed directly to the configuration command:"
|
||||
echo " - Autotools: ./configure [extra-args]"
|
||||
echo " - Meson: meson setup [extra-args]"
|
||||
exit 0
|
||||
}
|
||||
|
||||
tests=()
|
||||
MAKE="make --quiet -j$(num_cores)"
|
||||
CC="gcc"
|
||||
# Determine build system
|
||||
BUILD_SYSTEM="autotools"
|
||||
if [[ "$1" == "autotools" || "$1" == "meson" ]]; then
|
||||
BUILD_SYSTEM="$1"
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
ARCH="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||
EXTRA_ARGS="$*"
|
||||
|
||||
case "$ARCH" in
|
||||
linux*)
|
||||
tests=(
|
||||
"--enable-notifications --enable-icons-and-clipboard --enable-otr --enable-pgp
|
||||
--enable-omemo --enable-plugins --enable-c-plugins
|
||||
--enable-python-plugins --with-xscreensaver --enable-omemo-qrcode --enable-gdk-pixbuf"
|
||||
"--disable-notifications --disable-icons-and-clipboard --disable-otr --disable-pgp
|
||||
--disable-omemo --disable-plugins --disable-c-plugins
|
||||
--disable-python-plugins --without-xscreensaver"
|
||||
"--disable-notifications"
|
||||
"--disable-icons-and-clipboard"
|
||||
"--disable-otr"
|
||||
"--disable-pgp"
|
||||
"--disable-omemo --disable-omemo-qrcode"
|
||||
"--disable-pgp --disable-otr"
|
||||
"--disable-pgp --disable-otr --disable-omemo"
|
||||
"--disable-plugins"
|
||||
"--disable-python-plugins"
|
||||
"--disable-c-plugins"
|
||||
"--disable-c-plugins --disable-python-plugins"
|
||||
"--without-xscreensaver"
|
||||
"--disable-gdk-pixbuf"
|
||||
"")
|
||||
source /etc/profile.d/debuginfod.sh 2>/dev/null || true
|
||||
;;
|
||||
darwin*)
|
||||
tests=(
|
||||
"--enable-notifications --enable-icons-and-clipboard --enable-otr --enable-pgp
|
||||
--enable-omemo --enable-plugins --enable-c-plugins
|
||||
--enable-python-plugins"
|
||||
"--disable-notifications --disable-icons-and-clipboard --disable-otr --disable-pgp
|
||||
--disable-omemo --disable-plugins --disable-c-plugins
|
||||
--disable-python-plugins"
|
||||
"--disable-notifications"
|
||||
"--disable-icons-and-clipboard"
|
||||
"--disable-otr"
|
||||
"--disable-pgp"
|
||||
"--disable-omemo"
|
||||
"--disable-pgp --disable-otr"
|
||||
"--disable-pgp --disable-otr --disable-omemo"
|
||||
"--disable-plugins"
|
||||
"--disable-python-plugins"
|
||||
"--disable-c-plugins"
|
||||
"--disable-c-plugins --disable-python-plugins"
|
||||
"")
|
||||
;;
|
||||
openbsd*)
|
||||
MAKE="gmake"
|
||||
# TODO(#1231):
|
||||
# `-std=gnu99 -fexec-charset=UTF-8` to silence:
|
||||
# src/event/server_events.c:1453:19: error: universal character names are only valid in C++ and C99
|
||||
# src/event/server_events.c:1454:19: error: universal character names are only valid in C++ and C99
|
||||
CC="egcc -std=gnu99 -fexec-charset=UTF-8"
|
||||
if [ "$BUILD_SYSTEM" == "autotools" ]; then
|
||||
echo -e "${YELLOW}---> Starting Autotools build matrix...${NC}"
|
||||
./bootstrap.sh
|
||||
|
||||
tests=(
|
||||
"--enable-notifications --enable-icons-and-clipboard --enable-otr --enable-pgp
|
||||
--enable-omemo --enable-plugins --enable-c-plugins
|
||||
--enable-python-plugins"
|
||||
"--disable-notifications --disable-icons-and-clipboard --disable-otr --disable-pgp
|
||||
--disable-omemo --disable-plugins --disable-c-plugins
|
||||
--disable-python-plugins"
|
||||
"--disable-notifications"
|
||||
"--disable-icons-and-clipboard"
|
||||
"--disable-otr"
|
||||
"--disable-pgp"
|
||||
"--disable-omemo"
|
||||
"--disable-pgp --disable-otr"
|
||||
"--disable-pgp --disable-otr --disable-omemo"
|
||||
"--disable-plugins"
|
||||
"--disable-python-plugins"
|
||||
"--disable-c-plugins"
|
||||
"--disable-c-plugins --disable-python-plugins"
|
||||
"")
|
||||
;;
|
||||
esac
|
||||
MAKE="make --quiet -j$(num_cores)"
|
||||
CC="gcc"
|
||||
|
||||
case "$ARCH" in
|
||||
linux*)
|
||||
echo
|
||||
echo "--> Building with ./configure ${tests[0]} --enable-valgrind --disable-functional-tests $*"
|
||||
echo
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
./configure ${tests[0]} --enable-valgrind --disable-functional-tests $*
|
||||
case "$ARCH" in
|
||||
linux*)
|
||||
tests=(
|
||||
"--enable-notifications --enable-icons-and-clipboard --enable-otr --enable-pgp
|
||||
--enable-omemo --enable-plugins --enable-c-plugins
|
||||
--enable-python-plugins --with-xscreensaver --enable-omemo-qrcode --enable-gdk-pixbuf"
|
||||
"--disable-notifications --disable-icons-and-clipboard --disable-otr --disable-pgp
|
||||
--disable-omemo --disable-plugins --disable-c-plugins
|
||||
--disable-python-plugins --without-xscreensaver"
|
||||
"--disable-notifications"
|
||||
"--disable-icons-and-clipboard"
|
||||
"--disable-otr"
|
||||
"--disable-pgp"
|
||||
"--disable-omemo --disable-omemo-qrcode"
|
||||
"--disable-pgp --disable-otr"
|
||||
"--disable-pgp --disable-otr --disable-omemo"
|
||||
"--disable-plugins"
|
||||
"--disable-python-plugins"
|
||||
"--disable-c-plugins"
|
||||
"--disable-c-plugins --disable-python-plugins"
|
||||
"--without-xscreensaver"
|
||||
"--disable-gdk-pixbuf"
|
||||
"")
|
||||
source /etc/profile.d/debuginfod.sh 2>/dev/null || true
|
||||
;;
|
||||
*)
|
||||
# Darwin, OpenBSD, etc.
|
||||
if [ "$ARCH" == "openbsd*" ]; then
|
||||
MAKE="gmake"
|
||||
CC="egcc -std=gnu99 -fexec-charset=UTF-8"
|
||||
fi
|
||||
tests=(
|
||||
"--enable-notifications --enable-icons-and-clipboard --enable-otr --enable-pgp
|
||||
--enable-omemo --enable-plugins --enable-c-plugins
|
||||
--enable-python-plugins"
|
||||
"--disable-notifications --disable-icons-and-clipboard --disable-otr --disable-pgp
|
||||
--disable-omemo --disable-plugins --disable-c-plugins
|
||||
--disable-python-plugins"
|
||||
"--disable-notifications"
|
||||
"--disable-icons-and-clipboard"
|
||||
"--disable-otr"
|
||||
"--disable-pgp"
|
||||
"--disable-omemo"
|
||||
"--disable-pgp --disable-otr"
|
||||
"--disable-pgp --disable-otr --disable-omemo"
|
||||
"--disable-plugins"
|
||||
"--disable-python-plugins"
|
||||
"--disable-c-plugins"
|
||||
"--disable-c-plugins --disable-python-plugins"
|
||||
"")
|
||||
;;
|
||||
esac
|
||||
|
||||
# Valgrind check (Linux only)
|
||||
if [[ "$ARCH" == linux* ]]; then
|
||||
echo -e "${YELLOW}--> Building with ./configure ${tests[0]} --enable-valgrind --disable-functional-tests ${EXTRA_ARGS}${NC}"
|
||||
./configure ${tests[0]} --enable-valgrind --disable-functional-tests ${EXTRA_ARGS}
|
||||
$MAKE CC="${CC}"
|
||||
$MAKE check-valgrind
|
||||
$MAKE distclean
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for features in "${tests[@]}"
|
||||
do
|
||||
echo
|
||||
echo "--> Building with ./configure ${features} --disable-functional-tests $*"
|
||||
echo
|
||||
for features in "${tests[@]}"
|
||||
do
|
||||
echo -e "${YELLOW}--> Building with ./configure ${features} --disable-functional-tests ${EXTRA_ARGS}${NC}"
|
||||
./configure $features --disable-functional-tests ${EXTRA_ARGS}
|
||||
$MAKE CC="${CC}"
|
||||
$MAKE check-unit
|
||||
./profanity -v
|
||||
$MAKE clean
|
||||
done
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
./configure $features --disable-functional-tests $*
|
||||
else
|
||||
# Meson Build Matrix
|
||||
echo -e "${YELLOW}---> Starting Meson build matrix...${NC}"
|
||||
|
||||
$MAKE CC="${CC}"
|
||||
$MAKE check-unit
|
||||
tests=(
|
||||
"-Dnotifications=enabled -Dicons-and-clipboard=enabled -Dotr=enabled -Dpgp=enabled -Domemo=enabled -Dc-plugins=enabled -Dpython-plugins=enabled -Dxscreensaver=enabled -Domemo-qrcode=enabled -Dgdk-pixbuf=enabled"
|
||||
""
|
||||
"-Dnotifications=disabled"
|
||||
"-Dicons-and-clipboard=disabled"
|
||||
"-Dotr=disabled"
|
||||
"-Dpgp=disabled"
|
||||
"-Domemo=disabled -Domemo-qrcode=disabled"
|
||||
"-Dpgp=disabled -Dotr=disabled"
|
||||
"-Dpgp=disabled -Dotr=disabled -Domemo=disabled"
|
||||
"-Dpython-plugins=disabled"
|
||||
"-Dc-plugins=disabled"
|
||||
"-Dc-plugins=disabled -Dpython-plugins=disabled"
|
||||
"-Dxscreensaver=disabled"
|
||||
"-Dgdk-pixbuf=disabled"
|
||||
)
|
||||
|
||||
./profanity -v
|
||||
$MAKE clean
|
||||
done
|
||||
BACKEND_OPT=""
|
||||
if [ -n "${OMEMO_BACKEND}" ]; then
|
||||
BACKEND_OPT="-Domemo-backend=${OMEMO_BACKEND}"
|
||||
fi
|
||||
|
||||
# Valgrind check (Linux only)
|
||||
if [[ "$ARCH" == linux* ]]; then
|
||||
echo -e "${YELLOW}--> Running Valgrind check with full features ${BACKEND_OPT} ${EXTRA_ARGS}${NC}"
|
||||
rm -rf build_valgrind
|
||||
meson setup build_valgrind ${tests[0]} ${BACKEND_OPT} -Dtests=true -Db_sanitize=address,undefined ${EXTRA_ARGS}
|
||||
meson compile -C build_valgrind
|
||||
meson test -C build_valgrind "unit tests" --print-errorlogs --wrap=valgrind || echo "Valgrind issues detected"
|
||||
rm -rf build_valgrind
|
||||
fi
|
||||
|
||||
for features in "${tests[@]}"
|
||||
do
|
||||
echo -e "${YELLOW}--> Building with: ${features} ${BACKEND_OPT} ${EXTRA_ARGS}${NC}"
|
||||
rm -rf build_run
|
||||
meson setup build_run ${features} ${BACKEND_OPT} -Dtests=true ${EXTRA_ARGS}
|
||||
meson compile -C build_run
|
||||
meson test -C build_run "unit tests" --print-errorlogs
|
||||
./build_run/profanity -v
|
||||
done
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Build configuration matrix testing successful!${NC}"
|
||||
|
||||
Reference in New Issue
Block a user