From 86dede390aa496b89934a66206112b41d95243af Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 29 Nov 2021 21:18:41 -0800 Subject: [PATCH] Update regen-protos.sh for #45 and #46 --- bin/regen-protos.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/regen-protos.sh b/bin/regen-protos.sh index 9ceb46b..169f509 100755 --- a/bin/regen-protos.sh +++ b/bin/regen-protos.sh @@ -1,11 +1,15 @@ #!/bin/bash - -protoc -I=proto --python_out meshtastic `ls proto/*.proto` +./nanopb-0.4.4/generator-bin/protoc -I=proto --python_out meshtastic `ls proto/*.proto` # workaround for import bug in protoc https://github.com/protocolbuffers/protobuf/issues/1491#issuecomment-690618628 -sed -i -E 's/^import.*_pb2/from . \0/' meshtastic/*.py +if [[ $OSTYPE == 'darwin'* ]]; then + sed -i -E 's/^\(import.*_pb2\)/from . \1/' meshtastic/*.py +else + sed -i -E 's/^import.*_pb2/from . \0/' meshtastic/*.py +fi + # automate the current workaround (may be related to Meshtastic-protobufs issue #27 https://github.com/meshtastic/Meshtastic-protobufs/issues/27) -sed -i "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py +sed -i '' -e "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py