3 # Run this script in the top nanopb directory to create a binary package
6 # Requires: protobuf, python-protobuf, pyinstaller
11 VERSION=`git describe --always`-macosx-x86
17 # Export the files from newest commit
18 git archive HEAD | tar x -C $DEST
20 # Rebuild the Python .proto files
21 make -BC $DEST/generator/proto
23 # Package the Python libraries
24 ( cd $DEST/generator; pyinstaller nanopb_generator.py )
25 mv $DEST/generator/dist/nanopb_generator $DEST/generator-bin
28 rm -rf $DEST/generator/dist $DEST/generator/build $DEST/generator/nanopb_generator.spec
30 # Make the nanopb generator available as a protoc plugin
31 cp $DEST/generator-bin/nanopb_generator $DEST/generator-bin/protoc-gen-nanopb
33 # Package the protoc compiler
34 cp `which protoc` $DEST/generator-bin/protoc.bin
35 LIBPROTOC=$(otool -L `which protoc` | grep -o '/.*libprotoc[^ ]*')
36 LIBPROTOBUF=$(otool -L `which protoc` | grep -o '/.*libprotobuf[^ ]*')
37 cp $LIBPROTOC $LIBPROTOBUF $DEST/generator-bin/
38 cat > $DEST/generator-bin/protoc << EOF
40 SCRIPTDIR=\$(dirname "\$0")
41 export DYLD_LIBRARY_PATH=\$SCRIPTDIR
42 export PATH=\$SCRIPTDIR:\$PATH
43 exec "\$SCRIPTDIR/protoc.bin" "\$@"
45 chmod +x $DEST/generator-bin/protoc
48 ( cd dist; zip -r $VERSION.zip $VERSION )