@@ -2047,10 +2047,11 @@ def generate(kind, output):
enum_types = []
event_types = {}
indent_level = 0
+ prefix = output.split("/")[-1].split(".")[0]
- guard = '%s_H' % c_var(output[:-2]).upper()
- core = '%s-core.h' % output[:-2]
- header = '%s.h' % output[:-2]
+ guard = '%s_H' % c_var(prefix).upper()
+ core = '%s-core.h' % prefix
+ header = '%s.h' % prefix
if kind.endswith('body') or kind.endswith('header'):
ret = mcgen('''
@@ -2387,7 +2388,7 @@ void qcfg_options_init(void)
return ret
def main(args):
- if len(args) != 2:
+ if len(args) < 2:
return 1
if not args[0].startswith('--'):
return 1
To avoid errors when generating output to a seperate subdirectory, use only the filename, minus any leading directories, when passing it into functions to be used as a prefix for header guards, includes, etc. Also, trim file extensions based on "." seperator instead of assuming a single-char extension and trimming the last 2 chars Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- qmp-gen.py | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)