aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/scripts
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-08-23 22:04:50 +0800
committerchriseth <c@ethdev.com>2016-08-26 16:14:44 +0800
commit54ab787b83275fd374b3951ec3efa577c954bd1a (patch)
tree7a8d2e225d8dcf05f070d8223a61bc23efc1872e /cmake/scripts
parentd209e65b1d9ce3f49821970e96e027ba5243e386 (diff)
downloaddexon-solidity-54ab787b83275fd374b3951ec3efa577c954bd1a.tar.gz
dexon-solidity-54ab787b83275fd374b3951ec3efa577c954bd1a.tar.zst
dexon-solidity-54ab787b83275fd374b3951ec3efa577c954bd1a.zip
Make versioning semver compatible and force commit hash availability.
Diffstat (limited to 'cmake/scripts')
-rw-r--r--cmake/scripts/buildinfo.cmake52
1 files changed, 35 insertions, 17 deletions
diff --git a/cmake/scripts/buildinfo.cmake b/cmake/scripts/buildinfo.cmake
index 39359486..0d2d8870 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,44 @@ 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)
+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")