-
Notifications
You must be signed in to change notification settings - Fork 8
/
gen_proto.sh
executable file
·63 lines (52 loc) · 2.31 KB
/
gen_proto.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
#!/bin/bash
OS=`uname -s`
GOPATH=`pwd`
if [ "$OS" == "Linux" ]; then
export PATH=$GOPATH/tools/linux/protoc/bin:$PATH
else
export PATH=$GOPATH/tools/darwin/protoc/bin:$PATH
fi
echo "which protoc: "
which protoc
#[email protected]:geekjoys/gohive_proto.git
#if test ! -e pb/msg; then
# if test ! -e .build/pb; then
# git clone https://lab.qeetap.com/geekjoys/gohive_proto.git .build/pb
# fi
# pushd pb
# rm -rf msg
# rm -rf def
# rm -rf cfg
# ln -s ../.build/pb/msg msg
# ln -s ../.build/pb/cfg cfg
# ln -s ../.build/pb/def def
# popd
#fi
rm ./internal/pb/cfg/*.pb.go
rm ./internal/pb/msg/*.pb.go
rm ./internal/pb/def/*.pb.go
protoc --go_out=import_prefix=gohive/internal/pb/,plugins=grpc:internal/pb pb/cfg/*.proto --proto_path=pb
protoc --go_out=import_prefix=gohive/internal/pb/,plugins=grpc:internal/pb pb/def/*.proto --proto_path=pb
protoc --go_out=import_prefix=gohive/internal/pb/,plugins=grpc:internal/pb pb/msg/*.proto --proto_path=pb
protoc --go_out=import_prefix=gohive/internal/pb/,plugins=grpc:internal/pb pb/service/*.proto --proto_path=pb
if [ "$OS" == "Linux" ]; then
find ./internal/pb -name "*.pb.go" | xargs sed -i "s/gohive\/internal\/pb\/github.com/github.com/g"
find ./internal/pb -name "*.pb.go" | xargs sed -i "s/gohive\/internal\/pb\/golang.org/golang.org/g"
find ./internal/pb -name "*.pb.go" | xargs sed -i "s/gohive\/internal\/pb\/google.golang.org/google.golang.org/g"
find ./internal/pb -name "*.pb.go" | xargs sed -i "s/,omitempty//g"
else
find ./internal/pb -name "*.pb.go" | xargs sed -i '' "s/gohive\/internal\/pb\/github.com/github.com/g"
find ./internal/pb -name "*.pb.go" | xargs sed -i '' "s/gohive\/internal\/pb\/golang.org/golang.org/g"
find ./internal/pb -name "*.pb.go" | xargs sed -i '' "s/gohive\/internal\/pb\/google.golang.org/google.golang.org/g"
find ./internal/pb -name "*.pb.go" | xargs sed -i '' "s/,omitempty//g"
fi
types=`cat internal/pb/def/common.pb.go| grep "type" | cut -d ' ' -f2`
for type in ${types[@]};do
if [ "$OS" == "Linux" ]; then
sed -i "s/^\t${type}_/\t/g" internal/pb/def/common.pb.go
else
#sed -e 's/\/[CTR+V][CTR+I]/g' filename
sed -i '' "s/^ ${type}_/ /g" internal/pb/def/common.pb.go
fi
done
./gen_handler.py ./pb ./server/game ./server/game/handler