gdbus-codegen: Add --output-directory flag

This is useful with Meson where files are generated in subdirs

https://bugzilla.gnome.org/show_bug.cgi?id=778801
This commit is contained in:
Patrick Griffis
2017-02-16 21:03:18 -05:00
parent 001245171b
commit ee09bb704f
3 changed files with 30 additions and 7 deletions

View File

@@ -21,6 +21,7 @@
import sys
import optparse
from os import path
from . import config
from . import utils
@@ -162,6 +163,8 @@ def codegen_main():
help='Generate Docbook in OUTFILES-org.Project.IFace.xml')
arg_parser.add_option('', '--annotate', nargs=3, action='append', metavar='WHAT KEY VALUE',
help='Add annotation (may be used several times)')
arg_parser.add_option('', '--output-directory', metavar='OUTDIR', default='',
help='Location to output generated files')
(opts, args) = arg_parser.parse_args();
all_ifaces = []
@@ -185,15 +188,18 @@ def codegen_main():
c_code = opts.generate_c_code
if c_code:
h = open(c_code + '.h', 'w')
c = open(c_code + '.c', 'w')
outdir = opts.output_directory
header_name = c_code + '.h'
h = open(path.join(outdir, header_name), 'w')
c = open(path.join(outdir, c_code + '.c'), 'w')
gen = codegen.CodeGenerator(all_ifaces,
opts.c_namespace,
opts.interface_prefix,
opts.c_generate_object_manager,
opts.c_generate_autocleanup,
docbook_gen,
h, c);
h, c,
header_name)
ret = gen.generate()
h.close()
c.close()