aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi-visit.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-04-02 13:12:21 +0200
committerMarkus Armbruster <armbru@redhat.com>2015-05-14 18:37:14 +0200
commit2114f5a98d0d80774306279e1694de074ca86aa0 (patch)
tree8d20953275cd846c3a04e49a1aa29ddb6f4e7d49 /scripts/qapi-visit.py
parent72aaa73a4acef06bfaed750064c40a597f0cf745 (diff)
qapi: Factor parse_command_line() out of the generators
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi-visit.py')
-rw-r--r--scripts/qapi-visit.py35
1 files changed, 4 insertions, 31 deletions
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index e511be357d..75f0cf3db5 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -15,9 +15,7 @@
from ordereddict import OrderedDict
from qapi import *
import re
-import sys
import os
-import getopt
import errno
implicit_structs = []
@@ -376,42 +374,17 @@ void visit_type_%(name)s(Visitor *m, %(name)s *obj, const char *name, Error **er
''',
name=c_name(name))
-try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], "chbp:i:o:",
- ["source", "header", "builtins", "prefix=",
- "input-file=", "output-dir="])
-except getopt.GetoptError, err:
- print str(err)
- sys.exit(1)
-
-input_file = ""
-output_dir = ""
-prefix = ""
c_file = 'qapi-visit.c'
h_file = 'qapi-visit.h'
-
-do_c = False
-do_h = False
do_builtins = False
+(input_file, output_dir, do_c, do_h, prefix, opts) = \
+ parse_command_line("b", ["builtins"])
+
for o, a in opts:
- if o in ("-p", "--prefix"):
- prefix = a
- elif o in ("-i", "--input-file"):
- input_file = a
- elif o in ("-o", "--output-dir"):
- output_dir = a + "/"
- elif o in ("-c", "--source"):
- do_c = True
- elif o in ("-h", "--header"):
- do_h = True
- elif o in ("-b", "--builtins"):
+ if o in ("-b", "--builtins"):
do_builtins = True
-if not do_c and not do_h:
- do_c = True
- do_h = True
-
c_file = output_dir + prefix + c_file
h_file = output_dir + prefix + h_file