-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdo.sh
executable file
·125 lines (119 loc) · 2.33 KB
/
do.sh
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
set -ex
cd "$(dirname "$0")"
solana_version="1.5.1"
export PATH="$HOME"/.local/share/solana/install/active_release/bin:"$PATH"
usage() {
cat <<EOF
Usage: do.sh <action> <action specific arguments>
Supported actions:
build
build-lib
deploy
clean
clippy
doc
dump
new-swap
fmt
test
e2e-test
update
EOF
}
perform_action() {
set -ex
case "$1" in
build)
(
cargo build-bpf
)
;;
build-lib)
(
export RUSTFLAGS="${@:2}"
cargo build
)
;;
clean)
(
cargo clean
rm -rf lib/client/lib
)
;;
clippy)
(
cargo +nightly clippy ${@:2}
)
;;
e2e-test)
(
docker-compose up -d
./scripts/deploy-stable-swap.sh localnet
yarn --cwd lib/client install
yarn --cwd lib/client test-int ${@:2}
docker-compose down
)
;;
deploy)
(
./scripts/deploy-stable-swap.sh $2
./do.sh new-swap
)
;;
doc)
(
echo "generating docs ..."
cargo doc ${@:2}
)
;;
dump)
# Dump depends on tools that are not installed by default and must be installed manually
# - rustfilt
cargo build-bpf --dump ${@:2}
;;
fmt)
cargo fmt ${@:2}
;;
help)
usage
exit
;;
new-swap)
yarn --cwd lib/client install
yarn --cwd lib/client new-swap
;;
test)
cargo test-bpf ${@:2}
;;
update)
(
exit_code=0
which solana-install || exit_code=$?
if [ "$exit_code" -eq 1 ]; then
echo Installing Solana tool suite ...
sh -c "$(curl -sSfL https://release.solana.com/v${solana_version}/install)"
fi
solana-install update
)
;;
*)
echo "Error: Unknown command"
usage
exit
;;
esac
}
if [[ $1 == "update" ]]; then
perform_action "$1"
exit
else
if [[ "$#" -lt 1 ]]; then
usage
exit
fi
if [[ ! -d "$sdkDir" ]]; then
./do.sh update
fi
fi
perform_action "$1" "${@:2}"