This repository was archived by the owner on May 1, 2026. It is now read-only.
build: expose KSUID_VERSION_* macros via configure_file - #8
Merged
Conversation
Closes #3. Adds compile-time version macros to the public header so downstream consumers can guard new API surface with the conventional preprocessor arithmetic: #if KSUID_VERSION >= ((1 << 16) | (2 << 8) | 0) /* call symbol that landed in 1.2.0 */ #endif The five macros land in libksuid/ksuid_version.h, which is generated via meson's configure_file from libksuid/ksuid_version.h.in. The single source of truth is meson.build's project(version : '0.1.0') clause -- bumping the version there propagates through the binary soversion, the .pc file, and the public header in lockstep. KSUID_VERSION_MAJOR integer KSUID_VERSION_MINOR integer KSUID_VERSION_PATCH integer KSUID_VERSION (M << 16) | (m << 8) | p, single int KSUID_VERSION_STRING meson.project_version() verbatim Implementation notes addressing the architect + critic risk register: R1 (non-semver project_version): meson.build asserts the version string has at least three dot-separated parts and strips a trailing -prerelease / +build suffix from the patch component before .to_int() coerces it. The full string still rides through KSUID_VERSION_STRING so callers can inspect the suffix when present. R2 (reproducibility / meson dist): the .h.in template is the only tracked artifact and substitutes only @VERSION_*@ tokens that come from meson.project_version() -- no vcs_tag, no __DATE__, no build-time variables. The generated header is regenerated deterministically from any tarball. R3 (gst-indent over generated header): the .h.in suffix takes the template out of the *.h glob the lint hook sweeps, and .gitignore picks up libksuid/ksuid_version.h as belt-and-braces against an in-tree generation by mistake. R4 (clang-tidy 22 on generated header): verified locally to produce zero findings -- the body is just five #defines with no executable code. R5 (install_headers + .pc): configure_file's install_dir lays ksuid_version.h next to ksuid.h under ${prefix}/include/libksuid/, and ci-pr.yml's DESTDIR install verification gains a matching test -f assertion. .pc Cflags already cover ${includedir} so no pkg-config edit is needed. R6 (KSUID_VERSION_STRING source): emitted from meson.project_version() directly rather than synthesised via #x stringification, so a pre-release suffix survives in KSUID_VERSION_STRING even though the integer macros only encode MAJOR.MINOR.PATCH. R7 (header hygiene): #ifndef/#define/#endif guard matching the project's existing convention; no #pragma once, no static definitions, no transitive includes. R8 (Windows CRLF): .gitattributes pins *.h.in to LF so configure_file output is byte-identical regardless of which platform's checkout the runner used. A test_version_macros_are_consistent test in test_smoke.c pins the (MAJOR, MINOR, PATCH, KSUID_VERSION layout, KSUID_VERSION_STRING non-empty) invariants; 11/11 tests still pass on Linux GCC and the release-mode install verifies the new header lands at the documented path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3.
Summary
Exposes compile-time version macros in the public header so downstream consumers can guard new API surface with the conventional preprocessor arithmetic:
Five macros land in the new generated header
libksuid/ksuid_version.h, driven bymeson.project_version()via aconfigure_filesubstitution fromlibksuid/ksuid_version.h.in:KSUID_VERSION_MAJOR0for the current releaseKSUID_VERSION_MINOR1KSUID_VERSION_PATCH0KSUID_VERSION(M << 16) | (m << 8) | pfor#ifarithmeticKSUID_VERSION_STRINGmeson.project_version()verbatim, preserves any pre-release / +build suffixSingle source of truth is
meson.build'sproject(version : '0.1.0')clause; bumping it propagates to the binary soversion, the .pc file, and the public header in lockstep.Pipeline that ran
Per the global GitHub-issue resolution workflow rule:
.h.intemplate tracked in git,subdir('libksuid')so<libksuid/ksuid_version.h>resolves through the existing include path.8d24ebd.>= 0instead of exact values + missingmeson distround-trip CI gate.test_smoke.c(deliberate sync point withmeson.build'sversion :field) + newdistjob inci-pr.ymlthat does the fullmeson dist→ extract → setup → compile → test round-trip.@VERSION_MAJOR@substitution would now fail to compile (blank#define+==is a syntax error), strictly stronger than the runtime check the implementer's comment described.What gates this PR
The new
distjob inci-pr.ymlis a hard gate alongside the existing build matrix and sanitizer phases:staging/usr/local/include/libksuid/ksuid_version.hmeson distround-trip on Ubuntu — proves the generated header rebuilds deterministically from a clean tarballTest plan
${prefix}/include/libksuid/ksuid_version.hmeson distjob green (tarball → fresh extract → setup → compile → test)test_version_macros_are_consistentpasses (exact value pin)