Home | History | Annotate | Download | only in tools
      1 #!/bin/bash
      2 
      3 # Run this script in the top nanopb directory to create a binary package
      4 # for Mac OS X users.
      5 
      6 # Requires: protobuf, python-protobuf, pyinstaller
      7 
      8 set -e
      9 set -x
     10 
     11 VERSION=`git describe --always`-macosx-x86
     12 DEST=dist/$VERSION
     13 
     14 rm -rf $DEST
     15 mkdir -p $DEST
     16 
     17 # Export the files from newest commit
     18 git archive HEAD | tar x -C $DEST
     19 
     20 # Rebuild the Python .proto files
     21 make -BC $DEST/generator/proto
     22 
     23 # Package the Python libraries
     24 ( cd $DEST/generator; pyinstaller nanopb_generator.py )
     25 mv $DEST/generator/dist/nanopb_generator $DEST/generator-bin
     26 
     27 # Remove temp files
     28 rm -rf $DEST/generator/dist $DEST/generator/build $DEST/generator/nanopb_generator.spec
     29 
     30 # Make the nanopb generator available as a protoc plugin
     31 cp $DEST/generator-bin/nanopb_generator $DEST/generator-bin/protoc-gen-nanopb
     32 
     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
     39 #!/bin/bash
     40 SCRIPTDIR=\$(dirname "\$0")
     41 export DYLD_LIBRARY_PATH=\$SCRIPTDIR
     42 export PATH=\$SCRIPTDIR:\$PATH
     43 exec "\$SCRIPTDIR/protoc.bin" "\$@"
     44 EOF
     45 chmod +x $DEST/generator-bin/protoc
     46 
     47 # Tar it all up
     48 ( cd dist; zip -r $VERSION.zip $VERSION )
     49 
     50