logic: versioning

This commit is contained in:
Andreas Stallinger
2017-06-12 09:14:21 +02:00
parent 419a2e27ba
commit 19ed6cb372
28 changed files with 536 additions and 453 deletions
+10
View File
@@ -0,0 +1,10 @@
#ifndef PRIVATE_KEY_H
#define PRIVATE_KEY_H
// This File(PrivateKey.h) is generated with CMake
#include <string>
const std::string PRIVATE_KEY = "@KEY@";
#endif // PRIVATE_KEY_H
+1 -1
View File
@@ -5,6 +5,6 @@
#include <string>
static const std::string PublicKey = "@KEY@";
const std::string PUBLIC_KEY = "@KEY@";
#endif // PUBLIC_KEY_H
+22
View File
@@ -0,0 +1,22 @@
# searching for private key file of the Sourcetrail version in setup/RSA_keys
# if found the file will be put into a const string into the PrivateKey.h file
string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_VERSION_NUMBER}")
message(STATUS "Get Public Key for Sourcetrail version: ${VERSION_MAJOR}")
message(STATUS "${CMAKE_SOURCE_DIR}/setup/RSA_keys/private-sourcetrail.pem")
set(privateKeyFile "${CMAKE_SOURCE_DIR}/setup/RSA_keys/private-sourcetrail.pem")
if(EXISTS ${privateKeyFile})
file(READ ${privateKeyFile} KEY)
STRING(REGEX REPLACE "\"" "\\\\\"" KEY "${KEY}")
STRING(REGEX REPLACE "\n" "\\\\n\"\n\t\"" KEY "${KEY}")
else()
message(FATAL_ERROR "private keyfile for Sourcetrail not found")
endif()
configure_file(
${CMAKE_SOURCE_DIR}/cmake/PrivateKey.h.in
${CMAKE_BINARY_DIR}/src/license_generator/PrivateKey.h
)
@@ -1,27 +1,23 @@
# searching for public key file of the Sourcetrail version in setup/RSA_keys
# if found the file will be put into a const string into the PubicKeh.h file
# if found the file will be put into a const string into the PubicKey.h file
string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_VERSION_NUMBER}")
message(STATUS "Get Public Key for Sourcetrail version: ${VERSION_MAJOR}")
# message(STATUS "${CMAKE_SOURCE_DIR}/setup/RSA_keys/public-${VERSION_MAJOR}.pem")
message(STATUS "${CMAKE_SOURCE_DIR}/setup/RSA_keys/public-0.pem") # explain in Readme.md how to get this to work first
message(STATUS "${CMAKE_SOURCE_DIR}/setup/RSA_keys/public-sourcetrail.pem")
# set(pubKeyFile "${CMAKE_SOURCE_DIR}/setup/RSA_keys/public-${VERSION_MAJOR}.pem")
set(pubKeyFile "${CMAKE_SOURCE_DIR}/setup/RSA_keys/public-0.pem") # explain in Readme.md how to get this to work first
# message(STATUS "file: ${pubKeyFile}")
set(pubKeyFile "${CMAKE_SOURCE_DIR}/setup/RSA_keys/public-sourcetrail.pem")
if(EXISTS ${pubKeyFile})
file(READ ${pubKeyFile} KEY)
STRING(REGEX REPLACE "\"" "\\\\\"" KEY "${KEY}")
STRING(REGEX REPLACE "\n" "\\\\n\"\n\t\"" KEY "${KEY}")
# message(STATUS "key: ${KEY}")
else()
message(WARNING "public keyfile for this version of Sourcetrail not found")
message(FATAL_ERROR "public keyfile for Sourcetrail not found")
#message(WARNING "public keyfile for Sourcetrail not found")
endif()
configure_file(
${CMAKE_SOURCE_DIR}/cmake/PublicKey.h.in
${CMAKE_BINARY_DIR}/src/lib_license/PublicKey.h
)
)
+10 -3
View File
@@ -24,7 +24,7 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --long --match "[0-9]*" --abbrev=7 HEAD
COMMAND ${GIT_EXECUTABLE} describe --long --match "[0-9]*" HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION_NUMBER
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -37,10 +37,17 @@ else(EXISTS "${CMAKE_SOURCE_DIR}/.git")
endif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_YEAR "${GIT_VERSION_NUMBER}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_VERSION_NUMBER}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_VERSION_NUMBER}")
message(STATUS "Git current branch: ${GIT_BRANCH}")
message(STATUS "Git commit hash: ${GIT_COMMIT_HASH}")
message(STATUS "Git commit time: ${GIT_COMMIT_TIME}")
message(STATUS "Git version number: " ${GIT_VERSION_NUMBER} )
message(STATUS "Git commit hash: ${GIT_COMMIT_HASH}")
message(STATUS "Version year: ${VERSION_YEAR}")
message(STATUS "Version minor: ${VERSION_MINOR}")
message(STATUS "Version commit: ${VERSION_COMMIT}")
message(STATUS "Git commit time: ${GIT_COMMIT_TIME}")
configure_file(
${CMAKE_SOURCE_DIR}/cmake/version.h.in
+3
View File
@@ -5,5 +5,8 @@
#define GIT_VERSION_NUMBER "@GIT_VERSION_NUMBER@"
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"
#define GIT_COMMIT_TIME "@GIT_COMMIT_TIME@"
#define VERSION_YEAR @VERSION_YEAR@
#define VERSION_MINOR @VERSION_MINOR@
#define VERSION_COMMIT @VERSION_COMMIT@
#endif // SOURCETRAIL_VERSION_H