Skip to content

Commit 072dada

Browse files
authored
Trival/bootstrap (#237)
Trival/bootstrap
2 parents f800f67 + 566a35e commit 072dada

File tree

2 files changed

+59
-13
lines changed

2 files changed

+59
-13
lines changed

README.adoc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Darwinia Network provides game developers the scalability, cross-chain interoper
5353
=== Hacking on Darwinia
5454

5555
If you'd actually like to hack on Darwinia, you can just grab the source code and
56-
build it. Ensure you have Rust and the support software installed:
56+
build it. We also provide the script to help you setup your developing environment in bellow sections.
57+
Please ensure you have Rust and the support software installed:
5758

5859
==== Linux and Mac
5960

@@ -344,16 +345,14 @@ node-cli, node-executor, node-primitives, node-rpc, node-rpc-client, node-runtim
344345

345346
=== Environment
346347

347-
If you are using Ubuntu,
348-
you may use the `scripts/bootstrap.sh` to set up your develop environment.
349-
In this script, the nightly `Rust`, `cargo`, `rustfmt` will be installed,
348+
The `scripts/bootstrap.sh` help set up your develop environment.
349+
The nightly `Rust`, `cargo`, `rustfmt` will be installed,
350350
the git hooks will be set, and ready to code.
351+
352+
Besides, the script will install some essential packages depends on your OS,
353+
if you want to do it manually, use the `--fast` option to skip.
351354
We will appreciate your contribution.
352355

353-
If you are using different environment, you may copy the git hooks mannually.
354-
```
355-
$ cp .hooks/* .git/hooks
356-
```
357356
=== Contributing Guidelines
358357

359358
link:CONTRIBUTING.adoc[CONTRIBUTING.adoc]

scripts/bootstrap.sh

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,57 @@
11
#!/usr/bin/env bash
2-
2+
#
33
# The script help you set up your develop envirnment
4+
#
5+
# --fast: fast mode will skip OS pacakge dependency, only install git hooks and Rust
6+
#
7+
8+
if [[ "$1" != "--fast" ]]; then
9+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
10+
set -e
11+
if [ -f /etc/redhat-release ]; then
12+
echo "Redhat Linux detected, but current not support sorry."
13+
echo "Contribution is always welcome."
14+
exit 1
15+
elif [ -f /etc/SuSE-release ]; then
16+
echo "Suse Linux detected, but current not support sorry."
17+
echo "Contribution is always welcome."
18+
exit 1
19+
elif [ -f /etc/arch-release ]; then
20+
echo "Arch Linux detected."
21+
sudo pacman -Syu --needed --noconfirm cmake gcc openssl-1.0 clang llvm rocksdb curl
22+
export OPENSSL_LIB_DIR="/usr/lib/openssl-1.0";
23+
export OPENSSL_INCLUDE_DIR="/usr/include/openssl-1.0"
24+
elif [ -f /etc/mandrake-release ]; then
25+
echo "Mandrake Linux detected, but current not support sorry."
26+
echo "Contribution is always welcome."
27+
exit 1
28+
elif [ -f /etc/debian_version ]; then
29+
echo "Ubuntu/Debian Linux detected."
30+
sudo apt-get -y update
31+
sudo apt-get install -y cmake pkg-config libssl-dev
32+
else
33+
echo "Unknown Linux distribution."
34+
echo "Contribution is always welcome."
35+
exit 1
36+
fi
37+
elif [[ "$OSTYPE" == "darwin"* ]]; then
38+
set -e
39+
echo "Mac OS (Darwin) detected."
40+
if ! which brew >/dev/null 2>&1; then
41+
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
42+
fi
43+
brew upgrade
44+
brew install openssl cmake llvm
45+
elif [[ "$OSTYPE" == "freebsd"* ]]; then
46+
echo "FreeBSD detected, but current not support sorry."
47+
echo "Contribution is always welcome."
48+
exit 1
49+
else
50+
echo "Unknown operating system."
51+
echo "Contribution is always welcome."
52+
exit 1
53+
fi
54+
fi
455

556
# Setup git hooks
657
cp .hooks/* .git/hooks
@@ -13,7 +64,3 @@ rustup target add wasm32-unknown-unknown
1364

1465
# Install rustfmt for coding style checking
1566
rustup component add rustfmt --toolchain nightly
16-
17-
# TODO: help other developers with different platform
18-
sudo apt-get -y update
19-
sudo apt-get install -y cmake pkg-config libssl-dev

0 commit comments

Comments
 (0)