From 0bae47a75488e2fd1bcab8b141976763e4d81e95 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 10 Nov 2017 19:19:07 +0000 Subject: [PATCH] Define GIT_COMMIT_HASH via cmake or git archive --- .gitattributes | 1 + CMakeLists.txt | 28 ++++++++++++++++++++++++++++ xmrstak/cli/cli-miner.cpp | 2 +- xmrstak/version.hpp | 13 +++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c71d4e1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +xmrstak/version.hpp export-subst diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e13aa0..0faa56d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,6 +358,34 @@ if(WIN32) set(LIBS ${LIBS} wsock32 ws2_32) endif() +################################################################################ +# Versioning +################################################################################ + +# Get the current working branch +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Get the latest abbreviated commit hash of the working branch +execute_process( + COMMAND git log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if(NOT "${GIT_COMMIT_HASH}" STREQUAL "") + add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"") +endif() +if(NOT "${GIT_BRANCH}" STREQUAL "") + add_definitions("-DGIT_BRANCH=\"${GIT_BRANCH}\"") +endif() + + ################################################################################ # Compile & Link ################################################################################ diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index 5c16c1b..d103293 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -85,7 +85,7 @@ void help() cout<<" -u, --user USERNAME pool user name or wallet address"<