Permalink
Branch: master
Find file Copy path
129 lines (92 sloc) 4.52 KB

Building and Developing Scilla

Please, read the instructions below if you intend to hack on Scilla implementation.

Platform-specific setup for building Scilla

Setup OCaml using the instructions here. Make sure you have switched (using opam switch) to a version not older than the one specified below.

openSUSE

Ubuntu

On machines with Ubuntu strictly older than 18.04, run these additional commands first:

# Add Ubuntu PPA for libsecp256k1-dev
sudo add-apt-repository ppa:tah83/secp256k1 -y

Required ubuntu packages can be installed as below:

sudo add-apt-repository -y ppa:avsm/ppa
sudo apt-get update
sudo apt-get install -y curl build-essential m4 ocaml opam pkg-config zlib1g-dev libgmp-dev libffi-dev libssl-dev libboost-system-dev libsecp256k1-dev

OCaml toolchain

Building Scilla requires OCaml 4.06.1. You can switch to this version and install required opam packages using the commands listed below:

opam init --disable-sandboxing -y --compiler=4.06.1
opam install ocaml-migrate-parsetree core cryptokit ppx_sexp_conv yojson batteries angstrom hex ppx_deriving menhir oUnit dune stdint fileutils ctypes ctypes-foreign bisect_ppx secp256k1

The above three commands can, alternatively, be run using the make target opamdep

make opamdep

Finally, opam environment needs to be set in your shell. This can be done as:

echo ". ~/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true " >> ~/.bashrc

Note that the command above does not setup the environment for the current shell. Either quit and start a new shell (so that ~/.bashrc is invoked) OR, run the following command to setup the environment for your current shell.

eval `opam config env`

Scilla requires OpenSSL 1.0.2 and if your platform does not have packages for this, you may need to build OpenSSL yourself and set $CPLUS_INCLUDE_PATH, $C_INCLUDE_PATH, $LIBRARY_PATH and $LD_LIBRARY_PATH accordingly (if you install OpenSSL in a non-default path).

macOS

The dependencies can be installed via Homebrew:

Note: pending PR at https://github.com/DomT4/homebrew-crypto/pull/95/commits/9c62017362aa973afad75616046d14006f31be6a

brew tap iantanwx/crypto
brew install ocaml opam pkg-config libffi openssl@1.1 boost secp256k1
opam init --disable-sandboxing -y --compiler=4.06.1
opam install ocaml-migrate-parsetree core cryptokit ppx_sexp_conv yojson batteries angstrom hex ppx_deriving menhir oUnit dune stdint fileutils ctypes ctypes-foreign bisect_ppx secp256k1

Then run the following command to setup environment on current shell.

eval `opam config env`

Homebrew's openssl package is keg-only, which means it doesn't get symlinked into /usr/local directory, so (as mentioned above) you need to setup LIBRARY_PATH environment variable as follows

export LIBRARY_PATH=/usr/local/opt/openssl@1.1/lib:$LIBRARY_PATH

or invoke make command like so:

LIBRARY_PATH=/usr/local/opt/openssl@1.1/lib make

Using Ocaml with Emacs

As Scilla is written in OCaml, the following extensions would be useful for working on this codebase:

All those libraries can be installed via opem-user-setup:

opam install user-setup

To enable flycheck mode (integration of scilla-checker with Emacs for editing Scilla files), install flycheck for Emacs. See installation instructions here.