Include libprotoc
[apps/agl-service-can-low-level.git] / tools / make_linux_package.sh
1 #!/bin/bash
2
3 # Run this script in the top nanopb directory to create a binary package
4 # for Linux users.
5
6 set -e
7 set -x
8
9 VERSION=`git describe --always`
10 DEST=dist/$VERSION
11
12 rm -rf $DEST
13 mkdir -p $DEST
14
15 # Export the files from newest commit
16 git archive HEAD | tar x -C $DEST
17
18 # Rebuild the Python .proto files
19 make -BC $DEST/generator/proto
20
21 # Package the Python libraries
22 ( cd $DEST/generator; bbfreeze nanopb_generator.py )
23 mv $DEST/generator/dist $DEST/generator-bin
24
25 # Package the protoc compiler
26 cp `which protoc` $DEST/generator-bin/protoc.bin
27 LIBPROTOC=$(ldd `which protoc` | grep -o '/.*libprotoc[^ ]*')
28 cp $LIBPROTOC $DEST/generator-bin/
29 cat > $DEST/generator-bin/protoc << EOF
30 #!/bin/bash
31 SCRIPTDIR=\$(dirname \$(readlink -f \$0))
32 export LD_LIBRARY_PATH=\$SCRIPTDIR
33 export PATH=\$SCRIPTDIR:\$PATH
34 exec \$SCRIPTDIR/protoc.bin "\$@"
35 EOF
36 chmod +x $DEST/generator-bin/protoc
37
38 # Make the nanopb generator available as a protoc plugin
39 ln -s nanopb-generator $DEST/generator-bin/protoc-gen-nanopb
40
41 # Tar it all up
42 ( cd dist; tar -czf $VERSION.tar.gz $VERSION )
43