-
Notifications
You must be signed in to change notification settings - Fork 7
/
generate.sh
executable file
·185 lines (165 loc) · 4.7 KB
/
generate.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
set -e
mkdir -p build
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
go build -o mdgen ./cmd/mdgen/
function initrepo() {
PROTO_DIR=$PROTO_ROOT_DIR/$COMPONENT
LOCAL_REPO_PATH=./build/$COMPONENT
if [[ ! -d $LOCAL_REPO_PATH ]]; then
git clone $REPO_URL $LOCAL_REPO_PATH
fi
# Update the repository to the respective CHECKOUT_COMMIT and install the binary.
pushd $LOCAL_REPO_PATH
COMMIT=$(git rev-parse HEAD)
git reset --hard HEAD
git pull
git checkout $CHECKOUT_COMMIT
COMMIT=$(git rev-parse HEAD)
eval $INSTALL_CMD
popd
# Copy over all proto and json files from the checked out source directory.
mkdir -p $PROTO_DIR
rsync -a --prune-empty-dirs --include '*/' --include '*.proto' \
--include '*.json' --include '*.yaml' --exclude '*' \
$LOCAL_REPO_PATH/$PROTO_SRC_DIR/ $PROTO_DIR/
# Copy any additional proto files from other projects.
INCLUDE_FLAG=""
if [[ ! -z $INCLUDE_PROTOS ]]; then
echo "Including protos from $INCLUDE_PROTOS"
INCLUDE_FLAG="-I$INCLUDE_PROTOS"
fi
pushd $PROTO_DIR
proto_files=$(find . -name '*.proto' -not -name $EXCLUDE_PROTOS)
protoc -I. -I/usr/local/include $INCLUDE_FLAG \
--doc_out=json,generated.json:. $proto_files
popd
}
function compile() {
echo "Using ${COMPONENT} repo URL ${REPO_URL} and commit ${CHECKOUT_COMMIT}"
if [[ "${INIT_REPOS}" == "true" ]]; then
initrepo
else
# If we're not initializing the repos, we still need to the COMMIT variable
pushd ./build/$COMPONENT > /dev/null
COMMIT=$(git rev-parse HEAD)
popd > /dev/null
fi
export REPO_URL COMMIT PROTO_SRC_DIR EXPERIMENTAL_PACKAGES GRPC_PORT REST_PORT COMMAND DAEMON
./mdgen $COMPONENT
}
# Generic options.
WS_ENABLED="${WS_ENABLED:-true}"
LND_FORK="${LND_FORK:-lightningnetwork}"
LND_COMMIT="${LND_COMMIT:-master}"
LOOP_FORK="${LOOP_FORK:-lightninglabs}"
LOOP_COMMIT="${LOOP_COMMIT:-master}"
FARADAY_FORK="${FARADAY_FORK:-lightninglabs}"
FARADAY_COMMIT="${FARADAY_COMMIT:-master}"
POOL_FORK="${POOL_FORK:-lightninglabs}"
POOL_COMMIT="${POOL_COMMIT:-master}"
TAPD_FORK="${TAPD_FORK:-lightninglabs}"
TAPD_COMMIT="${TAPD_COMMIT:-main}"
LIT_FORK="${LIT_FORK:-lightninglabs}"
LIT_COMMIT="${LIT_COMMIT:-master}"
PROTO_ROOT_DIR="build/protos"
# Set to 'false' to skip cloning and building each repo
INIT_REPOS="${INIT_REPOS:-true}"
# Remove previously generated templates.
if [[ "${INIT_REPOS}" == "true" ]]; then
rm -rf $PROTO_ROOT_DIR
fi
########################
## Compile docs for lnd
########################
REPO_URL="https://github.com/${LND_FORK}/lnd"
CHECKOUT_COMMIT=$LND_COMMIT
COMPONENT=lnd
COMMAND=lncli
DAEMON=lnd
PROTO_SRC_DIR=lnrpc
EXCLUDE_PROTOS="none"
EXPERIMENTAL_PACKAGES="autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc monitoring peersrpc kvdb_postgres kvdb_etcd"
INSTALL_CMD="make clean && make install tags=\"$EXPERIMENTAL_PACKAGES\""
GRPC_PORT=10009
REST_PORT=8080
compile
########################
## Compile docs for loop
########################
REPO_URL="https://github.com/${LOOP_FORK}/loop"
CHECKOUT_COMMIT=$LOOP_COMMIT
COMPONENT=loop
COMMAND=loop
DAEMON=loopd
PROTO_SRC_DIR="swapserverrpc"
EXCLUDE_PROTOS="server.proto -not -name common.proto"
EXPERIMENTAL_PACKAGES=""
INSTALL_CMD="make install"
GRPC_PORT=11010
REST_PORT=8081
compile
########################
## Compile docs for faraday
########################
REPO_URL="https://github.com/${FARADAY_FORK}/faraday"
CHECKOUT_COMMIT=$FARADAY_COMMIT
COMPONENT=faraday
COMMAND=frcli
DAEMON=faraday
PROTO_SRC_DIR=frdrpc
EXCLUDE_PROTOS="none"
EXPERIMENTAL_PACKAGES=""
INSTALL_CMD="make install"
GRPC_PORT=8465
REST_PORT=8082
compile
########################
## Compile docs for pool
########################
REPO_URL="https://github.com/${POOL_FORK}/pool"
CHECKOUT_COMMIT=$POOL_COMMIT
COMPONENT=pool
COMMAND=pool
DAEMON=poold
PROTO_SRC_DIR=""
EXCLUDE_PROTOS="none"
EXCLUDE_SERVICES="ChannelAuctioneer"
EXPERIMENTAL_PACKAGES=""
INSTALL_CMD="make install"
GRPC_PORT=12010
REST_PORT=8281
compile
########################
## Compile docs for taproot-assets
########################
REPO_URL="https://github.com/${TAPD_FORK}/taproot-assets"
CHECKOUT_COMMIT=$TAPD_COMMIT
COMPONENT=taproot-assets
COMMAND=tapcli
DAEMON=tapd
PROTO_SRC_DIR="taprpc"
INCLUDE_PROTOS="../lnd"
EXCLUDE_PROTOS="none"
EXCLUDE_SERVICES=""
EXPERIMENTAL_PACKAGES=""
INSTALL_CMD="make install"
GRPC_PORT=10029
REST_PORT=8089
compile
########################
## Compile docs for lit
########################
REPO_URL="https://github.com/${LIT_FORK}/lightning-terminal"
CHECKOUT_COMMIT=$LIT_COMMIT
COMPONENT=lit
COMMAND=litcli
DAEMON=litd
PROTO_SRC_DIR="litrpc"
EXCLUDE_PROTOS="none"
EXCLUDE_SERVICES=""
EXPERIMENTAL_PACKAGES=""
INSTALL_CMD="make install"
GRPC_PORT=8443
REST_PORT=8443
compile