Skip to content

Commit

Permalink
Merge pull request ethereum#941 from chriseth/versionString
Browse files Browse the repository at this point in the history
Version string
  • Loading branch information
bobsummerwill authored Aug 27, 2016
2 parents d14d710 + 4588eda commit 91d4fa4
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ cache:

install:
- test $TRAVIS_INSTALL_DEPS != On || ./scripts/install_deps.sh
- echo -n "$TRAVIS_COMMIT" > commit_hash.txt
- test "$TRAVIS_PULL_REQUESTS" != "false" || test "$TRAVIS_BRANCH" != release || echo -n > prerelease.txt # this is a proper release
before_script:
- test $TRAVIS_EMSCRIPTEN != On || ./scripts/build_emscripten.sh
- test $TRAVIS_RELEASE != On || (mkdir -p build
Expand Down
4 changes: 1 addition & 3 deletions cmake/EthBuildInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
)
Expand Down
53 changes: 36 additions & 17 deletions cmake/scripts/buildinfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")

Expand Down
15 changes: 7 additions & 8 deletions cmake/templates/BuildInfo.h.in
Original file line number Diff line number Diff line change
@@ -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@"
6 changes: 2 additions & 4 deletions libsolidity/interface/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ char const* dev::solidity::VersionNumber = ETH_PROJECT_VERSION;

string const dev::solidity::VersionString =
string(dev::solidity::VersionNumber) +
"-" +
string(DEV_QUOTED(ETH_COMMIT_HASH)).substr(0, 8) +
(ETH_CLEAN_REPO ? "" : "*") +
"/" DEV_QUOTED(ETH_BUILD_TYPE) "-" DEV_QUOTED(ETH_BUILD_PLATFORM);
(string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) +
(string(SOL_VERSION_BUILDINFO).empty() ? "" : "+" + string(SOL_VERSION_BUILDINFO));


bytes dev::solidity::binaryVersion()
Expand Down
1 change: 1 addition & 0 deletions scripts/build_emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
set -e

if [[ "$OSTYPE" != "darwin"* ]]; then
date -u +"nightly.%Y.%m.%d" > prerelease.txt
./scripts/travis-emscripten/install_deps.sh
docker run -v $(pwd):/src trzeci/emscripten:sdk-tag-1.35.4-64bit ./scripts/travis-emscripten/build_emscripten.sh
fi
4 changes: 2 additions & 2 deletions scripts/release_ppa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ commithash=`git rev-parse --short HEAD`
committimestamp=`git show --format=%ci HEAD | head -n 1`
commitdate=`git show --format=%ci HEAD | head -n 1 | cut - -b1-10`

# TODO store the commit hash in a file so that the build info mechanism can pick it up even without git

echo "$commithash" > commit_hash.txt
if [ $branch = develop ]
then
debversion="$version-nightly-$commitdate-$commithash"
else
debversion="$version"
echo -n > prerelease.txt # proper release
fi

# gzip will create different tars all the time and we are not allowed
Expand Down

0 comments on commit 91d4fa4

Please sign in to comment.