Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trival/bootstrap #237

Merged
merged 2 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down
57 changes: 52 additions & 5 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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