Define GIT_COMMIT_HASH via cmake or git archive

This commit is contained in:
Unknown
2017-11-10 19:19:07 +00:00
parent d35893d926
commit 0bae47a754
4 changed files with 43 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
xmrstak/version.hpp export-subst
+28
View File
@@ -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
################################################################################
+1 -1
View File
@@ -85,7 +85,7 @@ void help()
cout<<" -u, --user USERNAME pool user name or wallet address"<<endl;
cout<<" -p, --pass PASSWD pool password, in the most cases x or empty \"\""<<endl;
cout<<" \n"<<endl;
cout<<XMR_STAK_NAME<<" "<<XMR_STAK_VERSION<<endl;
cout<<XMR_STAK_NAME << " " << XMR_STAK_VERSION << " " << GIT_COMMIT_HASH << " " << GIT_BRANCH << endl;
cout<<"Brought to by fireice_uk and psychocrypt under GPLv3."<<endl;
}
+13
View File
@@ -1,4 +1,17 @@
#pragma once
//! git will put "#define GIT_ARCHIVE 1" on the next line inside archives. $Format:%n#define GIT_ARCHIVE 1$
#if defined(GIT_ARCHIVE) && !defined(GIT_COMMIT_HASH)
#define GIT_COMMIT_HASH "$Format:%h$"
#endif
#ifndef GIT_COMMIT_HASH
#define GIT_COMMIT_HASH "0000000"
#endif
#ifndef GIT_BRANCH
#define GIT_BRANCH "unknown"
#endif
#define XMR_STAK_NAME "xmr-stak"
#define XMR_STAK_VERSION "2.0.0-predev"