EOS源代码运行(二)
2018-01-24 本文已影响342人
wangwei_hz
本文介绍如何手动构建EOS源代码
eos-logo
系统环境
- macOS Sierra 10.12.6
升级XCode和brew
-
升级XCode
$ xcode-select --install
-
升级brew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装依赖工具
-
基础工具
$ brew update $ brew install git automake libtool boost openssl llvm@4 gmp cmake
-
secp256k1-zkp (Cryptonomex branch)
$ git clone https://github.com/cryptonomex/secp256k1-zkp.git $ cd secp256k1-zkp $ ./autogen.sh $ ./configure $ make $ sudo make install
-
$ git clone https://github.com/WebAssembly/binaryen.git $ cd ~/binaryen $ git checkout tags/1.37.14 $ cmake -DCMAKE_C_COMPILER="$(brew --prefix llvm@4)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@4)/bin/clang++" . && make
配置环境变量
$ echo "export BINARYEN_ROOT=/usr/local/binaryen" >> ~/.bash_profile $ source ~/.bash_profile
编译WASM环境
$ mkdir ~/wasm-compiler
$ cd wasm-compiler
$ git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
$ cd llvm/tools
$ git clone --depth 1 --single-branch --branch release_40 http://llvm.org/git/clang.git
$ cd ..
$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../
$ make -j4 install
配置LLVM环境变量
# 配置wasm
$ echo 'export WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config' >> ~/.bash_profile
$ echo "export LLVM_DIR=$(brew --prefix llvm@4)/lib/cmake" >> ~/.bash_profile
$ source ~/.bash_profile
编译EOS代码
编译
$ cd ~
$ git clone https://github.com/eosio/eos --recursive
$ mkdir -p eos/build && cd eos/build
$ cmake -DBINARYEN_BIN=/usr/local/binaryen/bin -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
$ make -j4
运行EOS源代码
参考:运行EOS源代码(一)