solidity/docs/installing-solidity.rst

267 lines
8.2 KiB
ReStructuredText
Raw Normal View History

2016-08-29 17:24:28 +00:00
.. index:: ! installing
.. _installing-solidity:
2015-12-10 11:22:53 +00:00
###################
Installing Solidity
###################
2016-09-08 17:44:14 +00:00
Versioning
==========
2016-10-12 08:25:17 +00:00
Solidity versions follow `semantic versioning <https://semver.org>`_ and in addition to
2016-09-08 17:44:14 +00:00
releases, **nightly development builds** are also made available. The nightly builds
are not guaranteed to be working and despite best efforts they might contain undocumented
2016-10-26 17:43:51 +00:00
and/or broken changes. We recommend using the latest release. Package installers below
2016-09-13 11:13:21 +00:00
will use the latest release.
2016-09-08 17:44:14 +00:00
2015-12-10 11:22:53 +00:00
Browser-Solidity
================
If you just want to try Solidity for small contracts, you
2016-05-20 10:52:32 +00:00
can try `browser-solidity <https://ethereum.github.io/browser-solidity>`_
2015-12-10 11:22:53 +00:00
which does not need any installation. If you want to use it
without connection to the Internet, you can go to
https://github.com/ethereum/browser-solidity/tree/gh-pages and
download the .ZIP file as explained on that page.
2016-05-19 17:27:57 +00:00
npm / Node.js
2015-12-10 11:22:53 +00:00
=============
This is probably the most portable and most convenient way to install Solidity locally.
A platform-independent JavaScript library is provided by compiling the C++ source
into JavaScript using Emscripten. It can be used in projects directly (such as Browser-Solidity).
Please refer to the `solc-js <https://github.com/ethereum/solc-js>`_ repository for instructions.
2015-12-10 11:22:53 +00:00
It also contains a commandline tool called `solcjs`, which can be installed via npm:
2015-12-10 11:22:53 +00:00
.. code:: bash
2015-12-10 11:22:53 +00:00
npm install -g solc
.. note::
2015-12-10 11:22:53 +00:00
The comandline options of `solcjs` are not compatible with `solc` and tools (such as `geth`)
expecting the behaviour of `solc` will not work with `solcjs`.
2015-12-10 11:22:53 +00:00
2016-11-24 22:46:37 +00:00
Docker
======
2016-11-25 15:21:17 +00:00
We provide up to date docker builds for the compiler. The ``stable``
repository contains released versions while the ``nightly``
repository contains potentially unstable changes in the develop branch.
2016-11-24 22:46:37 +00:00
.. code:: bash
docker run ethereum/solc:stable solc --version
Currenty, the docker image only contains the compiler executable,
so you have to do some additional work to link in the source and
output directories.
2015-12-10 11:22:53 +00:00
Binary Packages
===============
Binary packages of Solidity available at
`solidity/releases <https://github.com/ethereum/solidity/releases>`_.
We also have PPAs for Ubuntu. For the latest stable version.
.. code:: bash
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
If you want to use the cutting edge developer version:
.. code:: bash
sudo add-apt-repository ppa:ethereum/ethereum
sudo add-apt-repository ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install solc
Arch Linux also has packages, albeit limited to the latest development version:
.. code:: bash
pacman -S solidity-git
Homebrew is missing pre-built bottles at the time of writing,
following a Jenkins to TravisCI migration, but Homebrew
should still work just fine as a means to build-from-source.
We will re-add the pre-built bottles soon.
.. code:: bash
brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
brew linkapps solidity
2015-12-10 11:22:53 +00:00
2016-08-29 17:24:28 +00:00
.. _building-from-source:
2015-12-10 11:22:53 +00:00
Building from Source
====================
Clone the Repository
--------------------
To clone the source code, execute the following command:
.. code:: bash
git clone --recursive https://github.com/ethereum/solidity.git
cd solidity
If you want to help developing Solidity,
you should fork Solidity and add your personal fork as a second remote:
.. code:: bash
2015-12-10 11:22:53 +00:00
cd solidity
2016-08-29 18:22:52 +00:00
git remote add personal git@github.com:[username]/solidity.git
2015-12-10 11:22:53 +00:00
Solidity has git submodules. Ensure they are properly loaded:
.. code:: bash
git submodule update --init --recursive
2015-12-10 11:22:53 +00:00
Prerequisites - macOS
2016-08-24 20:33:59 +00:00
---------------------
2015-12-10 11:22:53 +00:00
For macOS, ensure that you have the latest version of
2016-08-24 20:33:59 +00:00
`Xcode installed <https://developer.apple.com/xcode/download/>`_.
This contains the `Clang C++ compiler <https://en.wikipedia.org/wiki/Clang>`_, the
2016-08-24 20:33:59 +00:00
`Xcode IDE <https://en.wikipedia.org/wiki/Xcode>`_ and other Apple development
tools which are required for building C++ applications on OS X.
2016-08-24 20:33:59 +00:00
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:
2015-12-10 11:22:53 +00:00
.. code:: bash
2015-12-10 11:22:53 +00:00
sudo xcodebuild -license accept
2015-12-10 11:22:53 +00:00
Our OS X builds require you to `install the Homebrew <http://brew.sh>`_
package manager for installing external dependencies.
Here's how to `uninstall Homebrew
<https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/FAQ.md#how-do-i-uninstall-homebrew>`_,
if you ever want to start again from scratch.
2016-05-13 14:32:35 +00:00
2015-12-10 11:22:53 +00:00
Prerequisites - Windows
2016-08-24 20:33:59 +00:00
-----------------------
You will need to install the following dependencies for Windows builds of Solidity:
+------------------------------+-------------------------------------------------------+
| Software | Notes |
+==============================+=======================================================+
| `Git for Windows`_ | Command-line tool for retrieving source from Github. |
+------------------------------+-------------------------------------------------------+
| `CMake`_ | Cross-platform build file generator. |
+------------------------------+-------------------------------------------------------+
| `Visual Studio 2015`_ | C++ compiler and dev environment. |
+------------------------------+-------------------------------------------------------+
.. _Git for Windows: https://git-scm.com/download/win
.. _CMake: https://cmake.org/download/
.. _Visual Studio 2015: https://www.visualstudio.com/products/vs-2015-product-editions
2016-08-11 20:50:27 +00:00
External Dependencies
---------------------
2015-12-10 11:22:53 +00:00
We now have a "one button" script which installs all required external dependencies
on macOS, Windows and on numerous Linux distros. This used to be a multi-step
manual process, but is now a one-liner:
2015-12-10 11:22:53 +00:00
.. code:: bash
2015-12-10 11:22:53 +00:00
./scripts/install_deps.sh
2015-12-10 11:22:53 +00:00
Or, on Windows:
2016-08-11 20:50:27 +00:00
2016-08-29 14:23:40 +00:00
.. code:: bat
2016-07-11 15:23:17 +00:00
scripts\install_deps.bat
2015-12-10 11:22:53 +00:00
Command-Line Build
------------------
2015-12-10 11:22:53 +00:00
Building Solidity is quite similar on Linux, macOS and other Unices:
.. code:: bash
2015-12-10 11:22:53 +00:00
2016-08-04 09:04:13 +00:00
mkdir build
cd build
cmake .. && make
2015-12-10 11:22:53 +00:00
or even easier:
.. code:: bash
#note: this will install binaries solc and soltest at usr/local/bin
./scripts/build.sh
And even for Windows:
2015-12-10 11:22:53 +00:00
.. code:: bash
2015-12-10 11:22:53 +00:00
mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" ..
This latter set of instructions should result in the creation of
**solidity.sln** in that build directory. Double-clicking on that file
should result in Visual Studio firing up. We suggest building
**RelWithDebugInfo** configuration, but all others work.
Alternatively, you can build for Windows on the command-line, like so:
.. code:: bash
cmake --build . --config RelWithDebInfo
2016-09-13 11:13:21 +00:00
2017-01-17 12:32:07 +00:00
The version string in detail
============================
The Solidity version string contains four parts:
- the version number
- pre-release tag, usually set to ``develop.YYYY.MM.DD`` or ``nightly.YYYY.MM.DD``
- commit in the format of ``commit.GITHASH``
- platform has arbitrary number of items, containing details about the platform and compiler
If there are local modifications, the commit will be postfixed with ``.mod``.
2017-01-17 13:01:11 +00:00
These parts are combined as required by Semver, where the Solidity pre-release tag equals to the Semver pre-release
and the Solidity commit and platform combined make up the Semver build metadata.
2017-01-17 12:32:07 +00:00
A relase example: ``0.4.8+commit.60cc1668.Emscripten.clang``.
A pre-release example: ``0.4.9-nightly.2017.1.17+commit.6ecb4aa3.Emscripten.clang``
2016-09-13 11:13:21 +00:00
Important information about versioning
======================================
After a release is made, the patch version level is bumped, because we assume that only
patch level changes follow. When changes are merged, the version should be bumped according
to semver and the severity of the change. Finally, a release is always made with the version
of the current nightly build, but without the ``prerelease`` specifier.
Example:
2016-09-23 16:27:23 +00:00
0. the 0.4.0 release is made
1. nightly build has a version of 0.4.1 from now on
2. non-breaking changes are introduced - no change in version
3. a breaking change is introduced - version is bumped to 0.5.0
4. the 0.5.0 release is made
2016-09-13 11:13:21 +00:00
This behaviour works well with the version pragma.