core: embed git SHA as build-time constant#170
Open
webern wants to merge 2 commits into
Open
Conversation
gen-quality
|
Coverage reportCore-dev coverage
|
| Metric | Coverage | Covered / Total |
|---|---|---|
| Lines | 77.9% | 28505 / 36590 |
| Functions | 74.4% | 6354 / 8542 |
| Branches | 50.7% | 22645 / 44673 |
API coverage src/private/mx/{api,impl,utility}/
| Metric | Coverage | Covered / Total |
|---|---|---|
| Lines | 68.7% | 4734 / 6895 |
| Functions | 53.5% | 1507 / 2816 |
| Branches | 40.3% | 3851 / 9562 |
Core HTML report | API HTML report
Commit 6a76395dddcec8cf8e76db930bba17a3b28cabb7.
Add mx::core::gitSha, a C++ const carrying the commit the library was built from (a -dirty suffix marks an unclean tree, "unknown" marks a build outside any checkout). Capture runs as a build step via cmake/GitSha.cmake, not at configure time, so the value stays correct when an IDE rebuild (Xcode, Ninja, Make) bypasses the Makefile and never re-runs CMake. copy_if_different rewrites the generated TU only on change, keeping incremental builds warm.
Every file mx writes now carries <software>https://github.com/webern/mx version=SHA</software> in its <encoding>. The logic is a hand-written core wrapper, serializeWithAttribution, that stamps a copy of the typed model (so the generated serializer places identification/encoding in their schema-correct slots) and dedupes by URL prefix: re-writing a file from any mx version replaces the prior stamp instead of accumulating. DocumentManager's write path routes through the wrapper; the raw generated serialize() stays pure, so corert and validate are untouched. The api read path drops mx's own stamp from EncodingData.software, and the api-roundtrip harness strips it before comparison. AttributionTest covers placement, user-software preservation, and cross-version dedup.
53cd487 to
d7a72b0
Compare
gen-quality
|
Coverage reportCore-dev coverage
|
| Metric | Coverage | Covered / Total |
|---|---|---|
| Lines | 77.9% | 28539 / 36619 |
| Functions | 74.4% | 6360 / 8547 |
| Branches | 50.7% | 22672 / 44725 |
API coverage src/private/mx/{api,impl,utility}/
| Metric | Coverage | Covered / Total |
|---|---|---|
| Lines | 68.7% | 4735 / 6896 |
| Functions | 54.8% | 1475 / 2692 |
| Branches | 40.3% | 3850 / 9558 |
Core HTML report | API HTML report
Commit 9b1bedfb62c9c7272702898679378a37be133181.
Owner
Author
|
@copilot rebase |
I attempted to rebase onto |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds
mx::core::gitSha-- a C++const char* constholding the git commit the library was builtfrom. Unclean trees get a
-dirtysuffix (any modified tracked file or any untracked file); buildsoutside a git checkout (e.g. an exported source archive) get
"unknown".Why this shape
The capture must survive a rebuild that bypasses the Makefile. A configure-time capture
(
execute_process/configure_file) freezes the SHA into the generated project and goes stale themoment HEAD moves, because an IDE rebuild (Xcode/Ninja/Make) never re-runs CMake. So the capture is a
build step baked into the project (
cmake/GitSha.cmake, run viacmake -P); it re-checks git everybuild.
copy_if_differentrewrites the generated TU only when the value actually changed, soincremental builds stay warm and only that one TU recompiles on a new SHA.
Declaration (
Version.h) and definition (Version.cpp.in-> generatedGitSha.cppunder the buildtree) are split so consumers that include the header never recompile on a SHA change.
Files
src/private/mx/core/Version.h-- thegitShadeclarationsrc/private/mx/core/Version.cpp.in-- build-time templatecmake/GitSha.cmake-- the capture + copy-if-different scriptCMakeLists.txt--mx_git_shacustom target, wires the TU intomx_coreVerification
mx_corebuilds and links the symbol under the pinned GCC-14 toolchain(
_ZN2mx4core6gitShaEinlibmx_core.a).unknown; clean tree -> no suffix; untracked file alone ->-dirty.copy_if_differentleaves the TU mtime unchanged when the SHA is unchanged (no needless rebuild).