• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Run this script in the top nanopb directory to create a binary package
4# for Linux users.
5
6# Requires: protobuf, python-protobuf, pyinstaller
7
8set -e
9set -x
10
11VERSION=`git describe --always`-linux-x86
12DEST=dist/$VERSION
13
14rm -rf $DEST
15mkdir -p $DEST
16
17# Export the files from newest commit
18git archive HEAD | tar x -C $DEST
19
20# Rebuild the Python .proto files
21make -BC $DEST/generator/proto
22
23# Package the Python libraries
24( cd $DEST/generator; pyinstaller nanopb_generator.py )
25mv $DEST/generator/dist/nanopb_generator $DEST/generator-bin
26
27# Remove temp files
28rm -rf $DEST/generator/dist $DEST/generator/build $DEST/generator/nanopb_generator.spec
29
30# Make the nanopb generator available as a protoc plugin
31cp $DEST/generator-bin/nanopb_generator $DEST/generator-bin/protoc-gen-nanopb
32
33# Package the protoc compiler
34cp `which protoc` $DEST/generator-bin/protoc.bin
35LIBPROTOC=$(ldd `which protoc` | grep -o '/.*libprotoc[^ ]*')
36LIBPROTOBUF=$(ldd `which protoc` | grep -o '/.*libprotobuf[^ ]*')
37cp $LIBPROTOC $LIBPROTOBUF $DEST/generator-bin/
38cat > $DEST/generator-bin/protoc << EOF
39#!/bin/bash
40SCRIPTDIR=\$(dirname "\$0")
41export LD_LIBRARY_PATH=\$SCRIPTDIR
42export PATH=\$SCRIPTDIR:\$PATH
43exec "\$SCRIPTDIR/protoc.bin" "\$@"
44EOF
45chmod +x $DEST/generator-bin/protoc
46
47# Remove debugging symbols to reduce size of package
48( cd $DEST/generator-bin; strip *.so *.so.* )
49
50# Tar it all up
51( cd dist; tar -czf $VERSION.tar.gz $VERSION )
52
53