Skip to content
Open
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
3 changes: 2 additions & 1 deletion utils/build_date.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <ctime>
#include <sys/stat.h>

/// git commit this binary was built from, with a "-dirty" marker when the tree
/// git commit this binary was built from, described relative to the latest
/// release tag (e.g. v1.10.0-12-gc719a4ac), with a "-dirty" marker when the tree
/// carried uncommitted changes. Defined in provenance.cpp, which is the only
/// translation unit that includes the generated version.h, so that a change of
/// hash recompiles one file instead of everything including this header.
Expand Down
11 changes: 10 additions & 1 deletion utils/gen_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
# leave OUT_FILE alone when nothing changed, avoiding a rebuild.
# ----------------------------------------------------------------------------

execute_process( COMMAND git rev-parse --short HEAD
# Name the build relative to the most recent release tag, e.g.
# v1.10.0-12-gc719a4ac is 12 commits past v1.10.0 at commit c719a4ac.
#
# --long keeps the hash even on a tagged commit (v1.10.0-0-g...), because a
# tag can be moved or deleted but the hash always names the commit.
# --match restricts this to annotated release tags of the form vX.Y.Z.
# --always falls back to the bare hash when no tag is reachable, such as in
# a shallow clone.
#
execute_process( COMMAND git describe --long --always --match "v[0-9]*"
WORKING_DIRECTORY ${SRC_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down
4 changes: 3 additions & 1 deletion utils/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
*/
#pragma once

#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" ///< hash, hash-dirty, or "unknown"
/// git describe output, e.g. v1.10.0-12-gc719a4ac[-dirty]; a bare hash if no
/// release tag is reachable; or "unknown" if git is unavailable
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"
Loading