forked from yetanotherco/zkRust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_zkrust_from_source.sh
More file actions
88 lines (75 loc) · 2.27 KB
/
install_zkrust_from_source.sh
File metadata and controls
88 lines (75 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "Installing zkRust from source..."
BASE_DIR=$HOME
ZKRUST_DIR="${ZKRUST_DIR-"$BASE_DIR/.zkRust"}"
ZKRUST_BIN_DIR="$ZKRUST_DIR/bin"
ZKRUST_BIN_PATH="$ZKRUST_BIN_DIR/zkRust"
# Create bin directory
mkdir -p "$ZKRUST_BIN_DIR"
# Build from source using local code
echo "Building zkRust from source..."
cargo build --release
cp target/release/zkRust "$ZKRUST_BIN_PATH"
chmod +x "$ZKRUST_BIN_PATH"
# Store the correct profile file
case $SHELL in
*/zsh)
PROFILE="${ZDOTDIR-"$HOME"}/.zshenv"
PREF_SHELL=zsh
;;
*/bash)
PROFILE=$HOME/.bashrc
PREF_SHELL=bash
;;
*/fish)
PROFILE=$HOME/.config/fish/config.fish
PREF_SHELL=fish
;;
*/ash)
PROFILE=$HOME/.profile
PREF_SHELL=ash
;;
*)
echo "zkrust: could not detect shell, manually add ${ZKRUST_BIN_DIR} to your PATH."
exit 1
esac
# Only add to PATH if it isn't already there
if [[ ":$PATH:" != *":${ZKRUST_BIN_DIR}:"* ]]; then
if [[ "$PREF_SHELL" == "fish" ]]; then
echo >> "$PROFILE" && echo "fish_add_path -a $ZKRUST_BIN_DIR" >> "$PROFILE"
else
echo >> "$PROFILE" && echo "export PATH=\"\$PATH:$ZKRUST_BIN_DIR\"" >> "$PROFILE"
fi
fi
echo "zkRust built and installed successfully in $ZKRUST_BIN_PATH"
echo "Detected your preferred shell is $PREF_SHELL and added to PATH."
echo "Installing zkVM toolchains"
# Check for RISC0 toolchain
echo "Checking for RISC0 toolchain..."
if ! command -v rzup &> /dev/null; then
echo "Installing RISC0 toolchain..."
curl -L https://risczero.com/install | bash
export PATH="$PATH:$HOME/.risc0/bin"
rzup install
else
echo "RISC0 toolchain already installed"
fi
cargo risczero --version
# Check for SP1 toolchain
echo "Checking for SP1 toolchain..."
if ! command -v sp1up &> /dev/null; then
echo "Installing SP1 toolchain..."
curl -L https://sp1.succinct.xyz | bash
export PATH="$PATH:$HOME/.sp1/bin"
sp1up -v v4.0.1
else
echo "SP1 toolchain already installed"
fi
cargo prove --version
# Set up workspaces directory
echo "Setting up workspaces..."
mkdir -p "$ZKRUST_DIR/workspaces"
cp -r "$SCRIPT_DIR/workspaces/"* "$ZKRUST_DIR/workspaces/"
echo "Run 'source $PROFILE' or start a new terminal session to use zkRust!"