diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e5c3cd..20fcbf9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: > @@ -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: > @@ -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: > @@ -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: > @@ -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" <> "$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 diff --git a/CHANGELOG.md b/CHANGELOG.md index e9a8a7c..1dc907f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/meson.build b/meson.build index efc8692..3f040a9 100644 --- a/meson.build +++ b/meson.build @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: MIT + project( 'ppack', 'c', @@ -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') diff --git a/meson_options.txt b/meson_options.txt index b14b85f..64fa6fb 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: MIT + # === Build personality ======================================================== # By default tests are disabled. Enable them with -Dbuild_tests=true. option( diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 0000000..010b5bf --- /dev/null +++ b/scripts/format.sh @@ -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 diff --git a/tests/compatibility/meson.build b/tests/compatibility/meson.build index 2c65a0a..4ffa5af 100644 --- a/tests/compatibility/meson.build +++ b/tests/compatibility/meson.build @@ -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']) diff --git a/tests/compatibility/meson_options.txt b/tests/compatibility/meson_options.txt index 5d72347..6449c37 100644 --- a/tests/compatibility/meson_options.txt +++ b/tests/compatibility/meson_options.txt @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: MIT + option( 'legacy_root', type: 'string', diff --git a/tests/compatibility/test_legacy_compat.c b/tests/compatibility/test_legacy_compat.c index 98a2211..f2f2229 100644 --- a/tests/compatibility/test_legacy_compat.c +++ b/tests/compatibility/test_legacy_compat.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_legacy_compat.c * @brief Compare valid legacy geometry against an unmodified old codec. * diff --git a/tests/meson.build b/tests/meson.build index 25cc478..03099e8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: MIT + test_sources = [ 'test_ppack_main.c', 'test_harness.c', diff --git a/tests/test_edge.c b/tests/test_edge.c index 9571249..197467f 100644 --- a/tests/test_edge.c +++ b/tests/test_edge.c @@ -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. diff --git a/tests/test_exhaustive.c b/tests/test_exhaustive.c index a3b8390..1982242 100644 --- a/tests/test_exhaustive.c +++ b/tests/test_exhaustive.c @@ -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 diff --git a/tests/test_fixtures.h b/tests/test_fixtures.h index 1f6d36d..b9d1ea8 100644 --- a/tests/test_fixtures.h +++ b/tests/test_fixtures.h @@ -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. diff --git a/tests/test_fuzz.c b/tests/test_fuzz.c index 3c48f09..2d6382f 100644 --- a/tests/test_fuzz.c +++ b/tests/test_fuzz.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_fuzz.c * @brief PRNG + small math helpers shared by the fuzz tests. */ diff --git a/tests/test_fuzz.h b/tests/test_fuzz.h index 89a973f..cf5ec46 100644 --- a/tests/test_fuzz.h +++ b/tests/test_fuzz.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_fuzz.h * @brief Deterministic xorshift32 PRNG and helpers for the fuzz tests. * diff --git a/tests/test_fuzz_cases.c b/tests/test_fuzz_cases.c index 16af2bd..7ac590d 100644 --- a/tests/test_fuzz_cases.c +++ b/tests/test_fuzz_cases.c @@ -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 diff --git a/tests/test_harness.c b/tests/test_harness.c index b988839..7fb5a03 100644 --- a/tests/test_harness.c +++ b/tests/test_harness.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_harness.c * @brief Test runner implementation. */ diff --git a/tests/test_harness.h b/tests/test_harness.h index 7b516f5..6e15c00 100644 --- a/tests/test_harness.h +++ b/tests/test_harness.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_harness.h * @brief Minimal test harness used by the ppack unit-test suite. * diff --git a/tests/test_large_payload.c b/tests/test_large_payload.c index 47275a8..835de41 100644 --- a/tests/test_large_payload.c +++ b/tests/test_large_payload.c @@ -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. * diff --git a/tests/test_layout.c b/tests/test_layout.c index 7cf226d..e2885c1 100644 --- a/tests/test_layout.c +++ b/tests/test_layout.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_layout.c * @brief Field layout and multi-field placement. */ diff --git a/tests/test_mau_layout.c b/tests/test_mau_layout.c index a7d6371..a8ed409 100644 --- a/tests/test_mau_layout.c +++ b/tests/test_mau_layout.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_mau_layout.c * @brief Verify the physical memory layout of ppack payloads on 16-bit MAU. * diff --git a/tests/test_null_args.c b/tests/test_null_args.c index 32c0916..1aed56a 100644 --- a/tests/test_null_args.c +++ b/tests/test_null_args.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_null_args.c * @brief NULL / invalid-argument handling. */ diff --git a/tests/test_partial_coverage.c b/tests/test_partial_coverage.c index 36dcf84..cf7d02f 100644 --- a/tests/test_partial_coverage.c +++ b/tests/test_partial_coverage.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_partial_coverage.c * @brief Verify struct-member survival semantics when fields only partially * cover a multi-byte destination member. diff --git a/tests/test_patterns.c b/tests/test_patterns.c index 525fd94..6ddb2f4 100644 --- a/tests/test_patterns.c +++ b/tests/test_patterns.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_patterns.c * @brief Targeted edge-value tests — scaled extremes, sign-extension * boundaries, all-zeros / all-ones payloads, single-bit fields. diff --git a/tests/test_payload_size.c b/tests/test_payload_size.c index d902c42..6c00000 100644 --- a/tests/test_payload_size.c +++ b/tests/test_payload_size.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_payload_size.c * @brief Variable-size payload validation and round-trip coverage. * diff --git a/tests/test_ppack_main.c b/tests/test_ppack_main.c index 7ac5047..67c33f6 100644 --- a/tests/test_ppack_main.c +++ b/tests/test_ppack_main.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_ppack_main.c * @brief Unit-test driver for the ppack library. * diff --git a/tests/test_roundtrip_raw.c b/tests/test_roundtrip_raw.c index 2924f8c..1e80be6 100644 --- a/tests/test_roundtrip_raw.c +++ b/tests/test_roundtrip_raw.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_roundtrip_raw.c * @brief Raw (non-scaled) pack/unpack round-trips at full type widths. */ diff --git a/tests/test_scale_zero.c b/tests/test_scale_zero.c index 8485aa2..e8c9a68 100644 --- a/tests/test_scale_zero.c +++ b/tests/test_scale_zero.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_scale_zero.c * @brief Rejection of scale==0 (and any scaling on PPACK_TYPE_UINT8). */ diff --git a/tests/test_scaled.c b/tests/test_scaled.c index 0adfa0a..6b31a35 100644 --- a/tests/test_scaled.c +++ b/tests/test_scaled.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_scaled.c * @brief Scaled (linear scale/offset) field round-trips. */ diff --git a/tests/test_scaled_nonfinite.c b/tests/test_scaled_nonfinite.c index 767de0d..f260236 100644 --- a/tests/test_scaled_nonfinite.c +++ b/tests/test_scaled_nonfinite.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_scaled_nonfinite.c * @brief Non-finite inputs on SCALED fields: NaN is rejected with * -PPACK_ERR_INVALARG (casting NaN to an integer is undefined diff --git a/tests/test_sign_extension.c b/tests/test_sign_extension.c index 91d23e7..87d02a6 100644 --- a/tests/test_sign_extension.c +++ b/tests/test_sign_extension.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_sign_extension.c * @brief Sign-extension behaviour for sub-width signed fields. */ diff --git a/tests/test_uint8_shim.c b/tests/test_uint8_shim.c index 906f916..431c2ac 100644 --- a/tests/test_uint8_shim.c +++ b/tests/test_uint8_shim.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_uint8_shim.c * @brief 16-bit-MAU uint8_t alias-shim behaviour. * diff --git a/tests/test_validation.c b/tests/test_validation.c index 6800c79..802293f 100644 --- a/tests/test_validation.c +++ b/tests/test_validation.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_validation.c * @brief Overflow and bit_length bounds validation. */ diff --git a/tests/test_wire_lockdown.c b/tests/test_wire_lockdown.c index fce75f6..a4146d1 100644 --- a/tests/test_wire_lockdown.c +++ b/tests/test_wire_lockdown.c @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: MIT + * * @file: test_wire_lockdown.c * @brief Wire-format lockdown tests for the 64-bit (CAN classic) payload. *