aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/EthBuildInfo.cmake4
-rw-r--r--cmake/scripts/buildinfo.cmake53
-rw-r--r--cmake/templates/BuildInfo.h.in15
3 files changed, 44 insertions, 28 deletions
diff --git a/cmake/EthBuildInfo.cmake b/cmake/EthBuildInfo.cmake
index cbb9dd24..1f70d371 100644
--- a/cmake/EthBuildInfo.cmake
+++ b/cmake/EthBuildInfo.cmake
@@ -19,7 +19,7 @@ function(create_build_info NAME)
set(ETH_BUILD_COMPILER "unknown")
endif ()
- set(ETH_BUILD_PLATFORM "${ETH_BUILD_OS}/${ETH_BUILD_COMPILER}")
+ set(ETH_BUILD_PLATFORM "${ETH_BUILD_OS}.${ETH_BUILD_COMPILER}")
#cmake build type may be not speCified when using msvc
if (CMAKE_BUILD_TYPE)
@@ -36,8 +36,6 @@ function(create_build_info NAME)
-DETH_BUILD_OS="${ETH_BUILD_OS}"
-DETH_BUILD_COMPILER="${ETH_BUILD_COMPILER}"
-DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}"
- -DETH_BUILD_NUMBER="${BUILD_NUMBER}"
- -DETH_VERSION_SUFFIX="${VERSION_SUFFIX}"
-DPROJECT_VERSION="${PROJECT_VERSION}"
-P "${ETH_SCRIPTS_DIR}/buildinfo.cmake"
)
diff --git a/cmake/scripts/buildinfo.cmake b/cmake/scripts/buildinfo.cmake
index 39359486..ad23ca86 100644
--- a/cmake/scripts/buildinfo.cmake
+++ b/cmake/scripts/buildinfo.cmake
@@ -5,11 +5,11 @@
# ETH_DST_DIR - main CMAKE_BINARY_DIR
# ETH_BUILD_TYPE
# ETH_BUILD_PLATFORM
-# ETH_BUILD_NUMBER
-# ETH_VERSION_SUFFIX
#
# example usage:
-# cmake -DETH_SOURCE_DIR=. -DETH_DST_DIR=build -DETH_BUILD_TYPE=Debug -DETH_BUILD_PLATFORM=Darwin/appleclang -P scripts/buildinfo.cmake
+# cmake -DETH_SOURCE_DIR=. -DETH_DST_DIR=build -DETH_BUILD_TYPE=Debug -DETH_BUILD_PLATFORM=Darwin.appleclang -P scripts/buildinfo.cmake
+#
+# Its main output variables are SOL_VERSION_BUILDINFO and SOL_VERSION_PRERELEASE
if (NOT ETH_BUILD_TYPE)
set(ETH_BUILD_TYPE "unknown")
@@ -19,26 +19,45 @@ if (NOT ETH_BUILD_PLATFORM)
set(ETH_BUILD_PLATFORM "unknown")
endif()
-execute_process(
- COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} rev-parse HEAD
- OUTPUT_VARIABLE ETH_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
-)
+# Logic here: If prereleases.txt exists but is empty, it is a non-pre release.
+# If it does not exist, create our own prerelease string
+if (EXISTS ${ETH_SOURCE_DIR}/prerelease.txt)
+ file(READ ${ETH_SOURCE_DIR}/prerelease.txt SOL_VERSION_PRERELEASE)
+ string(STRIP ${SOL_VERSION_PRERELEASE} SOL_VERSION_PRERELEASE)
+else()
+ string(TIMESTAMP SOL_VERSION_PRERELEASE "develop.%Y.%m.%d" UTC)
+endif()
-if (NOT ETH_COMMIT_HASH)
- set(ETH_COMMIT_HASH 0)
+if (EXISTS ${ETH_SOURCE_DIR}/commit_hash.txt)
+ file(READ ${ETH_SOURCE_DIR}/commit_hash.txt SOL_COMMIT_HASH)
+ string(STRIP ${SOL_COMMIT_HASH} SOL_COMMIT_HASH)
+else()
+ execute_process(
+ COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} rev-parse HEAD
+ OUTPUT_VARIABLE SOL_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
+ )
+ execute_process(
+ COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} diff HEAD --shortstat
+ OUTPUT_VARIABLE SOL_LOCAL_CHANGES OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
+ )
endif()
-execute_process(
- COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} diff HEAD --shortstat
- OUTPUT_VARIABLE ETH_LOCAL_CHANGES OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
-)
+if (SOL_COMMIT_HASH)
+ string(STRIP ${SOL_COMMIT_HASH} SOL_COMMIT_HASH)
+ string(SUBSTRING ${SOL_COMMIT_HASH} 0 8 SOL_COMMIT_HASH)
+endif()
-if (ETH_LOCAL_CHANGES)
- set(ETH_CLEAN_REPO 0)
-else()
- set(ETH_CLEAN_REPO 1)
+if (SOL_COMMIT_HASH AND SOL_LOCAL_CHANGES)
+ set(SOL_COMMIT_HASH "${SOL_COMMIT_HASH}-mod")
+endif()
+
+if (NOT SOL_COMMIT_HASH)
+ message(FATAL_ERROR "Unable to determine commit hash. Either compile from within git repository or "
+ "supply a file called commit_hash.txt")
endif()
+set(SOL_VERSION_BUILDINFO "commit.${SOL_COMMIT_HASH}.${ETH_BUILD_PLATFORM}")
+
set(TMPFILE "${ETH_DST_DIR}/BuildInfo.h.tmp")
set(OUTFILE "${ETH_DST_DIR}/BuildInfo.h")
diff --git a/cmake/templates/BuildInfo.h.in b/cmake/templates/BuildInfo.h.in
index 6f9baf50..6c16e4ac 100644
--- a/cmake/templates/BuildInfo.h.in
+++ b/cmake/templates/BuildInfo.h.in
@@ -1,11 +1,10 @@
#pragma once
#define ETH_PROJECT_VERSION "@PROJECT_VERSION@"
-#define ETH_COMMIT_HASH @ETH_COMMIT_HASH@
-#define ETH_CLEAN_REPO @ETH_CLEAN_REPO@
-#define ETH_BUILD_TYPE @ETH_BUILD_TYPE@
-#define ETH_BUILD_OS @ETH_BUILD_OS@
-#define ETH_BUILD_COMPILER @ETH_BUILD_COMPILER@
-#define ETH_BUILD_PLATFORM @ETH_BUILD_PLATFORM@
-#define ETH_BUILD_NUMBER @ETH_BUILD_NUMBER@
-#define ETH_VERSION_SUFFIX "@ETH_VERSION_SUFFIX@"
+#define SOL_COMMIT_HASH "@SOL_COMMIT_HASH@"
+#define ETH_BUILD_TYPE "@ETH_BUILD_TYPE@"
+#define ETH_BUILD_OS "@ETH_BUILD_OS@"
+#define ETH_BUILD_COMPILER "@ETH_BUILD_COMPILER@"
+#define ETH_BUILD_PLATFORM "@ETH_BUILD_PLATFORM@"
+#define SOL_VERSION_PRERELEASE "@SOL_VERSION_PRERELEASE@"
+#define SOL_VERSION_BUILDINFO "@SOL_VERSION_BUILDINFO@"