diff options
author | chriseth <c@ethdev.com> | 2016-09-15 07:47:16 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-09-15 07:47:37 +0800 |
commit | af86bfb07df801d4b9b2d9782f3a6c764a2b9859 (patch) | |
tree | 6709b5ddb8e5780455ab6a98b08abf0808e47de7 /cmake | |
parent | 2bee7e91716a2bfee826f7b648c4cc6de888abbb (diff) | |
download | dexon-solidity-af86bfb07df801d4b9b2d9782f3a6c764a2b9859.tar.gz dexon-solidity-af86bfb07df801d4b9b2d9782f3a6c764a2b9859.tar.zst dexon-solidity-af86bfb07df801d4b9b2d9782f3a6c764a2b9859.zip |
Force commit hash to 8 digits.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/scripts/buildinfo.cmake | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmake/scripts/buildinfo.cmake b/cmake/scripts/buildinfo.cmake index f0e39906..e6077a34 100644 --- a/cmake/scripts/buildinfo.cmake +++ b/cmake/scripts/buildinfo.cmake @@ -34,7 +34,7 @@ if (EXISTS ${ETH_SOURCE_DIR}/commit_hash.txt) 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 + COMMAND git --git-dir=${ETH_SOURCE_DIR}/.git --work-tree=${ETH_SOURCE_DIR} rev-parse --short=8 HEAD OUTPUT_VARIABLE SOL_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) execute_process( @@ -48,14 +48,17 @@ if (SOL_COMMIT_HASH) string(SUBSTRING ${SOL_COMMIT_HASH} 0 8 SOL_COMMIT_HASH) endif() -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() +if (NOT SOL_COMMIT_HASH MATCHES [a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]) + message(FATAL_ERROR "Malformed commit hash \"${SOL_COMMIT_HASH}\". It has to consist of exactly 8 hex digits.") +endif() + +if (SOL_COMMIT_HASH AND SOL_LOCAL_CHANGES) + set(SOL_COMMIT_HASH "${SOL_COMMIT_HASH}.mod") +endif() set(SOL_VERSION_BUILDINFO "commit.${SOL_COMMIT_HASH}.${ETH_BUILD_PLATFORM}") |