Commit 1217b1bc authored by Philip Withnall's avatar Philip Withnall

codegen: List basenames of input files in generated preamble

This makes it a bit easier for debugging which files were generated from
which introspection XML.
Signed-off-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=650875
parent 80764866
Pipeline #9524 passed with stage
in 2 minutes and 14 seconds
...@@ -29,7 +29,7 @@ from . import dbustypes ...@@ -29,7 +29,7 @@ from . import dbustypes
from .utils import print_error from .utils import print_error
LICENSE_STR = '''/* LICENSE_STR = '''/*
* Generated by gdbus-codegen {!s}. DO NOT EDIT. * Generated by gdbus-codegen {!s} from {!s}. DO NOT EDIT.
* *
* The license of this code is the same as for the D-Bus interface description * The license of this code is the same as for the D-Bus interface description
* it was derived from. * it was derived from.
...@@ -53,19 +53,22 @@ def generate_namespace(namespace): ...@@ -53,19 +53,22 @@ def generate_namespace(namespace):
class HeaderCodeGenerator: class HeaderCodeGenerator:
def __init__(self, ifaces, namespace, generate_objmanager, def __init__(self, ifaces, namespace, generate_objmanager,
generate_autocleanup, header_name, use_pragma, outfile): generate_autocleanup, header_name, input_files_basenames,
use_pragma, outfile):
self.ifaces = ifaces self.ifaces = ifaces
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace) self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
self.generate_objmanager = generate_objmanager self.generate_objmanager = generate_objmanager
self.generate_autocleanup = generate_autocleanup self.generate_autocleanup = generate_autocleanup
self.header_guard = header_name.upper().replace('.', '_').replace('-', '_').replace('/', '_').replace(':', '_') self.header_guard = header_name.upper().replace('.', '_').replace('-', '_').replace('/', '_').replace(':', '_')
self.input_files_basenames = input_files_basenames
self.use_pragma = use_pragma self.use_pragma = use_pragma
self.outfile = outfile self.outfile = outfile
# ---------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------
def generate_header_preamble(self): def generate_header_preamble(self):
self.outfile.write(LICENSE_STR.format(config.VERSION)) basenames = ', '.join(self.input_files_basenames)
self.outfile.write(LICENSE_STR.format(config.VERSION, basenames))
self.outfile.write('\n') self.outfile.write('\n')
if self.use_pragma: if self.use_pragma:
...@@ -612,18 +615,20 @@ class HeaderCodeGenerator: ...@@ -612,18 +615,20 @@ class HeaderCodeGenerator:
class CodeGenerator: class CodeGenerator:
def __init__(self, ifaces, namespace, generate_objmanager, header_name, def __init__(self, ifaces, namespace, generate_objmanager, header_name,
docbook_gen, outfile): input_files_basenames, docbook_gen, outfile):
self.ifaces = ifaces self.ifaces = ifaces
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace) self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
self.generate_objmanager = generate_objmanager self.generate_objmanager = generate_objmanager
self.header_name = header_name self.header_name = header_name
self.input_files_basenames = input_files_basenames
self.docbook_gen = docbook_gen self.docbook_gen = docbook_gen
self.outfile = outfile self.outfile = outfile
# ---------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------
def generate_body_preamble(self): def generate_body_preamble(self):
self.outfile.write(LICENSE_STR.format(config.VERSION)) basenames = ', '.join(self.input_files_basenames)
self.outfile.write(LICENSE_STR.format(config.VERSION, basenames))
self.outfile.write('\n') self.outfile.write('\n')
self.outfile.write('#ifdef HAVE_CONFIG_H\n' self.outfile.write('#ifdef HAVE_CONFIG_H\n'
'# include "config.h"\n' '# include "config.h"\n'
......
...@@ -212,11 +212,13 @@ def codegen_main(): ...@@ -212,11 +212,13 @@ def codegen_main():
header_name = os.path.splitext(c_file)[0] + '.h' header_name = os.path.splitext(c_file)[0] + '.h'
all_ifaces = [] all_ifaces = []
input_files_basenames = []
for fname in args.files + args.xml_files: for fname in args.files + args.xml_files:
with open(fname, 'rb') as f: with open(fname, 'rb') as f:
xml_data = f.read() xml_data = f.read()
parsed_ifaces = parser.parse_dbus_xml(xml_data) parsed_ifaces = parser.parse_dbus_xml(xml_data)
all_ifaces.extend(parsed_ifaces) all_ifaces.extend(parsed_ifaces)
input_files_basenames.append(os.path.basename(fname))
if args.annotate != None: if args.annotate != None:
apply_annotations(all_ifaces, args.annotate) apply_annotations(all_ifaces, args.annotate)
...@@ -236,6 +238,7 @@ def codegen_main(): ...@@ -236,6 +238,7 @@ def codegen_main():
args.c_generate_object_manager, args.c_generate_object_manager,
args.c_generate_autocleanup, args.c_generate_autocleanup,
header_name, header_name,
input_files_basenames,
args.pragma_once, args.pragma_once,
outfile) outfile)
gen.generate() gen.generate()
...@@ -246,6 +249,7 @@ def codegen_main(): ...@@ -246,6 +249,7 @@ def codegen_main():
args.c_namespace, args.c_namespace,
args.c_generate_object_manager, args.c_generate_object_manager,
header_name, header_name,
input_files_basenames,
docbook_gen, docbook_gen,
outfile) outfile)
gen.generate() gen.generate()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment