build 884 B

123456789101112131415161718192021222324252627282930
  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. for cur, dirs, files in os.walk('.'):
  10. if cur[2:8] == 'google':
  11. continue
  12. for file in files:
  13. f, ext = os.path.splitext(file)
  14. if ext != '.proto':
  15. continue
  16. if args.golang:
  17. os.system('protoc --go_out=. {}'.format(os.path.join(cur,file)))
  18. if args.python:
  19. os.system('protoc --python_out=. {}'.format(os.path.join(cur, file)))
  20. print('.')
  21. if __name__ == '__main__':
  22. main()
  23. print('done. check if any errors.')