Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 131 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install ninja
run: sudo apt-get update -q && sudo apt-get install -y ninja-build
- uses: astral-sh/setup-uv@v10.1.0

- name: Install meson
run: pip install meson
- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

- name: Configure (debug + sanitizers)
run: >
Expand Down Expand Up @@ -86,15 +81,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install ninja
run: sudo apt-get update -q && sudo apt-get install -y ninja-build
- uses: astral-sh/setup-uv@v10.1.0

- name: Install meson
run: pip install meson
- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

- name: Configure (debug + sanitizers + buffer-size override)
run: >
Expand Down Expand Up @@ -130,15 +120,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install ninja
run: sudo apt-get update -q && sudo apt-get install -y ninja-build
- uses: astral-sh/setup-uv@v10.1.0

- name: Install meson
run: pip install meson
- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

- name: Configure (release)
run: >
Expand All @@ -163,15 +148,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: astral-sh/setup-uv@v10.1.0

- name: Install ninja
run: sudo apt-get update -q && sudo apt-get install -y ninja-build

- name: Install meson and gcovr
run: pip install meson gcovr
- name: Install meson, ninja and gcovr
run: uv tool install meson && uv tool install ninja && uv tool install gcovr

- name: Configure (coverage)
run: >
Expand Down Expand Up @@ -205,3 +185,122 @@ jobs:
with:
name: coverage-report
path: coverage-report/

# ---------------------------------------------------------------------------
# Cross-compile the library with TI's C2000 code generation tools, a target
# with CHAR_BIT == 16 and a 16-bit int, under both object ABIs. The
# installer is checksum-pinned and the installed toolchain is cached.
# ---------------------------------------------------------------------------
c2000:
name: "TI C2000 (CGT ${{ matrix.cgt }})"
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
include:
- cgt: "22.6.2"
sha256: "9773f338df7b7314bc459be2cd9d9bf329786da8de6531f8f2d3d38c1e9f5750"
- cgt: "25.11.1"
sha256: "2f3a978e24a53279c9796ad374c32b530fc58fd085fd71288597846fe169c821"

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v10.1.0

- name: Install meson and ninja
run: uv tool install meson && uv tool install ninja

- name: Cache TI C2000 CGT
id: cache-cgt
uses: actions/cache@v4
with:
path: ~/ti
key: ti-cgt-c2000-${{ matrix.cgt }}

- name: Install TI C2000 CGT
if: steps.cache-cgt.outputs.cache-hit != 'true'
run: |
bin="ti_cgt_c2000_${{ matrix.cgt }}.LTS_linux-x64_installer.bin"
curl -sSfL --retry 3 -o "$RUNNER_TEMP/$bin" \
"https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-xqxJ05PLfM/${{ matrix.cgt }}.LTS/$bin"
echo "${{ matrix.sha256 }} $RUNNER_TEMP/$bin" | sha256sum -c -
chmod +x "$RUNNER_TEMP/$bin"
"$RUNNER_TEMP/$bin" --mode unattended --prefix "$HOME/ti"

- name: Configure and build (COFF and EABI)
run: |
CGT="$HOME/ti/ti-cgt-c2000_${{ matrix.cgt }}.LTS"
for abi in coffabi eabi; do
cat > "c2000-$abi.ini" <<INI
[binaries]
c = '$CGT/bin/cl2000'
ar = '$CGT/bin/ar2000'
strip = '$CGT/bin/strip2000'

[built-in options]
c_args = ['-v28', '--float_support=fpu32', '--abi=$abi', '-I$CGT/include']

[host_machine]
system = 'bare-metal'
cpu_family = 'c2000'
cpu = 'c28x'
endian = 'little'
INI
meson setup "build-$abi" --cross-file="c2000-$abi.ini" \
-Dbuild_tests=false -Dwerror=true
meson compile -C "build-$abi"
done

# ---------------------------------------------------------------------------
# Formatting, with the clang-format release pinned in scripts/format.sh.
# ---------------------------------------------------------------------------
format:
name: "clang-format"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v10.1.0

- name: Check formatting
run: scripts/format.sh

# ---------------------------------------------------------------------------
# MISRA C:2023 analysis with misch. The analysis reports zero findings, so
# CI fails on any finding; deviations are justified at point of use or in
# misra-deviations.txt.
# ---------------------------------------------------------------------------
misra:
name: "MISRA (misch)"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v10.1.0

# Ubuntu 24.04 ships cppcheck 2.13, whose findings differ from current
# releases. The Homebrew bottle is current; brew is preinstalled.
- name: Install cppcheck
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
run: |
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install cppcheck
echo "$(brew --prefix)/bin" >> "$GITHUB_PATH"
cppcheck --version

- name: Install meson, ninja and misch
run: uv tool install meson && uv tool install ninja && uv tool install misch

- name: Configure (compile database)
run: meson setup build --buildtype=debug -Dbuild_tests=true

- name: Analyse
run: misch run -v

- name: Deviation record
run: misch deviations
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added

