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