-
Notifications
You must be signed in to change notification settings - Fork 35
/
protoc-wrapper
executable file
·53 lines (49 loc) · 1.04 KB
/
protoc-wrapper
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
#!/usr/bin/env bash
c_out=""
csharp_out=""
includes=()
outs=()
args=()
for arg in $@; do
case $arg in
--c_out=*)
c_out=${arg}
shift
;;
--csharp_out=*)
csharp_out=${arg}
shift
;;
--grpc-csharp_out=*)
csharp_out=${arg}
shift
;;
--*_out=*)
outs+=(${arg})
shift
;;
-I*|--proto_path=*)
includes+=(${arg})
shift
;;
*)
args+=(${arg})
;;
esac
done
if [ ${#includes[@]} -eq 0 ]; then
# replicate protoc behavior
includes+=("-I.")
fi
protoc_cmd="protoc ${includes[@]} ${outs[@]} ${args[@]}"
protoc_c_cmd="protoc-c ${includes[@]} ${c_out} ${args[@]}"
protoc_csharp_cmd="protoc-csharp ${includes[@]} ${csharp_out} ${args[@]}"
if [ ${c_out} ]; then
${protoc_c_cmd} || exit 1
fi
if [ ${csharp_out} ]; then
${protoc_csharp_cmd} || exit 1
fi
if [ ${#outs[@]} -gt 0 ]; then
exec ${protoc_cmd}
fi