forked from anza-xyz/agave
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.sh
More file actions
107 lines (93 loc) · 2.59 KB
/
common.sh
File metadata and controls
107 lines (93 loc) · 2.59 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# |source| this file
#
# Common utilities shared by other scripts in this directory
#
# The following directive disable complaints about unused variables in this
# file:
# shellcheck disable=2034
#
here="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. || exit 1; pwd)"
# shellcheck source=net/common.sh
source "$here"/net/common.sh
prebuild=
if [[ $1 = "--prebuild" ]]; then
prebuild=true
fi
if [[ -n $USE_INSTALL || ! -f "$SOLANA_ROOT"/Cargo.toml ]]; then
solana_program() {
declare program="$1"
if [[ -z $program ]]; then
printf "solana"
else
if [[ $program == "validator" || $program == "ledger-tool" || $program == "watchtower" || $program == "install" ]]; then
printf "agave-%s" "$program"
else
printf "solana-%s" "$program"
fi
fi
}
else
solana_program() {
declare program="$1"
declare crate="$program"
declare manifest_path
if [[ $program == "bench-tps" || $program == "ledger-tool" ]]; then
manifest_path="--manifest-path $here/dev-bins/Cargo.toml"
fi
if [[ -z $program ]]; then
crate="cli"
program="solana"
elif [[ $program == "validator" || $program == "ledger-tool" || $program == "watchtower" || $program == "install" ]]; then
program="agave-$program"
else
program="solana-$program"
fi
if [[ -n $CARGO_BUILD_PROFILE ]]; then
profile_arg="--profile $CARGO_BUILD_PROFILE"
fi
# Prebuild binaries so that CI sanity check timeout doesn't include build time
if [[ $prebuild ]]; then
(
set -x
# shellcheck disable=SC2086 # Don't want to double quote
cargo $CARGO_TOOLCHAIN build $manifest_path $profile_arg --bin $program
)
fi
printf "cargo $CARGO_TOOLCHAIN run $manifest_path $profile_arg --bin %s %s -- " "$program"
}
fi
solana_bench_tps=$(solana_program bench-tps)
solana_faucet=$(solana_program faucet)
agave_validator=$(solana_program validator)
solana_genesis=$(solana_program genesis)
solana_gossip=$(solana_program gossip)
solana_keygen=$(solana_program keygen)
solana_ledger_tool=$(solana_program ledger-tool)
solana_cli=$(solana_program)
export RUST_BACKTRACE=1
default_arg() {
declare name=$1
declare value=$2
for arg in "${args[@]}"; do
if [[ $arg = "$name" ]]; then
return
fi
done
if [[ -n $value ]]; then
args+=("$name" "$value")
else
args+=("$name")
fi
}
replace_arg() {
declare name=$1
declare value=$2
default_arg "$name" "$value"
declare index=0
for arg in "${args[@]}"; do
index=$((index + 1))
if [[ $arg = "$name" ]]; then
args[$index]="$value"
fi
done
}