mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 12:28:48 +02:00
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:
parent
001245171b
commit
ee09bb704f
@ -33,6 +33,7 @@
|
|||||||
<arg><option>--c-namespace</option> <replaceable>YourProject</replaceable></arg>
|
<arg><option>--c-namespace</option> <replaceable>YourProject</replaceable></arg>
|
||||||
<arg><option>--c-generate-object-manager</option></arg>
|
<arg><option>--c-generate-object-manager</option></arg>
|
||||||
<arg><option>--c-generate-autocleanup</option> none|objects|all</arg>
|
<arg><option>--c-generate-autocleanup</option> none|objects|all</arg>
|
||||||
|
<arg><option>--output-directory</option> <replaceable>OUTDIR</replaceable></arg>
|
||||||
<arg><option>--generate-docbook</option> <replaceable>OUTFILES</replaceable></arg>
|
<arg><option>--generate-docbook</option> <replaceable>OUTFILES</replaceable></arg>
|
||||||
<arg><option>--xml-files</option> <replaceable>FILE</replaceable></arg>
|
<arg><option>--xml-files</option> <replaceable>FILE</replaceable></arg>
|
||||||
<group choice="plain" rep="repeat">
|
<group choice="plain" rep="repeat">
|
||||||
@ -187,7 +188,12 @@
|
|||||||
<para>
|
<para>
|
||||||
Generate C code for all D-Bus interfaces and put it in
|
Generate C code for all D-Bus interfaces and put it in
|
||||||
<filename>OUTFILES.c</filename> and
|
<filename>OUTFILES.c</filename> and
|
||||||
<filename>OUTFILES.h</filename>.
|
<filename>OUTFILES.h</filename> including any sub-directories. If you want the files to
|
||||||
|
be output in a different location use <option>--output-directory</option> as <filename>OUTFILES.h</filename>
|
||||||
|
including sub-directories will be referenced from <filename>OUTFILES.c</filename>.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The full paths would then be <literal>$(OUTDIR)/$(dirname $OUTFILES)/$(basename $OUTFILES).{c,h}</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -230,6 +236,15 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--output-directory</option> <replaceable>OUTDIR</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Directory to output generated source to. Equivalent to changing directory before generation.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--annotate</option> <replaceable>ELEMENT</replaceable> <replaceable>KEY</replaceable> <replaceable>VALUE</replaceable></term>
|
<term><option>--annotate</option> <replaceable>ELEMENT</replaceable> <replaceable>KEY</replaceable> <replaceable>VALUE</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -28,13 +28,15 @@ from . import dbustypes
|
|||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class CodeGenerator:
|
class CodeGenerator:
|
||||||
def __init__(self, ifaces, namespace, interface_prefix, generate_objmanager, generate_autocleanup, docbook_gen, h, c):
|
def __init__(self, ifaces, namespace, interface_prefix, generate_objmanager,
|
||||||
|
generate_autocleanup, docbook_gen, h, c, header_name):
|
||||||
self.docbook_gen = docbook_gen
|
self.docbook_gen = docbook_gen
|
||||||
self.generate_objmanager = generate_objmanager
|
self.generate_objmanager = generate_objmanager
|
||||||
self.generate_autocleanup = generate_autocleanup
|
self.generate_autocleanup = generate_autocleanup
|
||||||
self.ifaces = ifaces
|
self.ifaces = ifaces
|
||||||
self.h = h
|
self.h = h
|
||||||
self.c = c
|
self.c = c
|
||||||
|
self.header_name = header_name
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
if len(namespace) > 0:
|
if len(namespace) > 0:
|
||||||
if utils.is_ugly_case(namespace):
|
if utils.is_ugly_case(namespace):
|
||||||
@ -48,7 +50,7 @@ class CodeGenerator:
|
|||||||
self.ns_upper = ''
|
self.ns_upper = ''
|
||||||
self.ns_lower = ''
|
self.ns_lower = ''
|
||||||
self.interface_prefix = interface_prefix
|
self.interface_prefix = interface_prefix
|
||||||
self.header_guard = self.h.name.upper().replace('.', '_').replace('-', '_').replace('/', '_')
|
self.header_guard = header_name.upper().replace('.', '_').replace('-', '_').replace('/', '_')
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ class CodeGenerator:
|
|||||||
'#include "%s"\n'
|
'#include "%s"\n'
|
||||||
'\n'
|
'\n'
|
||||||
'#include <string.h>\n'
|
'#include <string.h>\n'
|
||||||
%(self.h.name))
|
%(self.header_name))
|
||||||
|
|
||||||
self.c.write('#ifdef G_OS_UNIX\n'
|
self.c.write('#ifdef G_OS_UNIX\n'
|
||||||
'# include <gio/gunixfdlist.h>\n'
|
'# include <gio/gunixfdlist.h>\n'
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import optparse
|
import optparse
|
||||||
|
from os import path
|
||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
from . import utils
|
from . import utils
|
||||||
@ -162,6 +163,8 @@ def codegen_main():
|
|||||||
help='Generate Docbook in OUTFILES-org.Project.IFace.xml')
|
help='Generate Docbook in OUTFILES-org.Project.IFace.xml')
|
||||||
arg_parser.add_option('', '--annotate', nargs=3, action='append', metavar='WHAT KEY VALUE',
|
arg_parser.add_option('', '--annotate', nargs=3, action='append', metavar='WHAT KEY VALUE',
|
||||||
help='Add annotation (may be used several times)')
|
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();
|
(opts, args) = arg_parser.parse_args();
|
||||||
|
|
||||||
all_ifaces = []
|
all_ifaces = []
|
||||||
@ -185,15 +188,18 @@ def codegen_main():
|
|||||||
|
|
||||||
c_code = opts.generate_c_code
|
c_code = opts.generate_c_code
|
||||||
if c_code:
|
if c_code:
|
||||||
h = open(c_code + '.h', 'w')
|
outdir = opts.output_directory
|
||||||
c = open(c_code + '.c', 'w')
|
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,
|
gen = codegen.CodeGenerator(all_ifaces,
|
||||||
opts.c_namespace,
|
opts.c_namespace,
|
||||||
opts.interface_prefix,
|
opts.interface_prefix,
|
||||||
opts.c_generate_object_manager,
|
opts.c_generate_object_manager,
|
||||||
opts.c_generate_autocleanup,
|
opts.c_generate_autocleanup,
|
||||||
docbook_gen,
|
docbook_gen,
|
||||||
h, c);
|
h, c,
|
||||||
|
header_name)
|
||||||
ret = gen.generate()
|
ret = gen.generate()
|
||||||
h.close()
|
h.close()
|
||||||
c.close()
|
c.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user