Skip to content

build: commit SilKitVersionMacros.h and regenerate with tool#339

Open
MariusBgm wants to merge 1 commit into
mainfrom
dev/generate_version_tool
Open

build: commit SilKitVersionMacros.h and regenerate with tool#339
MariusBgm wants to merge 1 commit into
mainfrom
dev/generate_version_tool

Conversation

@MariusBgm

Copy link
Copy Markdown
Collaborator

Commit the version macros directly to the public include folders.
Add a small C++17 tool to regenerate the header with new version, git hash and optionally rotate the changelog.md if version number changed.

Signed-off-by: Marius Börschig <Marius.Boerschig@vector.com>
@MariusBgm

Copy link
Copy Markdown
Collaborator Author

i think we should be able to pass the git hash as a define to the compilation

@MariusBgm

MariusBgm commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

i think we should be able to pass the git hash as a define to the compilation

i think something like:

# CI: update the header in-tree (not committed, just for this build)
./sil-kit-version-gen \
  --major 5 --minor 0 --patch 6 \
  --git-hash "$(git rev-parse HEAD)" \
  --no-changelog \
  SilKit/include/silkit/capi/SilKitVersionMacros.h

would work in CI builds, without changing the current implementation.
and in bazel we could probably create it using something like:

# tools/BUILD.bazel — build the generator itself
cc_binary(
    name = "sil-kit-version-gen",
    srcs = ["//SilKit/source/util:sil-kit-version-gen.cpp"],
    # C++17, no deps — trivially hermetic
)

# SilKit/BUILD.bazel — generate the header
genrule(
    name = "version_macros",
    srcs = [".git/HEAD"],   # or nothing if hash is passed in
    outs = ["include/silkit/capi/SilKitVersionMacros.h"],
    cmd = "$(location //tools:sil-kit-version-gen) " +
          "--major 5 --minor 0 --patch 6 " +
          "--git-hash $$(cat bazel-out/stable-status.txt | grep GIT_HASH | cut -d' ' -f2) " +
          "--no-changelog $@",
    tools = ["//tools:sil-kit-version-gen"],
    stamp = 1,  # gives the rule access to stable-status.txt
)

cc_library(
    name = "version_header",
    hdrs = [":version_macros"],
    includes = ["include"],
)

@MariusBgm MariusBgm marked this pull request as ready for review July 6, 2026 07:19
@MariusBgm MariusBgm added the needs reviewer This issue is looking for a reviewer. label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Design Proposal needs reviewer This issue is looking for a reviewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant