-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·62 lines (46 loc) · 1.04 KB
/
build
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
#!/usr/bin/env bash
set -euo pipefail
TEMPFILES=()
cleanup () {
rm -rf "${TEMPFILES[@]}"
}
trap cleanup EXIT
PROJECT=counter_anchor
TARGET=$PROJECT/target
SHAREDOBJECT=$TARGET/deploy/$PROJECT.so
MANIFEST=$(mktemp)
TEMPFILES+=("$MANIFEST")
function add-section () {
local section filename
section=$1 ; shift
filename=$1 ; shift
llvm-objcopy --add-section=${section}=${filename} $SHAREDOBJECT
}
log::info () {
printf "INFO:\t%s\n" "$@"
}
if [[ -e $SHAREDOBJECT ]] ; then
log::info "removing existing shared object $SHAREDOBJECT..."
rm -f $SHAREDOBJECT
fi
(
cd $PROJECT
log::info "syncing keys..."
anchor keys sync
log::info "building $PROJECT anchor project..."
anchor build
)
log::info "creating top-level manifest..."
cat <<'EOF' > $MANIFEST
{
"sections": {
"solana.idl": {
"type": "AnchorIDL"
}
}
}
EOF
log::info "patching $PROJECT deployment object with manifest and IDL..."
add-section solana.manifest $MANIFEST
add-section solana.idl $TARGET/idl/$PROJECT.json
log::info "done building"