2013-11-17 15:46:41 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Run this script in the top nanopb directory to create a binary package
|
|
|
|
|
# for Linux users.
|
|
|
|
|
|
2017-09-17 12:53:49 +03:00
|
|
|
# Requires: protobuf, python-protobuf, pyinstaller
|
|
|
|
|
|
2013-11-17 15:46:41 +02:00
|
|
|
set -e
|
|
|
|
|
set -x
|
|
|
|
|
|
2013-12-29 20:25:36 +02:00
|
|
|
VERSION=`git describe --always`-linux-x86
|
2013-11-17 15:46:41 +02:00
|
|
|
DEST=dist/$VERSION
|
|
|
|
|
|
|
|
|
|
rm -rf $DEST
|
|
|
|
|
mkdir -p $DEST
|
|
|
|
|
|
|
|
|
|
# Export the files from newest commit
|
|
|
|
|
git archive HEAD | tar x -C $DEST
|
|
|
|
|
|
2020-06-27 22:10:53 +03:00
|
|
|
# Rebuild the Python .proto files and .pyc
|
|
|
|
|
( cd $DEST/generator; python3 nanopb_generator.py ||: )
|
2013-11-17 15:46:41 +02:00
|
|
|
|
|
|
|
|
# Package the Python libraries
|
2020-06-27 22:10:53 +03:00
|
|
|
( cd $DEST/generator; python3 -m PyInstaller nanopb_generator.py )
|
|
|
|
|
( cd $DEST/generator; python3 -m PyInstaller protoc )
|
2017-09-17 12:53:49 +03:00
|
|
|
mv $DEST/generator/dist/nanopb_generator $DEST/generator-bin
|
2020-06-27 22:10:53 +03:00
|
|
|
cp $DEST/generator/dist/protoc/protoc $DEST/generator-bin
|
|
|
|
|
|
|
|
|
|
# Include Google's descriptor.proto and nanopb.proto
|
|
|
|
|
cp -pr $(python3 -c 'import grpc_tools, os.path; print(os.path.dirname(grpc_tools.__file__))')/_proto $DEST/generator-bin/grpc_tools/
|
|
|
|
|
cp -pr $DEST/generator/proto $DEST/generator-bin/proto
|
2013-11-17 15:46:41 +02:00
|
|
|
|
2017-09-17 12:53:49 +03:00
|
|
|
# Remove temp files
|
|
|
|
|
rm -rf $DEST/generator/dist $DEST/generator/build $DEST/generator/nanopb_generator.spec
|
|
|
|
|
|
|
|
|
|
# Make the nanopb generator available as a protoc plugin
|
|
|
|
|
cp $DEST/generator-bin/nanopb_generator $DEST/generator-bin/protoc-gen-nanopb
|
2013-11-17 22:37:48 +02:00
|
|
|
|
2016-10-24 12:26:55 +03:00
|
|
|
# Remove debugging symbols to reduce size of package
|
2016-10-24 12:35:59 +03:00
|
|
|
( cd $DEST/generator-bin; strip *.so *.so.* )
|
2016-10-24 12:26:55 +03:00
|
|
|
|
2013-11-17 22:25:52 +02:00
|
|
|
# Tar it all up
|
2013-12-29 20:25:36 +02:00
|
|
|
( cd dist; tar -czf $VERSION.tar.gz $VERSION )
|
2013-11-17 22:25:52 +02:00
|
|
|
|