name: C/C++ distribution
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: cxx-dist-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
cxx-dist:
runs-on: ubuntu-22.04
name: CMake + Meson + pkg-config (no cbindgen)
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install CMake, Meson, Ninja, pkg-config
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build pkg-config python3
python3 -m pip install meson
- name: Structural gate (no cbindgen required)
run: bash scripts/check-cxx-dist.sh
- name: Note cbindgen is unused
run: |
if command -v cbindgen >/dev/null 2>&1; then
echo "cbindgen is on PATH but this job must not invoke it"
else
echo "cbindgen: absent"
fi
- name: CMake FetchContent from this source tree
run: |
cmake -S tests/cmake-project -B build/cmake-fetch \
-DREADCON_CORE_SOURCE_DIR="$GITHUB_WORKSPACE" \
-DREADCON_CORE_USE_FETCHCONTENT=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build build/cmake-fetch --parallel
./build/cmake-fetch/c-main "$GITHUB_WORKSPACE/resources/test/tiny_multi_cuh2.con"
./build/cmake-fetch/c-main-static "$GITHUB_WORKSPACE/resources/test/tiny_multi_cuh2.con"
- name: CMake install + find_package + pkg-config
run: |
cmake -S . -B build/core-prefix \
-DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/prefix" \
-DCMAKE_BUILD_TYPE=Release
cmake --build build/core-prefix --parallel
cmake --install build/core-prefix
test -f prefix/include/readcon-core.h
test -f prefix/include/readcon-core.hpp
test -f prefix/lib/pkgconfig/readcon-core.pc
test -f prefix/lib/cmake/readcon-core/readcon-core-config.cmake
PKG_CONFIG_PATH="$GITHUB_WORKSPACE/prefix/lib/pkgconfig" \
pkg-config --exists --print-errors readcon-core
PKG_CONFIG_PATH="$GITHUB_WORKSPACE/prefix/lib/pkgconfig" \
pkg-config --libs readcon-core | grep -q readcon_core
cmake -S tests/cmake-project -B build/cmake-find \
-DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/prefix"
cmake --build build/cmake-find --parallel
./build/cmake-find/c-main "$GITHUB_WORKSPACE/resources/test/tiny_multi_cuh2.con"
- name: Meson setup + install (no cbindgen)
run: |
meson setup build/meson-dist \
--prefix="$GITHUB_WORKSPACE/meson-prefix" \
--libdir=lib \
--buildtype=release
meson compile -C build/meson-dist
meson install -C build/meson-dist
test -f meson-prefix/include/readcon-core.h
test -f meson-prefix/lib/pkgconfig/readcon-core.pc
test ! -f meson-prefix/lib/pkgconfig/meson-readcon-core.pc
export PKG_CONFIG_PATH="$GITHUB_WORKSPACE/meson-prefix/lib/pkgconfig"
pkg-config --exists --print-errors readcon-core
meson setup tests/meson-wrap build/meson-wrap --buildtype=release
meson compile -C build/meson-wrap
./build/meson-wrap/c-main
- name: cxx tarball FetchContent (file:// URL)
run: |
mkdir -p /tmp/cxx-out
bash scripts/package-cxx.sh /tmp/cxx-out
TAR=$(ls /tmp/cxx-out/readcon-core-cxx-*.tar.gz | grep -v vendor | head -1)
tar -tzf "$TAR" | grep -E 'include/readcon-core\.h$'
if tar -tzf "$TAR" | grep -E '(^|/)cbindgen(\.toml)?$'; then
echo "cxx tarball must not ship cbindgen.toml or a cbindgen binary" >&2
exit 1
fi
SHA=$(sha256sum "$TAR" | awk '{print $1}')
cmake -S tests/cmake-project -B build/cmake-tarball \
-DREADCON_CORE_FETCH_URL="$TAR" \
-DREADCON_CORE_FETCH_HASH="SHA256=${SHA}" \
-DCMAKE_BUILD_TYPE=Release
cmake --build build/cmake-tarball --parallel
./build/cmake-tarball/c-main "$GITHUB_WORKSPACE/resources/test/tiny_multi_cuh2.con"