protoc 883 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python3
  2. import sys
  3. import os
  4. import os.path
  5. from nanopb_generator import invoke_protoc
  6. if __name__ == '__main__':
  7. # Add argument so that protoc-gen-nanopb gets found
  8. if getattr(sys, 'frozen', False):
  9. mypath = os.path.dirname(sys.executable) # For pyInstaller
  10. else:
  11. mypath = os.path.dirname(__file__)
  12. if os.path.isfile(os.path.join(mypath, "protoc-gen-nanopb.exe")):
  13. protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb.exe")
  14. elif os.name == 'nt':
  15. protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb.bat")
  16. else:
  17. protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb")
  18. args = sys.argv[1:]
  19. if os.path.isfile(protoc_gen_nanopb):
  20. args = ['--plugin=protoc-gen-nanopb=%s' % protoc_gen_nanopb] + args
  21. status = invoke_protoc(['protoc'] + args)
  22. sys.exit(status)