-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.sh
34 lines (27 loc) · 1 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
#!/bin/bash
rm -rf ./api
rm -rf ./core
# Check and install dependencies
if ! command -v protoc-gen-go &>/dev/null; then
echo "Installing protoc-gen-go..."
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
else
echo "protoc-gen-go is already installed"
fi
if ! command -v protoc-gen-go-grpc &>/dev/null; then
echo "Installing protoc-gen-go-grpc..."
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
else
echo "protoc-gen-go-grpc is already installed"
fi
# Generate code
protoc -I=./protocol -I./googleapis --go_out=. --go-grpc_out=. \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
./protocol/api/*.proto ./protocol/core/*.proto ./protocol/core/contract/*.proto
# Replace import paths
find . -name "*.pb.go" -type f -exec sed -i 's|github.com/tronprotocol/grpc-gateway|github.com/gofika/fikatron|g' {} +
# Move files and remove empty directories
mv ./core/contract/* ./core/
rm -rf ./core/contract
echo "Installation and generation steps completed"