|
|
@@ -1,14 +1,30 @@
|
|
|
#!/usr/bin/env python
|
|
|
import os
|
|
|
-print('compile proto to go file')
|
|
|
-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':
|
|
|
+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()
|
|
|
+
|
|
|
+ for cur, dirs, files in os.walk('.'):
|
|
|
+ if cur[2:8] == 'google':
|
|
|
continue
|
|
|
- os.system('protoc --go_out=. {}'.format(os.path.join(cur,file)))
|
|
|
- print('.')
|
|
|
+ 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('.')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-print('done. check if there any errors')
|
|
|
+if __name__ == '__main__':
|
|
|
+ main()
|
|
|
+ print('done. check if any errors.')
|