build 959 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. import os
  3. import argparse
  4. def main():
  5. parser = argparse.ArgumentParser()
  6. parser.add_argument('-g', '--golang', help='build proto to golang output', action='store_true')
  7. parser.add_argument('-p', '--python', help='build proto to python output', action='store_true')
  8. args = parser.parse_args()
  9. if not args.golang and not args.python:
  10. args.golang = True
  11. for cur, dirs, files in os.walk('.'):
  12. if cur[2:8] == 'google':
  13. continue
  14. for file in files:
  15. f, ext = os.path.splitext(file)
  16. if ext != '.proto':
  17. continue
  18. if args.golang:
  19. os.system('protoc --go_out=. {}'.format(os.path.join(cur,file)))
  20. if args.python:
  21. os.system('protoc --python_out=. {}'.format(os.path.join(cur, file)))
  22. print('.')
  23. if __name__ == '__main__':
  24. main()
  25. print('done. check if any errors.')