Quellcode durchsuchen

Add initial docs

Signed-off-by: Sean <sean@mess.org>
Sean vor 6 Jahren
Ursprung
Commit
148d75d738
9 geänderte Dateien mit 291 neuen und 16 gelöschten Zeilen
  1. 1 0
      .gitignore
  2. 1 1
      README.md
  3. 0 15
      build-llvm.sh
  4. 20 0
      docs/Makefile
  5. 56 0
      docs/conf.py
  6. 31 0
      docs/index.rst
  7. 147 0
      docs/installing.rst
  8. 35 0
      docs/make.bat
  9. 0 0
      docs/solang.svg

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 
+/docs/build
 Cargo.lock
 /target
 **/*.rs.bk

+ 1 - 1
README.md

@@ -2,7 +2,7 @@
 
 [![CI](https://github.com/hyperledger-labs/solang/workflows/test/badge.svg)]
 
-<img align="right" width="400" height="400" src="doc/solang.svg">
+<img align="right" width="400" height="400" src="docs/solang.svg">
 
 This is solang, a proof of concept
 [solidity](https://en.wikipedia.org/wiki/Solidity) compiler. The

+ 0 - 15
build-llvm.sh

@@ -1,15 +0,0 @@
-
-
-svn co http://llvm.org/svn/llvm-project/llvm/branches/release_80 llvm-src
-cd llvm-src/tools
-svn co http://llvm.org/svn/llvm-project/cfe/branches/release_80 clang
-svn co http://llvm.org/svn/llvm-project/lld/branches/release_80 lld
-cd ../..
-mkdir llvm-build
-cd llvm-build
-cmake -G Ninja -DLLVM_TARGETS_TO_BUILD=WebAssembly -DCMAKE_INSTALL_PREFIX=../llvm -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_ENABLE_ASSERTIONS=ON ../llvm-src
-cmake --build . --target install
-cd ..
-# ensure llvm-config is in the path
-export PATH=$(pwd)/llvm/bin:$PATH 
-cargo build

+ 20 - 0
docs/Makefile

@@ -0,0 +1,20 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SPHINXOPTS    ?=
+SPHINXBUILD   ?= sphinx-build
+SOURCEDIR     = .
+BUILDDIR      = build
+
+# Put it first so that "make" without argument is like "make help".
+help:
+	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help Makefile
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

+ 56 - 0
docs/conf.py

@@ -0,0 +1,56 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# This file only contains a selection of the most common options. For a full
+# list see the documentation:
+# http://www.sphinx-doc.org/en/master/config
+
+# -- Path setup --------------------------------------------------------------
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+# import os
+# import sys
+# sys.path.insert(0, os.path.abspath('.'))
+
+
+# -- Project information -----------------------------------------------------
+
+project = 'Solang Solidity Compiler'
+copyright = '2019, Sean Young <sean@mess.org>'
+author = 'Sean Young <sean@mess.org>'
+
+# The full version, including alpha/beta/rc tags
+release = '0.1.0'
+
+
+# -- General configuration ---------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This pattern also affects html_static_path and html_extra_path.
+exclude_patterns = []
+
+
+# -- Options for HTML output -------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+#
+#html_theme = 'alabaster'
+html_theme = 'sphinx_rtd_theme'
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']

+ 31 - 0
docs/index.rst

@@ -0,0 +1,31 @@
+Solang Solidity Compiler
+========================
+
+Welcome the solang Solidity compiler. Using solang, you can compile 
+smart contracts written in `Solidity <https://en.wikipedia.org/wiki/Solidity>`_ for `Substrate <https://substrate.dev/>`_ or `Hyperledger Burrow <https://github.com/hyperledger/burrow>`_. It uses the
+`llvm <https://www.llvm.org/>`_ compiler framework to produce WebAssembly
+(wasm). As result, the output is highly optimized, which saves you in gas costs.
+
+The Solidity language support is not fully compatible with the Ethereum
+EVM Solidity compiler. Where differences exists, this is noted in the
+documentation. In our flavour of solidity, there are also novel features
+like the condition argument to the ``if`` statement does not need
+parentheses, like in Go or rust.
+
+Many language features are not implemented yet. Anything which is documented
+is supported, though.
+
+.. toctree::
+   :maxdepth: 3
+   :caption: Contents:
+
+   installing
+   running
+   language
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`

+ 147 - 0
docs/installing.rst

@@ -0,0 +1,147 @@
+Installing Solang
+=================
+
+The solang compiler is a single binary. It can be installed in many different
+ways, so please pick whatever method suits your needs.
+
+Using hyperledgerlabs/solang docker hub images
+----------------------------------------------
+
+Simply pull the latest docker image using::
+
+	docker pull hyperledgerlabs/solang
+
+And if you are using podman::
+
+	podman image pull hyperlederlabs/solang
+
+The solang binary is in ``/usr/bin/solang`` in this image. The latest tag
+gets updated each time there is a commit to the master branch of the solang
+git repository.
+
+Build solang from source using Dockerfile
+-----------------------------------------
+
+First clone the git repo using::
+
+  git clone https://github.com/hyperledger-labs/solang
+
+Then you can build the image using::
+
+	docker build .
+
+Alternatively this will work with podman too::
+
+	podman image build .
+
+Building solang from source using cargo
+---------------------------------------
+
+solang is listed on `crates.io <https://crates.io/crates/solang>`_. Only
+releases are pushed to cargo. Do install using cargo::
+
+	cargo install solang
+
+You will need the llvm libraries for this to work, see 
+`Getting the right version of LLVM`_.
+
+Building solang from source
+---------------------------
+In order to build solang from source, you will need rust 1.33.0 or higher,
+and llvm version 8 or higher with the WebAssembly target enabled.
+
+So see if you have the correct version of rust, simply execute::
+
+  rustc --version
+
+If you do not have the correct version of rust installed, go to `rustup <https://rustup.rs/>`_.
+
+To make sure you have the correct version of the llvm libraries installed, first run::
+
+  llvm-config --version
+
+The output should be 8.0 or higher. Then check if the WebAssembly target is enabled by running::
+
+  llc --version
+
+You should see wasm32 listed under the target. Lastly check that the static libraries are installed::
+
+  llvm-version --link-static --libs
+
+If there is no output, there are no static llvm libraries and building will fail.
+
+After making sure llvm and rust are installed, just run::
+
+  cargo build --release
+
+The executable will be in ``target/release/solang``.
+
+Getting the right version of LLVM
+---------------------------------
+If you did not have the llvm libraries installed then you can either install
+your systems llvm packages or compile your own. Compiling your own is helpful
+if you want to do solang development.
+
+Any version from llvm 8.0 will do. Note that you will also need clang; the
+Solidity standard library is written in C, and is compiled to wasm by
+clang. For this to work, the version of clang **must** be the same as the
+version of llvm.
+
+Installing LLVM on Ubuntu
+_________________________
+
+You will need ubuntu 18.04 with backports or later. Just run::
+
+	sudo apt install curl llvm clang git zlib1g-dev cargo
+
+Installing LLVM on Fedora
+_________________________
+
+You will need Fedora 30 or later. Running the following::
+
+	sudo dnf install cargo llvm8.0-static llvm8.0-devel zlib-devel clang
+
+Installing LLVM from source
+___________________________
+
+If your system does not come with llvm, then you have to build your own.
+Building your own llvm libraries does not interfere with any llvm libraries
+installed by your distribution.
+
+The llvm project is a large code base so it will take some time to build.
+
+If you are planning to do development on solang itself, then having your
+own built llvm is very helpful. The distributions build llvm without 
+assertions enabled. These assertions check that the IR that solang builds
+is correct. If the IR is not correct, then faults might happen when llvm
+runs compiler passes on the IR and the stack trace will not be useful
+to debug this problem.
+
+The llvm project itself has a guide to `installing from source <http://www.llvm.org/docs/CMake.html>`_ which you may need to consult. 
+First if all clone the llvm repository::
+
+	git clone https://github.com/llvm/llvm-project
+	cd llvm-project
+
+Now switch to the 8.0 release branch::
+
+	git checkout -b release_8.x origin/release/8.x
+
+Ensure that clang will built::
+
+	ln -s clang llvm/tools/clang
+
+Create a directory where the build and intermediate files will be stored::
+
+	mkdir build
+	cd build
+
+Now run cmake to create the makefiles. Replace the *installdir* argument to ``CMAKE_INSTALL_PREFIX`` with with a directory where you would like to have llvm installed, and then run the build::
+
+	cmake -G Ninja -DLLVM_TARGETS_TO_BUILD=WebAssembly -DLLVM_ENABLE_ASSERTIONS=On -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=installdir ../llvm
+	cmake --build . --target install
+
+Once the build has succeeded, the *installdir*/bin has to be added to your path so the solang build can find this llvm config:
+
+	export PATH=*installdir*/bin:$PATH
+

+ 35 - 0
docs/make.bat

@@ -0,0 +1,35 @@
+@ECHO OFF
+
+pushd %~dp0
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set SOURCEDIR=.
+set BUILDDIR=build
+
+if "%1" == "" goto help
+
+%SPHINXBUILD% >NUL 2>NUL
+if errorlevel 9009 (
+	echo.
+	echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+	echo.installed, then set the SPHINXBUILD environment variable to point
+	echo.to the full path of the 'sphinx-build' executable. Alternatively you
+	echo.may add the Sphinx directory to PATH.
+	echo.
+	echo.If you don't have Sphinx installed, grab it from
+	echo.http://sphinx-doc.org/
+	exit /b 1
+)
+
+%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+goto end
+
+:help
+%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+
+:end
+popd

+ 0 - 0
doc/solang.svg → docs/solang.svg