forked from solana-labs/solana-program-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.crates-io.sh
executable file
·85 lines (73 loc) · 2.5 KB
/
patch.crates-io.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
#!/usr/bin/env bash
#
# Patches the SPL crates for developing against a local solana monorepo
#
solana_dir=$1
if [[ -z $solana_dir ]]; then
echo "Usage: $0 <path-to-solana-monorepo>"
exit 1
fi
workspace_crates=(
Cargo.toml
)
if [[ ! -r "$solana_dir"/scripts/read-cargo-variable.sh ]]; then
echo "$solana_dir is not a path to the solana monorepo"
exit 1
fi
set -e
solana_dir=$(cd "$solana_dir" && pwd)
cd "$(dirname "$0")"
source "$solana_dir"/scripts/read-cargo-variable.sh
# The toolchain file only exists in version >= 1.15
toolchain_file="$solana_dir"/rust-toolchain.toml
if [[ -f "$toolchain_file" ]]; then
cp "$toolchain_file" .
fi
# get version from Cargo.toml first. if it is empty, get it from other places.
solana_ver="$(readCargoVariable version "$solana_dir"/Cargo.toml)"
solana_ver=${solana_ver:-$(readCargoVariable version "$solana_dir"/sdk/Cargo.toml)}
crates_map=()
crates_map+=("solana-account-decoder account-decoder")
crates_map+=("solana-banks-client banks-client")
crates_map+=("solana-banks-server banks-server")
crates_map+=("solana-bpf-loader-program programs/bpf_loader")
crates_map+=("solana-clap-utils clap-utils")
crates_map+=("solana-clap-v3-utils clap-v3-utils")
crates_map+=("solana-cli-config cli-config")
crates_map+=("solana-cli-output cli-output")
crates_map+=("solana-client client")
crates_map+=("solana-core core")
crates_map+=("solana-logger logger")
crates_map+=("solana-notifier notifier")
crates_map+=("solana-remote-wallet remote-wallet")
crates_map+=("solana-program sdk/program")
crates_map+=("solana-program-test program-test")
crates_map+=("solana-runtime runtime")
crates_map+=("solana-sdk sdk")
crates_map+=("solana-stake-program programs/stake")
crates_map+=("solana-test-validator test-validator")
crates_map+=("solana-transaction-status transaction-status")
crates_map+=("solana-version version")
crates_map+=("solana-vote-program programs/vote")
crates_map+=("solana-zk-token-sdk zk-token-sdk")
patch_crates=()
for map_entry in "${crates_map[@]}"; do
read -r crate_name crate_path <<<"$map_entry"
full_path="$solana_dir/$crate_path"
if [[ -r "$full_path/Cargo.toml" ]]; then
patch_crates+=("$crate_name = { path = \"$full_path\" }")
fi
done
echo "Patching in $solana_ver from $solana_dir"
echo
for crate in "${workspace_crates[@]}"; do
if grep -q '\[patch.crates-io\]' "$crate"; then
echo "$crate is already patched"
else
cat >> "$crate" <<PATCH
[patch.crates-io]
$(printf "%s\n" "${patch_crates[@]}")
PATCH
fi
done
./update-solana-dependencies.sh "$solana_ver"