mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-06 02:07:07 +00:00
The existing code added the git commit info (`GIT_COMMIT_HASH` and `GIT_BRANCH`) to every file, which was a problem for leveraging `ccache` to cache build objects. This change adds a separate C++ file from where these compile-time variables are propagated to wherever they are needed. A new CMake file is added to set the commit info if the `git` binary is available.
32 lines
597 B
C++
32 lines
597 B
C++
#include "xrpl/git/Git.h"
|
|
|
|
#include <string>
|
|
|
|
#ifndef GIT_COMMIT_HASH
|
|
#error "GIT_COMMIT_HASH must be defined"
|
|
#endif
|
|
#ifndef GIT_BUILD_BRANCH
|
|
#error "GIT_BUILD_BRANCH must be defined"
|
|
#endif
|
|
|
|
namespace xrpl::git {
|
|
|
|
static constexpr char kGIT_COMMIT_HASH[] = GIT_COMMIT_HASH;
|
|
static constexpr char kGIT_BUILD_BRANCH[] = GIT_BUILD_BRANCH;
|
|
|
|
std::string const&
|
|
getCommitHash()
|
|
{
|
|
static std::string const kVALUE = kGIT_COMMIT_HASH;
|
|
return kVALUE;
|
|
}
|
|
|
|
std::string const&
|
|
getBuildBranch()
|
|
{
|
|
static std::string const kVALUE = kGIT_BUILD_BRANCH;
|
|
return kVALUE;
|
|
}
|
|
|
|
} // namespace xrpl::git
|