diff --git a/README.adoc b/README.adoc index 5c8b75f92..cea81815b 100644 --- a/README.adoc +++ b/README.adoc @@ -53,7 +53,8 @@ Darwinia Network provides game developers the scalability, cross-chain interoper === Hacking on Darwinia If you'd actually like to hack on Darwinia, you can just grab the source code and -build it. Ensure you have Rust and the support software installed: +build it. We also provide the script to help you setup your developing environment in bellow sections. +Please ensure you have Rust and the support software installed: ==== Linux and Mac @@ -344,16 +345,14 @@ node-cli, node-executor, node-primitives, node-rpc, node-rpc-client, node-runtim === Environment -If you are using Ubuntu, -you may use the `scripts/bootstrap.sh` to set up your develop environment. -In this script, the nightly `Rust`, `cargo`, `rustfmt` will be installed, +The `scripts/bootstrap.sh` help set up your develop environment. +The nightly `Rust`, `cargo`, `rustfmt` will be installed, the git hooks will be set, and ready to code. + +Besides, the script will install some essential packages depends on your OS, +if you want to do it manually, use the `--fast` option to skip. We will appreciate your contribution. -If you are using different environment, you may copy the git hooks mannually. -``` -$ cp .hooks/* .git/hooks -``` === Contributing Guidelines link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index b98165b5c..be92973b4 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,6 +1,57 @@ #!/usr/bin/env bash - +# # The script help you set up your develop envirnment +# +# --fast: fast mode will skip OS pacakge dependency, only install git hooks and Rust +# + +if [[ "$1" != "--fast" ]]; then + if [[ "$OSTYPE" == "linux-gnu" ]]; then + set -e + if [ -f /etc/redhat-release ]; then + echo "Redhat Linux detected, but current not support sorry." + echo "Contribution is always welcome." + exit 1 + elif [ -f /etc/SuSE-release ]; then + echo "Suse Linux detected, but current not support sorry." + echo "Contribution is always welcome." + exit 1 + elif [ -f /etc/arch-release ]; then + echo "Arch Linux detected." + sudo pacman -Syu --needed --noconfirm cmake gcc openssl-1.0 clang llvm rocksdb curl + export OPENSSL_LIB_DIR="/usr/lib/openssl-1.0"; + export OPENSSL_INCLUDE_DIR="/usr/include/openssl-1.0" + elif [ -f /etc/mandrake-release ]; then + echo "Mandrake Linux detected, but current not support sorry." + echo "Contribution is always welcome." + exit 1 + elif [ -f /etc/debian_version ]; then + echo "Ubuntu/Debian Linux detected." + sudo apt-get -y update + sudo apt-get install -y cmake pkg-config libssl-dev + else + echo "Unknown Linux distribution." + echo "Contribution is always welcome." + exit 1 + fi + elif [[ "$OSTYPE" == "darwin"* ]]; then + set -e + echo "Mac OS (Darwin) detected." + if ! which brew >/dev/null 2>&1; then + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + fi + brew upgrade + brew install openssl cmake llvm + elif [[ "$OSTYPE" == "freebsd"* ]]; then + echo "FreeBSD detected, but current not support sorry." + echo "Contribution is always welcome." + exit 1 + else + echo "Unknown operating system." + echo "Contribution is always welcome." + exit 1 + fi +fi # Setup git hooks cp .hooks/* .git/hooks @@ -13,7 +64,3 @@ rustup target add wasm32-unknown-unknown # Install rustfmt for coding style checking rustup component add rustfmt --toolchain nightly - -# TODO: help other developers with different platform -sudo apt-get -y update -sudo apt-get install -y cmake pkg-config libssl-dev