forked from Lilly-Protocol/lily-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-tooling.sh
More file actions
executable file
·92 lines (79 loc) · 2.59 KB
/
Copy pathcheck-tooling.sh
File metadata and controls
executable file
·92 lines (79 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
#!/usr/bin/env sh
# Tooling report.
#
# check-tooling.sh informational: print versions, always exit 0
# check-tooling.sh --strict fail (exit 1) if a required tool is missing
#
# Required (strict) tools: rustc, cargo, rustfmt, stellar, wasm32v1-none stdlib.
set -u
STRICT=0
for arg in "$@"; do
case "$arg" in
--strict)
STRICT=1
;;
esac
done
if [ "${CHECK_TOOLING_STRICT:-0}" = "1" ]; then
STRICT=1
fi
missing_count=0
if command -v rustc >/dev/null 2>&1; then
printf "rustc: "
rustc --version
else
printf "rustc: not installed\n"
missing_count=$((missing_count + 1))
fi
if command -v cargo >/dev/null 2>&1; then
printf "cargo: "
cargo --version
else
printf "cargo: not installed\n"
missing_count=$((missing_count + 1))
fi
if command -v rustfmt >/dev/null 2>&1; then
printf "rustfmt: "
rustfmt --version
else
printf "rustfmt: not installed\n"
missing_count=$((missing_count + 1))
fi
# Extract soroban-sdk major version from workspace
SDK_MAJOR=""
if [ -f "$REPO_ROOT/Cargo.lock" ]; then
SDK_MAJOR="$(sed -n '/name = "soroban-sdk"/{n;s/version = "\([0-9]*\).*/\1/p;}' "$REPO_ROOT/Cargo.lock" | head -n 1)"
fi
if [ -z "$SDK_MAJOR" ] && [ -f "$REPO_ROOT/Cargo.toml" ]; then
SDK_MAJOR="$(grep -E '^[[:space:]]*soroban-sdk[[:space:]]*=' "$REPO_ROOT/Cargo.toml" | sed -E 's/.*"([0-9]+).*/\1/' | head -n 1)"
fi
SDK_MAJOR="${SDK_MAJOR:-22}"
# Extract soroban-sdk major version from Cargo.toml or Cargo.lock
SDK_MAJOR=""
if [ -f "$REPO_ROOT/Cargo.toml" ]; then
SDK_MAJOR=$(grep -E "^[[:space:]]*soroban-sdk[[:space:]]*=" "$REPO_ROOT/Cargo.toml" | head -n 1 | grep -oE "[0-9]+" | head -n 1)
fi
if [ -z "$SDK_MAJOR" ] && [ -f "$REPO_ROOT/Cargo.lock" ]; then
SDK_MAJOR=$(grep -A 1 'name = "soroban-sdk"' "$REPO_ROOT/Cargo.lock" | grep "version =" | head -n 1 | grep -oE "[0-9]+" | head -n 1)
fi
if command -v stellar >/dev/null 2>&1; then
have stellar stellar --version
else
printf "stellar: not installed\n"
missing_count=$((missing_count + 1))
fi
if command -v rustc >/dev/null 2>&1 && rustc --print target-list | grep -qx "wasm32v1-none"; then
printf "wasm target available in toolchain list: yes\n"
else
miss wasm32v1-none-target "not in toolchain target list"
fi
if command -v rustc >/dev/null 2>&1 && [ -d "$(rustc --print sysroot)/lib/rustlib/wasm32v1-none/lib" ]; then
printf "wasm target stdlib installed: yes\n"
else
printf "wasm target stdlib installed: no\n"
missing_count=$((missing_count + 1))
fi
if [ "$STRICT" = "1" ] && [ "$missing_count" -gt 0 ]; then
printf "\nError: %d required tool(s) missing in strict mode.\n" "$missing_count" >&2
exit 1
fi