-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateDecoder.sh
executable file
·56 lines (52 loc) · 1.48 KB
/
CreateDecoder.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
if [[ $# < 1 ]]
then
echo "Please provide the class Name what to decode"
echo "CreateDecoder.sh <className>"
echo "Example:: CreateDecoder.sh DNDResponse"
exit
fi
CPP_OUT=./inc
SOURCE=./src
echo
echo "Generating source code ..."
protoc --cpp_out $CPP_OUT *.proto
if [ $? != '0' ]
then
echo "Failed to generate code please check the error message printed."
exit 1
fi
echo
echo " -->Successfully geneerated Protocol buffer source code!"
echo " -->Please check directory: $CPP_OUT for source code files."
echo " NOTE: If you are adding or changing an existing proto file"
echo " please make sure that its compiling successfully, this script"
echo " will suppress any error messages from protoc."
echo
echo "Generating library..."
cd $CPP_OUT
make
if [ $? -ne 0 ]
then
echo " -->Failed to generate lib"
exit 1;
fi
echo "Successfully generated lib!"
cd ../
class=$1;
MaxLengthOfPacket=20000
#################Creating Define file ###########################
echo "#define className $class" > $CPP_OUT/Defines.h
echo "#define MaxLenPkt $MaxLengthOfPacket" >> $CPP_OUT/Defines.h
#################################################################
cd $SOURCE
#################Creating Header file ###########################
HEADER=Headers.h
echo "#ifndef __HEADERS__" > $HEADER
echo "#define __HEADERS__" >> $HEADER
for file in ../$CPP_OUT/*.h
do
echo "#include <$file>" >> $HEADER
done
echo "#endif" >> $HEADER
#################################################################
make