Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfschoen committed Nov 21, 2023
1 parent 735db4b commit bf5689a
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 88 deletions.
99 changes: 94 additions & 5 deletions book/src/developers/contributing/build_instructions/mac_os.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,98 @@
# Mac Os

Clone trin and run.
## Prerequisites
- [Rust](https://www.rust-lang.org/) installation
- Xcode Command Line Tools

## Building, Testing, and Running

Note: If you use a VPN, you should disable it before running Trin.

Install Xcode Command Line Tools (MacOS):

```sh
xcode-select --install
```

Add environment variables in current shell session:

```sh
# Optional
export RUST_LOG=<error/warn/info/debug/trace>
export TRIN_DATA_PATH=<path-to-data-directory>
```

Install Rust dependencies (MacOS):

```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh -s -- --default-toolchain stable -y

# Permanently add environment variables to login shell file for reuse across terminal sessions.
if [[ $(echo $SHELL) == "/bin/zsh" ]]; then
LOGIN_SHELL_FILE=$HOME/.zshrc
elif [[ $(echo $SHELL) == "/bin/bash" ]]; then
LOGIN_SHELL_FILE=$HOME/.bashrc
else
echo "The path to the binary of your current shell is: $SHELL"
echo "Please manually add environment variables to the relevant login shell file"
exit 1
fi
echo 'export RUST_LOG=debug' >> $LOGIN_SHELL_FILE
echo 'export PATH="${HOME}/.cargo/bin:${PATH}"' >> $LOGIN_SHELL_FILE
echo 'export RUSTUP_HOME="${HOME}/.rustup"' >> $LOGIN_SHELL_FILE
echo 'export CARGO_HOME="${HOME}/.cargo"' >> $LOGIN_SHELL_FILE
echo 'export TRIN_DATA_PATH="${HOME}/Library/Application Support/trin"' >> $LOGIN_SHELL_FILE
# Source the updated login shell file
. $LOGIN_SHELL_FILE
rustup component add rust-src rustfmt clippy
rustup target add wasm32-unknown-unknown
export RUST_STABLE="2023-08-03"
rustup toolchain install "stable-${RUST_STABLE}" --profile minimal --component rustfmt
rustup default "stable-${RUST_STABLE}"
rustup override set "stable-${RUST_STABLE}"
rustup target add wasm32-unknown-unknown --toolchain "stable-${RUST_STABLE}"
. $HOME/.cargo/env
rustup show
```

You should see something like:
```sh
active toolchain
----------------

stable-2023-08-03-aarch64-apple-darwin (default)
rustc 1.71.1 (eb26296b5 2023-08-03)
```

Build, test, and run:

```sh
cd ~
git clone https://github.com/ethereum/trin.git
cd trin

# Build
cargo build --workspace

# Run test suite
cargo test --workspace

# Build and run test suite for an individual crate
cargo build -p trin-history
cargo test -p trin-history

# Run
cargo run -p trin --release
```

Note: You may also pass environment variable values in the same command as the run command. This is especially useful for setting log levels.

```sh
RUST_LOG=debug cargo run
```

View CLI options:

```sh
$ cd ~
$ git clone https://github.com/ethereum/trin.git
$ cd trin
$ cargo run -p trin --release
cargo run -- --help
```
84 changes: 1 addition & 83 deletions book/src/developers/quick_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,89 +117,7 @@ cargo run

## Building on MacOS Based Systems

### Prerequisites
- [Rust](https://www.rust-lang.org/) installation
- Xcode Command Line Tools

### Building, Testing, and Running

Note: If you use a VPN, you should disable it before running Trin.

Install Xcode Command Line Tools (MacOS):

```sh
xcode-select --install
```

Environment variables:

```sh
# Optional
export RUST_LOG=<error/warn/info/debug/trace>
export TRIN_DATA_PATH=<path-to-data-directory>
```

Install Rust dependencies (MacOS):

```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh -s -- --default-toolchain nightly -y && \
echo 'export PATH="${HOME}/.cargo/bin:${PATH}"' >> $HOME/.bashrc && \
echo 'export RUSTUP_HOME="${HOME}/.rustup"' >> $HOME/.bashrc && \
echo 'export CARGO_HOME="${HOME}/.cargo"' >> $HOME/.bashrc && \
echo 'export RUST_LOG=debug' >> $HOME/.bashrc && \
echo 'export TRIN_DATA_PATH="${HOME}/Library/Application Support/trin"' >> $HOME/.bashrc && \
. $HOME/.bashrc && \
rustup component add rust-src rustfmt clippy && \
rustup target add wasm32-unknown-unknown && \
export RUST_NIGHTLY="2023-08-03" && \
rustup toolchain install "nightly-${RUST_NIGHTLY}" --profile minimal --component rustfmt && \
rustup default "nightly-${RUST_NIGHTLY}" && \
rustup override set "nightly-${RUST_NIGHTLY}" && \
rustup target add wasm32-unknown-unknown --toolchain "nightly-${RUST_NIGHTLY}" && \
. $HOME/.cargo/env && \
rustup show
```

You should see something like:
```sh
active toolchain
----------------

nightly-2023-08-03-aarch64-apple-darwin (default)
rustc 1.73.0-nightly (8131b9774 2023-08-02)
```

Build, test, and run:

```sh
git clone https://github.com/ethereum/trin.git
cd trin

# Build
cargo build --workspace

# Run test suite
cargo test --workspace

# Build and run test suite for an individual crate
cargo build -p trin-history
cargo test -p trin-history

# Run
cargo run
```

Note: You may also pass environment variable values in the same command as the run command. This is especially useful for setting log levels.

```sh
RUST_LOG=debug cargo run
```

View CLI options:

```sh
cargo run -- --help
```
Refer to [Build Instructions for MacOS](./contributing/build_instructions/mac_os.md)

## Run locally

Expand Down

0 comments on commit bf5689a

Please sign in to comment.