| 12345678910111213141516171819202122232425262728293031 |
- #!/usr/bin/env python
- import os
- import argparse
- def main():
- parser = argparse.ArgumentParser()
- parser.add_argument('-g', '--golang', help='build proto to golang output', action='store_true')
- parser.add_argument('-p', '--python', help='build proto to python output', action='store_true')
- args = parser.parse_args()
-
- if not args.golang and not args.python:
- args.golang = True
- for cur, dirs, files in os.walk('.'):
- if cur[2:8] == 'google':
- continue
- for file in files:
- f, ext = os.path.splitext(file)
- if ext != '.proto':
- continue
- if args.golang:
- os.system('protoc --go_out=. {}'.format(os.path.join(cur,file)))
- if args.python:
- os.system('protoc --python_out=. {}'.format(os.path.join(cur, file)))
- print('.')
- if __name__ == '__main__':
- main()
- print('done. check if any errors.')
|