Fix qapi code generation fix
The fixes to qapi code generation had multiple bugs: - the Null class used to drop output was missing some methods - in some scripts it was never instantiated, leading to a None return, which is missing even more methods - the --source and --header options were swapped Luckily, all those bugs were hidden by a makefile bug which caused the old behaviour (with the race) to be invoked. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
73a511decc
commit
19bf7c8708
2
Makefile
2
Makefile
|
@ -177,7 +177,7 @@ qapi-dir := $(BUILD_DIR)/qapi-generated
|
||||||
test-qmp-input-visitor.o test-qmp-output-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir)
|
test-qmp-input-visitor.o test-qmp-output-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir)
|
||||||
qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
|
qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
|
||||||
|
|
||||||
gen-out-type = $(subst .,-,$@)
|
gen-out-type = $(subst .,-,$(suffix $@))
|
||||||
|
|
||||||
$(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\
|
$(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\
|
||||||
$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
|
$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
|
||||||
|
|
|
@ -399,9 +399,9 @@ for o, a in opts:
|
||||||
elif o in ("-m", "--middle"):
|
elif o in ("-m", "--middle"):
|
||||||
middle_mode = True
|
middle_mode = True
|
||||||
elif o in ("-c", "--source"):
|
elif o in ("-c", "--source"):
|
||||||
do_h = True
|
|
||||||
elif o in ("-h", "--header"):
|
|
||||||
do_c = True
|
do_c = True
|
||||||
|
elif o in ("-h", "--header"):
|
||||||
|
do_h = True
|
||||||
|
|
||||||
if not do_c and not do_h:
|
if not do_c and not do_h:
|
||||||
do_c = True
|
do_c = True
|
||||||
|
@ -411,15 +411,11 @@ c_file = output_dir + prefix + c_file
|
||||||
h_file = output_dir + prefix + h_file
|
h_file = output_dir + prefix + h_file
|
||||||
|
|
||||||
def maybe_open(really, name, opt):
|
def maybe_open(really, name, opt):
|
||||||
class Null(object):
|
|
||||||
def write(self, str):
|
|
||||||
pass
|
|
||||||
def read(self):
|
|
||||||
return ''
|
|
||||||
if really:
|
if really:
|
||||||
return open(name, opt)
|
return open(name, opt)
|
||||||
else:
|
else:
|
||||||
return Null()
|
import StringIO
|
||||||
|
return StringIO.StringIO()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(output_dir)
|
os.makedirs(output_dir)
|
||||||
|
|
|
@ -183,9 +183,9 @@ for o, a in opts:
|
||||||
elif o in ("-o", "--output-dir"):
|
elif o in ("-o", "--output-dir"):
|
||||||
output_dir = a + "/"
|
output_dir = a + "/"
|
||||||
elif o in ("-c", "--source"):
|
elif o in ("-c", "--source"):
|
||||||
do_h = True
|
|
||||||
elif o in ("-h", "--header"):
|
|
||||||
do_c = True
|
do_c = True
|
||||||
|
elif o in ("-h", "--header"):
|
||||||
|
do_h = True
|
||||||
|
|
||||||
if not do_c and not do_h:
|
if not do_c and not do_h:
|
||||||
do_c = True
|
do_c = True
|
||||||
|
@ -201,13 +201,11 @@ except os.error, e:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def maybe_open(really, name, opt):
|
def maybe_open(really, name, opt):
|
||||||
class Null(object):
|
|
||||||
def write(self, str):
|
|
||||||
pass
|
|
||||||
def read(self):
|
|
||||||
return ''
|
|
||||||
if really:
|
if really:
|
||||||
return open(name, opt)
|
return open(name, opt)
|
||||||
|
else:
|
||||||
|
import StringIO
|
||||||
|
return StringIO.StringIO()
|
||||||
|
|
||||||
fdef = maybe_open(do_c, c_file, 'w')
|
fdef = maybe_open(do_c, c_file, 'w')
|
||||||
fdecl = maybe_open(do_h, h_file, 'w')
|
fdecl = maybe_open(do_h, h_file, 'w')
|
||||||
|
|
|
@ -159,9 +159,9 @@ for o, a in opts:
|
||||||
elif o in ("-o", "--output-dir"):
|
elif o in ("-o", "--output-dir"):
|
||||||
output_dir = a + "/"
|
output_dir = a + "/"
|
||||||
elif o in ("-c", "--source"):
|
elif o in ("-c", "--source"):
|
||||||
do_h = True
|
|
||||||
elif o in ("-h", "--header"):
|
|
||||||
do_c = True
|
do_c = True
|
||||||
|
elif o in ("-h", "--header"):
|
||||||
|
do_h = True
|
||||||
|
|
||||||
if not do_c and not do_h:
|
if not do_c and not do_h:
|
||||||
do_c = True
|
do_c = True
|
||||||
|
@ -177,13 +177,11 @@ except os.error, e:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def maybe_open(really, name, opt):
|
def maybe_open(really, name, opt):
|
||||||
class Null(object):
|
|
||||||
def write(self, str):
|
|
||||||
pass
|
|
||||||
def read(self):
|
|
||||||
return ''
|
|
||||||
if really:
|
if really:
|
||||||
return open(name, opt)
|
return open(name, opt)
|
||||||
|
else:
|
||||||
|
import StringIO
|
||||||
|
return StringIO.StringIO()
|
||||||
|
|
||||||
fdef = maybe_open(do_c, c_file, 'w')
|
fdef = maybe_open(do_c, c_file, 'w')
|
||||||
fdecl = maybe_open(do_h, h_file, 'w')
|
fdecl = maybe_open(do_h, h_file, 'w')
|
||||||
|
|
Loading…
Reference in New Issue