-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_proto.sh
executable file
·47 lines (45 loc) · 1.37 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
#!/bin/bash
# define function
function gen_proto() {
# scan all files in the giving directory
# and generate proto files
for file in $(ls $1)
do
# check if the file is a proto file
if [[ $file == *.proto ]]
then
# print the message in red color
echo -e "\033[31m generating $1/$file \033[0m"
# generate response.proto file
protoc --proto_path=. --proto_path=./third_party \
--go_out=paths=source_relative:. \
--go-grpc_out=paths=source_relative:. \
--validate_out=lang=go,paths=source_relative:. \
$1/$file
fi
# check if the file is a directory and if it is not a hidden directory
if [[ -d $1/$file && $file != .* ]]
then
# call the function recursively
gen_proto $1/$file
fi
done
}
# list all directories in current directory
for dir in $(ls)
do
# check if the directory is a directory and if it is not a hidden directory
if [[ -d $dir && $dir != .* ]]
then
# check if it is third_party directory
if [[ $dir == third_party ]]
then
# don't call the function recursively
echo "skipping $dir"
else
# call the function recursively
gen_proto $dir
fi
fi
done
echo "done"