diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-05-04 12:19:19 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-05-07 14:14:40 +0100 |
commit | ed4ed83ec28ff130afbf28c5c4dc8f76614bccc3 (patch) | |
tree | c8d6b6ca31499090821e67898fdd81d76c696a14 | |
parent | 34752d004ced4ce4ac75e7ab0c601bf444bed864 (diff) |
Add multiple-inclusion guards to generated client-side code
Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49384
-rw-r--r-- | telepathy-glib/codegen.am | 1 | ||||
-rw-r--r-- | tools/glib-client-gen.py | 13 |
2 files changed, 13 insertions, 1 deletions
diff --git a/telepathy-glib/codegen.am b/telepathy-glib/codegen.am index 02fe35dac..cd9a2ae70 100644 --- a/telepathy-glib/codegen.am +++ b/telepathy-glib/codegen.am @@ -298,6 +298,7 @@ _gen/tp-cli-%-body.h: _gen/tp-spec-%.xml \ $(PYTHON) $(tools_dir)/glib-client-gen.py \ $$subclass $$subclass_assert \ --group `echo $* | tr - _` \ + --guard "TP_GEN_TP_CLI_`echo $* | tr a-z- A-Z_`_H_INCLUDED" \ --iface-quark-prefix=TP_IFACE_QUARK \ --tp-proxy-api=0.7.6 \ --deprecation-attribute=_TP_GNUC_DEPRECATED \ diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py index c94bd2c31..6b2b97f1d 100644 --- a/tools/glib-client-gen.py +++ b/tools/glib-client-gen.py @@ -71,6 +71,8 @@ class Generator(object): self.deprecation_attribute = opts.get('--deprecation-attribute', 'G_GNUC_DEPRECATED') + self.guard = opts.get('--guard', None) + def h(self, s): if isinstance(s, unicode): s = s.encode('utf-8') @@ -1171,6 +1173,11 @@ class Generator(object): def __call__(self): + if self.guard is not None: + self.h('#ifndef %s' % self.guard) + self.h('#define %s' % self.guard) + self.h('') + self.h('G_BEGIN_DECLS') self.h('') @@ -1229,6 +1236,10 @@ class Generator(object): self.h('G_END_DECLS') self.h('') + if self.guard is not None: + self.h('#endif /* defined (%s) */' % self.guard) + self.h('') + file_set_contents(self.basename + '.h', '\n'.join(self.__header)) file_set_contents(self.basename + '-body.h', '\n'.join(self.__body)) file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs)) @@ -1242,7 +1253,7 @@ if __name__ == '__main__': ['group=', 'subclass=', 'subclass-assert=', 'iface-quark-prefix=', 'tp-proxy-api=', 'generate-reentrant=', 'deprecate-reentrant=', - 'deprecation-attribute=']) + 'deprecation-attribute=', 'guard=']) opts = {} |