Add GObject Introspection support to babl
authorNiels De Graef <nielsdegraef@gmail.com>
Mon, 5 Aug 2019 16:55:38 +0000 (18:55 +0200)
committerØyvind Kolås <pippin@gimp.org>
Tue, 6 Aug 2019 18:34:20 +0000 (20:34 +0200)
This is needed for GIMP to also have proper GIR support for its plugins.

Extra thanks go to Emmanuele Bassi for the identity filter.

babl/identfilter.py [new file with mode: 0644]
babl/meson.build
meson.build
meson_options.txt

diff --git a/babl/identfilter.py b/babl/identfilter.py
new file mode 100644 (file)
index 0000000..e592de4
--- /dev/null
@@ -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))
index c57bc938d43636462febcf5b09099e72cd09ad53..3d86860a4e33996fc731ecc05ae0dfc09040871d 100644 (file)
@@ -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
index d0a1f9fa235a7640bab8b1e5ee7606f864a5b135..e2a2064bf0aa9055d39544669ce26bf2b4cfb92f 100644 (file)
@@ -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')
index f4a7ced5bdba32fd692bc80e3b2c49bafa9ed601..eca27beb6ff4b823a312a3f0cb2e6150d2d78c18 100644 (file)
@@ -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')