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