aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--cmake/EthBuildInfo.cmake4
-rw-r--r--cmake/scripts/buildinfo.cmake53
-rw-r--r--cmake/templates/BuildInfo.h.in15
-rw-r--r--docs/contracts.rst31
-rw-r--r--docs/index.rst2
-rw-r--r--docs/installing-solidity.rst14
-rw-r--r--docs/introduction-to-smart-contracts.rst12
-rw-r--r--docs/types.rst9
-rw-r--r--libsolidity/interface/Version.cpp6
-rwxr-xr-xscripts/build_emscripten.sh1
-rwxr-xr-xscripts/release_ppa.sh4
12 files changed, 89 insertions, 64 deletions
diff --git a/.travis.yml b/.travis.yml
index 1b0ff15d..da9bd2f9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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
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@"
diff --git a/docs/contracts.rst b/docs/contracts.rst
index dfdcaf18..d3a89c1e 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -195,45 +195,47 @@ return parameter list for functions.
uint public data;
}
-An other contract ``D`` can call ``c.getData()`` to retrieve the value of data in state
-storage and is not able to call ``f``. Contract ``E`` is derived from ``C`` and can call
-``compute``.
+In the following example, ``D``, can call ``c.getData()`` to retrieve the value of
+``data`` in state storage, but is not able to call ``f``. Contract ``E`` is derived from
+``C`` and, thus, can call ``compute``.
::
contract C {
+ uint private data;
+
function f(uint a) private returns(uint b) { return a + 1; }
function setData(uint a) { data = a; }
- function getData() public returns(uint) {return data;}
- function compute(uint a, uint b) internal returns (uint) { return a+b;}
- uint private data;
+ function getData() public returns(uint) { return data; }
+ function compute(uint a, uint b) internal returns (uint) { return a+b; }
}
+
contract D {
function readData() {
C c = new C();
- local = c.f(7); // error: member "f" is not visible
+ uint local = c.f(7); // error: member "f" is not visible
c.setData(3);
- uint local = c.getData();
- local = c.compute(3,5); // error: member "compute" is not visible
+ local = c.getData();
+ local = c.compute(3, 5); // error: member "compute" is not visible
}
}
+
contract E is C {
function g() {
C c = new C();
- uint val = compute(3,5); // acces to internal member (from derivated to parent contract)
+ uint val = compute(3, 5); // acces to internal member (from derivated to parent contract)
}
}
-
.. index:: ! accessor;function, ! function;accessor
Accessor Functions
==================
The compiler automatically creates accessor functions for
-all public state variables. For the contract given below the compiler will
+all public state variables. For the contract given below, the compiler will
generate a function called ``data`` that does not take any
arguments and returns a ``uint``, the value of the state
variable ``data``. The initialization of state variables can
@@ -245,6 +247,7 @@ be done at declaration.
uint public data = 42;
}
+
contract Caller {
C c = new C();
function f() {
@@ -254,8 +257,8 @@ be done at declaration.
The accessor functions have external visibility. If the
symbol is accessed internally (i.e. without ``this.``),
-it is evaluated as state variable and if it is accessed externally
-(i.e. with ``this.``), it is evaluated as function.
+it is evaluated as a state variable and if it is accessed externally
+(i.e. with ``this.``), it is evaluated as a function.
::
diff --git a/docs/index.rst b/docs/index.rst
index 2c983d1e..a5ab3f86 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -66,7 +66,7 @@ Discontinued:
Solidity Tools
--------------------------------
+--------------
* `Solidity REPL <https://github.com/raineorshine/solidity-repl>`_
Try Solidity instantly with a command-line Solidity console.
diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst
index e1322f12..f8393f2d 100644
--- a/docs/installing-solidity.rst
+++ b/docs/installing-solidity.rst
@@ -93,18 +93,18 @@ you should fork Solidity and add your personal fork as a second remote:
.. code:: bash
cd solidity
- git remote add personal git@github.com:[username]/solidity.git
+ git remote add personal git@github.com:\<username\>/solidity.git
Prerequisites - macOS
-----------------------
+---------------------
For macOS, ensure that you have the latest version of
-`xcode installed <https://developer.apple.com/xcode/download/>`_.
+`Xcode installed <https://developer.apple.com/xcode/download/>`_.
This contains the `Clang C++ compiler <https://en.wikipedia.org/wiki/Clang>`_, the
-`xcode IDE <https://en.wikipedia.org/wiki/Xcode>`_ and other Apple development
+`Xcode IDE <https://en.wikipedia.org/wiki/Xcode>`_ and other Apple development
tools which are required for building C++ applications on OS X.
-If you are installing xcode for the first time, or have just installed a new
+If you are installing Xcode for the first time, or have just installed a new
version then you will need to agree to the license before you can do
command-line builds:
@@ -120,7 +120,7 @@ if you ever want to start again from scratch.
Prerequisites - Windows
-------------------------
+-----------------------
You will need to install the following dependencies for Windows builds of Solidity:
@@ -152,7 +152,7 @@ manual process, but is now a one-liner:
Or, on Windows:
-.. code:: bash
+.. code:: bat
scripts\install_deps.bat
diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst
index fbce4244..6fcd4854 100644
--- a/docs/introduction-to-smart-contracts.rst
+++ b/docs/introduction-to-smart-contracts.rst
@@ -220,7 +220,7 @@ only the person holding the keys to the account can transfer money from it.
Blocks
======
-One major obstacle to overcome is what, in Bitcoin terms, is called "double-spend attack":
+One major obstacle to overcome is what, in Bitcoin terms, is called a "double-spend attack":
What happens if two transactions exist in the network that both want to empty an account,
a so-called conflict?
@@ -444,13 +444,13 @@ receives the address of the new contract on the stack.
.. index:: selfdestruct
-Selfdestruct
-============
+``selfdestruct``
+================
The only possibility that code is removed from the blockchain is
-when a contract at that address performs the ``SELFDESTRUCT`` operation.
+when a contract at that address performs the ``selfdestruct`` operation.
The remaining Ether stored at that address is sent to a designated
target and then the storage and code is removed.
-Note that even if a contract's code does not contain the ``SELFDESTRUCT``
-opcode, it can still perform that operation using delegatecall or callcode.
+Note that even if a contract's code does not contain a call to ``selfdestruct``,
+it can still perform that operation using ``delegatecall`` or ``callcode``.
diff --git a/docs/types.rst b/docs/types.rst
index d6445ed9..737fbe7d 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -661,13 +661,18 @@ Explicit Conversions
--------------------
If the compiler does not allow implicit conversion but you know what you are
-doing, an explicit type conversion is sometimes possible::
+doing, an explicit type conversion is sometimes possible. Note that this may
+give you some unexpected behaviour so be sure to test to ensure that the
+result is what you want! Take the following example where you are converting
+a negative ``int8`` to a ``uint``:
+
+::
int8 y = -3;
uint x = uint(y);
At the end of this code snippet, ``x`` will have the value ``0xfffff..fd`` (64 hex
-characters), which is -3 in two's complement representation of 256 bits.
+characters), which is -3 in the two's complement representation of 256 bits.
If a type is explicitly converted to a smaller type, higher-order bits are
cut off::
diff --git a/libsolidity/interface/Version.cpp b/libsolidity/interface/Version.cpp
index a846efea..31ba4afc 100644
--- a/libsolidity/interface/Version.cpp
+++ b/libsolidity/interface/Version.cpp
@@ -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()
diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh
index 6046978e..da2c7df3 100755
--- a/scripts/build_emscripten.sh
+++ b/scripts/build_emscripten.sh
@@ -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
diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh
index 2fd286fd..8e9dc282 100755
--- a/scripts/release_ppa.sh
+++ b/scripts/release_ppa.sh
@@ -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