gdbus-codegen: Fix issue with docbook generation

In cases where gdbus-codegen is used only for docbook generation,
the execution stops with the following error message:

  `Using --header or --body requires --output`

This is because it was assumed that, in addition to the docbook
generation, the header or source code were always generated.

This patch fixes this, and the header or source code generation
is not mandatory, so the docbook can be generated separately.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
This commit is contained in:
Iñigo Martínez 2018-01-24 16:25:09 +01:00 committed by Philip Withnall
parent 382d13b618
commit 93042e0052

View File

@ -193,20 +193,21 @@ def codegen_main():
'--output at the same time is not allowed') '--output at the same time is not allowed')
if args.generate_c_code: if args.generate_c_code:
outdir = args.output_directory
header_name = args.generate_c_code + '.h' header_name = args.generate_c_code + '.h'
h_file = os.path.join(outdir, header_name) h_file = os.path.join(args.output_directory, header_name)
args.header = True args.header = True
c_file = os.path.join(outdir, args.generate_c_code + '.c') c_file = os.path.join(args.output_directory, args.generate_c_code + '.c')
args.body = True args.body = True
else: elif args.header:
if args.output is None: if args.output is None:
print_error('Using --header or --body requires --output') print_error('Using --header requires --output')
if args.header:
h_file = args.output h_file = args.output
header_name = os.path.basename(h_file) header_name = os.path.basename(h_file)
elif args.body: elif args.body:
if args.output is None:
print_error('Using --body requires --output')
c_file = args.output c_file = args.output
header_name = os.path.splitext(c_file)[0] + '.h' header_name = os.path.splitext(c_file)[0] + '.h'
@ -226,7 +227,7 @@ def codegen_main():
docbook = args.generate_docbook docbook = args.generate_docbook
docbook_gen = codegen_docbook.DocbookCodeGenerator(all_ifaces); docbook_gen = codegen_docbook.DocbookCodeGenerator(all_ifaces);
if docbook: if docbook:
ret = docbook_gen.generate(docbook, outdir) ret = docbook_gen.generate(docbook, args.output_directory)
if args.header: if args.header:
with open(h_file, 'w') as outfile: with open(h_file, 'w') as outfile: