This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgen_proto.sh
executable file
·70 lines (61 loc) · 1.64 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
63
64
65
66
67
68
69
70
#!/bin/sh
SRC=proto
FILE=$SRC/DevicesSpec.proto
CPP=src/proto
JS=../fanconw/src/proto
DIR=$(dirname "$0")
cd "$DIR"
# fancon
mkdir -p ./$CPP
rm -f ./$CPP/*
protoc -I=./$SRC ./$FILE \
--cpp_out=./$CPP \
--grpc_out=./$CPP \
--plugin=protoc-gen-grpc=$(which grpc_cpp_plugin)
# Silence compiler warnings from protoc generated code
CLANG_DIAG_S=$(
cat <<-END
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif // __clang__
END
)
CLANG_DIAG_E=$(
cat <<-END
#if defined(__clang__)
#pragma clang diagnostic pop // -Wunused-parameter
#elif defined(__GNUC__)
#pragma GCC diagnostic pop // -Wunused-but-set-variable
#endif // __clang__
END
)
for filename in ./"$CPP"/*.h; do
printf "%s\n\n%s\n\n%s\n" "$CLANG_DIAG_S" "$(cat "./$filename")" "$CLANG_DIAG_E" >"./$filename"
done
# fanconw
#mkdir -p ./$JS
#rm -f ./$JS/*
#GRPC_WEB=$(which protoc-gen-grpc-web)
#if [ $? -ne 0 ]; then
# GRPC_WEB=./node_modules/protoc-gen-grpc-web/bin/protoc-gen-grpc-web
# if [ ! -f $GRPC_WEB ]; then
# npm install grpc-tools protoc-gen-grpc-web
# fi
#fi
#protoc -I=./$SRC ./$FILE \
# --js_out=import_style=commonjs:$JS \
# --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$JS \
# --plugin=protoc-gen-grpc-web=$GRPC_WEB
#if [ $? -eq 0 ]; then
# ## Prepend /* eslint-disable */ to ignore compiler complaints
# for filename in "$JS/*.js"; do
# echo "/* eslint-disable */\n$(cat ./$filename)" > ./$filename
# done
#else
# echo 'protoc-grpc-web FAILED'
# ls $JS
#fi