From: Niels De Graef Date: Mon, 5 Aug 2019 16:55:38 +0000 (+0200) Subject: Add GObject Introspection support to babl X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~11^2~25 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=02edc4e8d4b34adc44c536b37caeaebdf453990f;p=babl.git Add GObject Introspection support to babl This is needed for GIMP to also have proper GIR support for its plugins. Extra thanks go to Emmanuele Bassi for the identity filter. --- diff --git a/babl/identfilter.py b/babl/identfilter.py new file mode 100644 index 0000000..e592de4 --- /dev/null +++ b/babl/identfilter.py @@ -0,0 +1,37 @@ +# Copyright 2014 Emmanuele Bassi +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +import sys +import re + +def rename_babl_object(text): + # We need this to rename the Babl type into BablObject + # Otherwise the type clashes with the namespace + if text == 'Babl': + return 'BablObject' + + # Leave the rest unharmed + return text + +if __name__ == '__main__': + in_text = sys.stdin.read() + sys.stdout.write(rename_babl_object(in_text)) diff --git a/babl/meson.build b/babl/meson.build index c57bc93..3d86860 100644 --- a/babl/meson.build +++ b/babl/meson.build @@ -133,3 +133,21 @@ babl = library( version: so_version, install: true, ) + +if get_option('enable-gir') + # identity filter, so GIR doesn't choke on the Babl type + # (since it has the same name as the Babl namespace) + identfilter_py = join_paths(meson.current_source_dir(), 'identfilter.py') + + babl_gir = gnome.generate_gir(babl, + sources: babl_headers, + extra_args: [ + '--identifier-filter-cmd=@0@ @1@'.format(python.path(), identfilter_py), + '-DBABL_IS_BEING_COMPILED', + ], + namespace: 'Babl', + nsversion: '1', + header: 'babl.h', + install: true, + ) +endif diff --git a/meson.build b/meson.build index d0a1f9f..e2a2064 100644 --- a/meson.build +++ b/meson.build @@ -25,6 +25,7 @@ conf = configuration_data() pkgconfig = import('pkgconfig') i18n = import('i18n') gnome = import('gnome') +python = import('python') cc = meson.get_compiler('c') prefix = get_option('prefix') diff --git a/meson_options.txt b/meson_options.txt index f4a7ced..eca27be 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,5 +5,6 @@ option('enable-sse3', type: 'boolean', value: true, description: 'enable SSE3 option('enable-sse4_1', type: 'boolean', value: true, description: 'enable SSE4.1 support') option('enable-avx2', type: 'boolean', value: true, description: 'enable AVX2 support') option('enable-f16c', type: 'boolean', value: true, description: 'enable hardware half-float support') +option('enable-gir', type: 'boolean', value: true, description: 'enable GObject-Introspection (GIR)') option('with-docs', type: 'boolean', value: true, description: 'build website') option('with-lcms', type: 'boolean', value: true, description: 'build with lcms')