gdbus-codegen: Split license string

The license string which is embedded in the C header and body
preambles has been moved to a global variable. This way it can be
reused in both sections.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
This commit is contained in:
Iñigo Martínez
2018-01-03 10:26:12 +01:00
parent 6dafc1ce13
commit a3d223d0e9

View File

@@ -25,6 +25,13 @@ from . import config
from . import utils from . import utils
from . import dbustypes from . import dbustypes
LICENSE_STR = '''/*
* Generated by gdbus-codegen {!s}. DO NOT EDIT.
*
* The license of this code is the same as for the D-Bus interface description
* it was derived from.
*/\n'''
# ---------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------
class CodeGenerator: class CodeGenerator:
@@ -55,14 +62,8 @@ class CodeGenerator:
# ---------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------
def generate_intro(self): def generate_intro(self):
self.c.write('/*\n' self.c.write(LICENSE_STR.format(config.VERSION))
' * Generated by gdbus-codegen %s. DO NOT EDIT.\n' self.c.write('\n')
' *\n'
' * The license of this code is the same as for the D-Bus interface description\n'
' * it was derived from.\n'
' */\n'
'\n'
%(config.VERSION))
self.c.write('#ifdef HAVE_CONFIG_H\n' self.c.write('#ifdef HAVE_CONFIG_H\n'
'# include "config.h"\n' '# include "config.h"\n'
'#endif\n' '#endif\n'
@@ -220,20 +221,15 @@ class CodeGenerator:
'}\n' '}\n'
'\n') '\n')
self.h.write('/*\n' self.h.write(LICENSE_STR.format(config.VERSION))
' * Generated by gdbus-codegen %s. DO NOT EDIT.\n' self.h.write('\n')
' *\n' self.h.write('#ifndef __{!s}__\n'.format(self.header_guard))
' * The license of this code is the same as for the D-Bus interface description\n' self.h.write('#define __{!s}__\n'.format(self.header_guard))
' * it was derived from.\n' self.h.write('\n')
' */\n' self.h.write('#include <gio/gio.h>\n')
'\n' self.h.write('\n')
'#ifndef __%s__\n' self.h.write('G_BEGIN_DECLS\n')
'#define __%s__\n' self.h.write('\n')
'\n'%(config.VERSION, self.header_guard, self.header_guard))
self.h.write('#include <gio/gio.h>\n'
'\n'
'G_BEGIN_DECLS\n'
'\n')
# ---------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------