- `meson install` generates a `ppack.pc` file, so an installed package is consumed with `pkg-config --cflags --libs ppack`, and the build registers `ppack` with `meson.override_dependency`.
- `scripts/format.sh`, which pins the clang-format release and runs it with `uvx`. CI checks formatting through it.
- CI runs the MISRA C:2023 analysis with `misch`, fails on any finding, and prints the deviation record.
- CI compiles the library with warnings as errors using two releases of a vendor C11 compiler for a 16-bit-MAU DSP target, under both of its object formats.

### Changed

- CI installs Meson, Ninja and gcovr with `uv` instead of `pip` and `apt`.

## [2.5.0] - 2026-09-08

### Changed
Expand Down
13 changes: 13 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: MIT

project(
'ppack',
'c',
Expand Down Expand Up @@ -57,6 +59,17 @@ ppack_dep = declare_dependency(
link_with: ppack_lib,
)

meson.override_dependency('ppack', ppack_dep)

pkg = import('pkgconfig')
pkg.generate(
ppack_lib,
description: 'Bit-aligned payload serialisation for embedded C',
filebase: 'ppack',
name: 'ppack',
subdirs: 'ppack',
)

# === Host unit tests ==========================================================

if get_option('build_tests')
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: MIT

# === Build personality ========================================================
# By default tests are disabled. Enable them with -Dbuild_tests=true.
option(
Expand Down
59 changes: 59 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
#
# Checks or applies the project's C and C++ formatting with a pinned
# clang-format. uvx fetches that exact release from PyPI and caches it, so the
# result does not depend on a system or editor install. CI runs the check.
#
# Usage: scripts/format.sh check tracked and new sources
# scripts/format.sh --fix rewrite them in place

set -eu

# Raise this to adopt a new release, then run --fix and commit the result.
CLANG_FORMAT_VERSION=23.1.1

usage="usage: scripts/format.sh [--fix]"

if [ "$#" -gt 1 ]; then
echo "$usage" >&2
exit 2
fi

case "${1:-}" in
"") mode=check ;;
--fix) mode=fix ;;
-h | --help) echo "$usage"; exit 0 ;;
*) echo "$usage" >&2; exit 2 ;;
esac

if ! command -v uvx >/dev/null 2>&1; then
echo "error: uvx not found. Install uv: https://docs.astral.sh/uv/" >&2
exit 1
fi

cd "$(dirname "$0")/.."

# Tracked sources plus new, unignored ones, so --fix also covers files that
# are not added yet. Paths deleted from the working tree are skipped.
set --
for file in $(git ls-files --cached --others --exclude-standard \
-- '*.c' '*.h' '*.cpp'); do
if [ -f "$file" ]; then
set -- "$@" "$file"
fi
done

if [ "$#" -eq 0 ]; then
echo "no C or C++ sources found"
exit 0
fi

clang_format="clang-format@$CLANG_FORMAT_VERSION"
if [ "$mode" = fix ]; then
uvx --quiet "$clang_format" -i "$@"
echo "formatted $# files with $clang_format"
else
uvx --quiet "$clang_format" --dry-run --Werror "$@"
echo "$# files match $clang_format"
fi
2 changes: 2 additions & 0 deletions tests/compatibility/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: MIT

# Optional side-by-side comparison. Supply an unmodified legacy checkout.
project('ppack-legacy-comparison', 'c', default_options: ['c_std=c11'])

Expand Down
2 changes: 2 additions & 0 deletions tests/compatibility/meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: MIT

option(
'legacy_root',
type: 'string',
Expand Down
2 changes: 2 additions & 0 deletions tests/compatibility/test_legacy_compat.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_legacy_compat.c
* @brief Compare valid legacy geometry against an unmodified old codec.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: MIT

test_sources = [
'test_ppack_main.c',
'test_harness.c',
Expand Down
2 changes: 2 additions & 0 deletions tests/test_edge.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_edge.c
* @brief Misc / edge cases — invalid types, empty fields, extreme values,
* single-bit and overlapping fields, full-payload sanity.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_exhaustive.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_exhaustive.c
* @brief Brute-force sweeps over bit positions, bit lengths, cross-boundary
* layouts, adjacency, odd alignment, and full-payload multi-field
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fixtures.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_fixtures.h
* @brief Shared fixtures, payload-inspection macros, and struct typedefs
* used by every category of the ppack unit-test suite.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fuzz.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_fuzz.c
* @brief PRNG + small math helpers shared by the fuzz tests.
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fuzz.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_fuzz.h
* @brief Deterministic xorshift32 PRNG and helpers for the fuzz tests.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fuzz_cases.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_fuzz_cases.c
* @brief Stress / fuzz / property tests using the deterministic PRNG
* from test_fuzz.h: per-type round-trips, pack/unpack/pack
Expand Down
2 changes: 2 additions & 0 deletions tests/test_harness.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_harness.c
* @brief Test runner implementation.
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/test_harness.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_harness.h
* @brief Minimal test harness used by the ppack unit-test suite.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/test_large_payload.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: MIT
*
* @file: test_large_payload.c
* @brief Large-payload checks against an independent bit-at-a-time model.
*
Expand Down
Loading
Loading