2
0

make_windows_package.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # Run this script in the top nanopb directory to create a binary package
  3. # for Windows users. This script is designed to run under MingW/MSYS bash
  4. # and requires the following tools: git, make, zip, unix2dos
  5. set -e
  6. set -x
  7. VERSION=`git describe --always`-windows-x86
  8. DEST=dist/$VERSION
  9. rm -rf $DEST
  10. mkdir -p $DEST
  11. # Export the files from newest commit
  12. git archive HEAD | tar x -C $DEST
  13. # Rebuild the Python .proto files and .pyc
  14. ( cd $DEST/generator; py -3 nanopb_generator.py ||: )
  15. # Package the Python libraries
  16. ( cd $DEST/generator; py -3 -m PyInstaller nanopb_generator.py )
  17. ( cd $DEST/generator; py -3 -m PyInstaller protoc )
  18. mv $DEST/generator/dist/nanopb_generator $DEST/generator-bin
  19. cp $DEST/generator/dist/protoc/protoc.exe $DEST/generator-bin
  20. # Include Google's descriptor.proto and nanopb.proto
  21. cp -pr $(py -3 -c 'import grpc_tools, os.path; print(os.path.dirname(grpc_tools.__file__))')/_proto $DEST/generator-bin/grpc_tools/
  22. cp -pr $DEST/generator/proto $DEST/generator-bin/proto
  23. # Remove temp files
  24. rm -rf $DEST/generator/dist $DEST/generator/build $DEST/generator/*.spec
  25. # Make the nanopb generator available as a protoc plugin
  26. cp $DEST/generator-bin/nanopb_generator.exe $DEST/generator-bin/protoc-gen-nanopb.exe
  27. # Convert line breaks for convenience
  28. find $DEST -name '*.c' -o -name '*.h' -o -name '*.txt' \
  29. -o -name '*.proto' -o -name '*.py' -o -name '*.options' \
  30. -exec sed -i 's/$/\r/' '{}' \;
  31. # Zip it all up
  32. ( cd dist; rm -f $VERSION.zip; powershell "Compress-Archive $VERSION $VERSION.zip" )