Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

macOS

macOS #1963

Workflow file for this run

name: macOS
on:
pull_request:
push:
schedule:
- cron: '00 21 * * *'
jobs:
general:
strategy:
matrix:
version: [latest, 14]
build-tool: [autotools, cmake]
cc: [gcc, clang]
fail-fast: false
runs-on: macOS-${{ matrix.version }}
steps:
- name: Checkout syslog-ng source
uses: actions/checkout@v3
- name: Set xcode version
if: matrix.version == 14
run: |
sudo xcode-select -s /Applications/Xcode_15.2.app
- name: Hack around SDK version
# FIXME: (Temporary?!) gcc/macOS SDK/autotools issue workaround
#
# __has_extension cannot be compiled
#
# This is a triple issue
#
# - gcc version lower than 14 doe snot know __has_extension (https://github.com/orgs/Homebrew/discussions/5216)
# - xcode 15.3 with macOS SDK 14.4 and older is uses __has_extension
# - autotools ignores the xcode-select -s selected SDK, and
# - wants to use the command line version in some cases
# - the command line version is using /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/ that
# - is a symlink to MacOSX14.4.sdk (that is belonging to xcode 15.3), and
# - 14.4.sdk definitly will not be compiled gcc version < 14 now
#
# The goal was here not adding a new, hopefully temporally syslog-ng build modification/workaround in the source
# Possible solutions I could find so far
# 1. trivial solution could be to define __has_extension to do nothing, like -D__has_extension(x)=0, but it had several issues using utotools again, see bellow in set ENV step
# 2. hacking around the SDK usage, to force use an earlier SDK than 14.4 (the one that really belongs to the given xcode version)
#
# Stayed with the 2nd one, here bellow
#
if: matrix.version == 14 && matrix.cc == 'gcc'
run: |
ls -Al /Library/Developer/CommandLineTools/SDKs/
sudo rm -f /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
sudo rm -f /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
sudo ln -s /Applications/Xcode_15.2.app//Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
sudo ln -s /Applications/Xcode_15.2.app//Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
ls -Al /Library/Developer/CommandLineTools/SDKs/
- name: Unlinking preinstalled Python (workaround)
# The python@3 brew package has to be installed and linked system-wide (it's a dependency of glib and syslog-ng)
# The macos-latest GitHub runner has Python preinstalled as a pkg, this prevents linking the python@3
# brew package, even when linking is forced. `brew "python@3", link: true, force: true`
# also, brew cannot update the links even these cretated by itself for an earlier python version
run : |
find /usr/local/bin/ -lname "*Python.framework*" -delete
- name: Install dependencies
run: |
brew update --preinstall
brew bundle --file=contrib/Brewfile
- name: Set ENV variables
run: |
. .github/workflows/gh-tools.sh
HOMEBREW_PREFIX="$(brew --prefix)"
PYTHONUSERBASE="${HOME}/python_packages"
CC="${{ matrix.cc }}"
CXX=`[ $CC = gcc ] && echo g++ || echo clang++`
PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig:${HOMEBREW_PREFIX}/opt/net-snmp/lib/pkgconfig:${HOMEBREW_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
CFLAGS="-I${HOMEBREW_PREFIX}/include/"
# FIXME: This sould work as well as a workaround for the above mentioned issue, but is not help either actually, as autoools cannot handle this CFLAGS construct, none of the tried form has worked
# - escaped versions fail immediately at configure compiler probing phase
# - none escaped version failes at compile time, as () must be escaped
#
#if [ "$CC" = "gcc" ] && [ "$(arch)" = "arm64" ]; then
# CFLAGS="${CFLAGS} -D__has_extension\(x\)=0" # -D\"__has_extension(x)=0\" -D__has_extension(x)=0
#fi
LDFLAGS="-L${HOMEBREW_PREFIX}/lib"
THREADS="$(sysctl -n hw.physicalcpu)"
CONFIGURE_FLAGS="
`[ $CC = clang ] && echo '--enable-force-gnu99' || true`
--prefix=${SYSLOG_NG_INSTALL_DIR}
--enable-all-modules
--enable-tests
--with-ivykis=system
--with-python=3
--with-systemd-journal=no
--disable-smtp
--disable-grpc
--disable-java
--disable-java-modules
--disable-mqtt
--disable-pacct
"
CMAKE_CONFIGURE_FLAGS="
-DCMAKE_BUILD_TYPE=Debug
-DSUMMARY_VERBOSE=ON
-DBUILD_TESTING=ON
-DIVYKIS_SOURCE=system
-DPYTHON_VERSION=3
-DENABLE_JOURNALD=OFF
-DENABLE_AFSMTP=OFF
-DENABLE_GRPC=OFF
-DENABLE_JAVA=OFF
-DENABLE_JAVA_MODULES=OFF
-DENABLE_MQTT=OFF
-DENABLE_PACCT=OFF
"
PATH="${HOMEBREW_PREFIX}/opt/bison/bin:${HOMEBREW_PREFIX}/opt/libnet/bin:${HOMEBREW_PREFIX}/opt/net-snmp/bin:${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:${PYTHONUSERBASE}/bin:${PATH}"
gh_export HOMEBREW_PREFIX PYTHONUSERBASE CC CXX PKG_CONFIG_PATH THREADS CONFIGURE_FLAGS CFLAGS LDFLAGS CMAKE_CONFIGURE_FLAGS PATH
gh_path "${PATH}"
ln -s "${HOMEBREW_PREFIX}/bin/gcc-11" "${HOMEBREW_PREFIX}/bin/gcc"
ln -s "${HOMEBREW_PREFIX}/bin/g++-11" "${HOMEBREW_PREFIX}/bin/g++"
echo "ARCH: " $(arch)
echo "xcode:" $(xcode-select -p)
env | sort
- name: autogen.sh
if: matrix.build-tool == 'autotools'
run: |
./autogen.sh
- name: configure
if: matrix.build-tool == 'autotools'
run: |
./configure ${CONFIGURE_FLAGS}
- name: cmake configure
if: matrix.build-tool == 'cmake'
run: |
mkdir build
# If you know the valid syntax to provide the quoted string for -DCMAKE_C_FLAGS inplace in CMAKE_CONFIGURE_FLAGS above (in Set ENV variables step) instead of this hack, please contribute!
#
# TODO: -Wall must be replaced here with -Werror but now multiple warnings could occure in several modules that needs to be corrected first
#
cmake --install-prefix "${HOME}/install/syslog-ng" -B build . -DCMAKE_C_FLAGS="-Wall ${CFLAGS}" ${CMAKE_CONFIGURE_FLAGS}
- name: cmake install
if: matrix.build-tool == 'cmake'
run: |
cmake --build ./build -j ${THREADS} --target install
- name: cmake check
# FIXME: Some of our checks still do not run correctly on silicon yet (and probably never will)
if: matrix.build-tool == 'cmake' && matrix.version != 14
run: |
cmake --build ./build -j ${THREADS} --target check
- name: make
if: matrix.build-tool == 'autotools'
run: |
set -e
make --keep-going -j ${THREADS} || \
{ \
S=$?; \
make V=1; \
return $S; \
}
- name: make check
# FIXME: Some of our checks still do not run correctly on silicon yet (and probably never will)
if: matrix.build-tool == 'autotools' && matrix.version != 14
run: |
set -e
make --keep-going check -j ${THREADS} || \
{ \
S=$?; \
echo "Output of first test invocation:"; \
find . -name test-suite.log | xargs cat; \
make V=1 check; \
echo "Output of second test invocation:"; \
find . -name test-suite.log | xargs cat; \
return $S; \
}