Skip to content

Commit a7c21d5

Browse files
authored
[TKN-683] Add setup.sh script for local Whirlpools build (#1074)
* Base script * Update README. Improve setup.sh * Simplify Anchor installation. Switch Rust versions only once.
1 parent 634b06a commit a7c21d5

File tree

2 files changed

+98
-13
lines changed

2 files changed

+98
-13
lines changed

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,27 @@ This monorepo contains all the code needed to build, deploy and interact with th
4242

4343
### Getting Started
4444

45-
These instructions are for setting up a development environment on a Mac. If you are using a different operating system, you will need to adjust the instructions accordingly.
46-
47-
* Install NodeJS and gcc-12 using `brew install node gcc@12`.
48-
* Add gcc-12 headers to your cpath using `export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"`.
49-
* Install Rust lang using `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`.
50-
* Install the Solana CLI using `curl -sSfL https://release.solana.com/v1.17.22/install | sh`.
51-
* Add the Solana CLI to your path using `export PATH="/Users/$(whoami)/.local/share/solana/install/active_release/bin:$PATH"`.
52-
* Install Anchor version manager using `cargo install --git https://github.com/coral-xyz/anchor avm --locked --force`.
53-
* Install the latest Anchor version using `avm install 0.29.0 && avm use 0.29.0`.
54-
* Clone this repository using `git clone https://github.com/orca-so/whirlpools`.
55-
* Install the dependencies using `yarn`.
56-
* Set up a Solana wallet if you don't have one already (see below).
57-
* Run one of the commands below to get started such as `yarn build`.
45+
#### Automated Setup Script
46+
47+
For a complete development environment setup, use the provided setup script:
48+
49+
```bash
50+
chmod +x scripts/setup.sh
51+
./scripts/setup.sh
52+
```
53+
54+
This script installs all required dependencies and builds the project. It's designed for fresh environments (cloud VMs, containers, new machines) and doesn't check for existing versions. The script also serves as a reference for understanding which dependencies are needed at each stage.
55+
56+
#### Manual Setup
57+
58+
If you prefer manual installation or already have some dependencies:
59+
60+
* Install system dependencies (build tools, Node.js, Rust, Solana CLI, Anchor)
61+
* Reference `scripts/setup.sh` for the exact versions and installation steps
62+
* Clone this repository: `git clone https://github.com/orca-so/whirlpools`
63+
* Install JavaScript dependencies: `yarn`
64+
* Build the project: `yarn build`
65+
* Set up a Solana wallet if needed (see below)
5866

5967
#### Setting up a Solana wallet
6068

scripts/setup.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# =============================================================================
5+
# DEPENDENCY VERSIONS
6+
# =============================================================================
7+
NVM_VERSION="v0.40.3"
8+
NODE_VERSION="22"
9+
YARN_VERSION="4.6.0"
10+
SOLANA_VERSION="v1.17.25"
11+
ANCHOR_VERSION="v0.29.0"
12+
RUST_VERSION_FOR_PROJECT="1.84.0"
13+
14+
# Resolve repo root from this script's directory
15+
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
16+
REPO_ROOT="$(cd -- "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
17+
echo "=== Repo root: $REPO_ROOT ==="
18+
19+
echo "=== Detecting system ==="
20+
UNAME_OUT="$(uname -s)"
21+
case "${UNAME_OUT}" in
22+
Linux*) OS=Linux;;
23+
Darwin*) OS=Mac;;
24+
*) OS="UNKNOWN:${UNAME_OUT}"
25+
esac
26+
echo "Detected: $OS"
27+
28+
if [[ "$OS" == "Linux" ]]; then
29+
echo "=== Updating system packages (Linux) ==="
30+
sudo apt-get update && sudo apt-get upgrade -y
31+
sudo apt-get install -y build-essential pkg-config libssl-dev curl git
32+
elif [[ "$OS" == "Mac" ]]; then
33+
echo "=== Installing Xcode Command Line Tools ==="
34+
xcode-select --install || true
35+
36+
echo "=== Installing Homebrew and dependencies ==="
37+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || true
38+
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || eval "$(/usr/local/bin/brew shellenv)" 2>/dev/null || true
39+
brew update
40+
brew upgrade
41+
brew install pkg-config openssl git
42+
fi
43+
44+
echo "=== Installing NVM (Node Version Manager) ==="
45+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash
46+
export NVM_DIR="$HOME/.nvm"
47+
source "$NVM_DIR/nvm.sh"
48+
49+
echo "=== Installing Node.js ${NODE_VERSION} and Yarn (via Corepack) ==="
50+
nvm install ${NODE_VERSION}
51+
nvm use ${NODE_VERSION}
52+
corepack enable
53+
corepack prepare yarn@${YARN_VERSION} --activate
54+
55+
echo "=== Installing Rust via rustup ==="
56+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
57+
source "$HOME/.cargo/env"
58+
rustup default stable
59+
rustc -V
60+
61+
echo "=== Installing Solana CLI ==="
62+
sh -c "$(curl -sSfL https://release.anza.xyz/${SOLANA_VERSION}/install)"
63+
source "$HOME/.profile" || true
64+
solana -V
65+
66+
echo "=== Installing Anchor (${ANCHOR_VERSION}) ==="
67+
cargo install --git https://github.com/coral-xyz/anchor --tag ${ANCHOR_VERSION} anchor-cli --force
68+
export PATH="$HOME/.cargo/bin:$PATH"
69+
cd "$REPO_ROOT"
70+
71+
echo "=== Building local Whirlpools repo ==="
72+
rustup default ${RUST_VERSION_FOR_PROJECT}
73+
cd "$REPO_ROOT"
74+
yarn install
75+
yarn build
76+
77+
echo "=== Setup complete ==="

0 commit comments

Comments
 (0)