Force commit hash to 8 digits.

This commit is contained in:
chriseth 2016-09-15 01:47:16 +02:00
parent 2bee7e9171
commit af86bfb07d
3 changed files with 10 additions and 7 deletions

View File

@ -34,7 +34,7 @@ if (EXISTS ${ETH_SOURCE_DIR}/commit_hash.txt)
string(STRIP ${SOL_COMMIT_HASH} SOL_COMMIT_HASH) string(STRIP ${SOL_COMMIT_HASH} SOL_COMMIT_HASH)
else() else()
execute_process( 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 OUTPUT_VARIABLE SOL_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
) )
execute_process( execute_process(
@ -48,14 +48,17 @@ if (SOL_COMMIT_HASH)
string(SUBSTRING ${SOL_COMMIT_HASH} 0 8 SOL_COMMIT_HASH) string(SUBSTRING ${SOL_COMMIT_HASH} 0 8 SOL_COMMIT_HASH)
endif() endif()
if (SOL_COMMIT_HASH AND SOL_LOCAL_CHANGES)
set(SOL_COMMIT_HASH "${SOL_COMMIT_HASH}.mod")
endif()
if (NOT SOL_COMMIT_HASH) if (NOT SOL_COMMIT_HASH)
message(FATAL_ERROR "Unable to determine commit hash. Either compile from within git repository or " message(FATAL_ERROR "Unable to determine commit hash. Either compile from within git repository or "
"supply a file called commit_hash.txt") "supply a file called commit_hash.txt")
endif() 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}") set(SOL_VERSION_BUILDINFO "commit.${SOL_COMMIT_HASH}.${ETH_BUILD_PLATFORM}")

View File

@ -52,7 +52,7 @@ mv solidity solc
# Determine version # Determine version
cd solc cd solc
version=`grep -oP "PROJECT_VERSION \"?\K[0-9.]+(?=\")"? CMakeLists.txt` version=`grep -oP "PROJECT_VERSION \"?\K[0-9.]+(?=\")"? CMakeLists.txt`
commithash=`git rev-parse --short HEAD` commithash=`git rev-parse --short=8 HEAD`
committimestamp=`git show --format=%ci HEAD | head -n 1` committimestamp=`git show --format=%ci HEAD | head -n 1`
commitdate=`git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./'` commitdate=`git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./'`

View File

@ -33,7 +33,7 @@ set -e
VER=$(cat CMakeLists.txt | grep 'set(PROJECT_VERSION' | sed -e 's/.*set(PROJECT_VERSION "\(.*\)".*/\1/') VER=$(cat CMakeLists.txt | grep 'set(PROJECT_VERSION' | sed -e 's/.*set(PROJECT_VERSION "\(.*\)".*/\1/')
test -n "$VER" test -n "$VER"
VER="v$VER" VER="v$VER"
COMMIT=$(git rev-parse --short HEAD) COMMIT=$(git rev-parse --short=8 HEAD)
DATE=$(date --date="$(git log -1 --date=iso --format=%ad HEAD)" --utc +%Y.%-m.%-d) DATE=$(date --date="$(git log -1 --date=iso --format=%ad HEAD)" --utc +%Y.%-m.%-d)
# remove leading zeros in components - they are not semver-compatible # remove leading zeros in components - they are not semver-compatible