aboutsummaryrefslogtreecommitdiff
path: root/modules/gnome.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-03-08 19:39:03 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-03-08 19:39:03 +0200
commit3f46cd7fb30e3a478c44cac565d2ae12c72a0c25 (patch)
tree42c26ddfbb871bededf9fcfc278f80106e7ecf52 /modules/gnome.py
parentc0f097c0c74551972f7ec2203cd960824984f058 (diff)
downloadmeson-3f46cd7fb30e3a478c44cac565d2ae12c72a0c25.zip
meson-3f46cd7fb30e3a478c44cac565d2ae12c72a0c25.tar.gz
meson-3f46cd7fb30e3a478c44cac565d2ae12c72a0c25.tar.bz2
Added gobject-introspection to gnome module.
Diffstat (limited to 'modules/gnome.py')
-rw-r--r--modules/gnome.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/gnome.py b/modules/gnome.py
index 6779b60..fd8d09d 100644
--- a/modules/gnome.py
+++ b/modules/gnome.py
@@ -17,6 +17,8 @@ functionality such as gobject-introspection and gresources.'''
import build
import os
+import subprocess
+from coredata import MesonException
def compile_resources(state, args, kwargs):
cmd = ['glib-compile-resources', '@INPUT@', '--generate']
@@ -35,3 +37,35 @@ def compile_resources(state, args, kwargs):
kwargs['output'] = output_h
target_h = build.CustomTarget(args[0] + '_h', state.subdir, kwargs)
return [target_c, target_h]
+
+def generate_gir(state, args, kwargs):
+ if len(args) != 1:
+ raise MesonException('Gir takes one argument')
+ girtarget = args[0]
+ while hasattr(girtarget, 'held_object'):
+ girtarget = girtarget.held_object
+ if not isinstance(girtarget, build.Executable):
+ raise MesonException('Gir target must be an executable')
+ pkgstr = subprocess.check_output(['pkg-config', '--cflags', 'gobject-introspection-1.0'])
+ pkgargs = pkgstr.decode().strip().split()
+ ns = kwargs.pop('namespace')
+ nsversion = kwargs.pop('nsversion')
+ libsources = kwargs.pop('sources')
+ girfile = '%s-%s.gir' % (ns, nsversion)
+ scan_name = girtarget.name + '-gir'
+ scan_command = ['g-ir-scanner', '@INPUT@', '--program', girtarget]
+ scan_command += pkgargs
+ scan_command += ['--include=GObject-2.0', '--namespace='+ns,
+ '--nsversion=' + nsversion, '--output', '@OUTPUT@']
+ scankwargs = {'output' : girfile,
+ 'input' : libsources,
+ 'command' : scan_command}
+ scan_target = build.CustomTarget(scan_name, state.subdir, scankwargs)
+
+ typelib_name = girtarget.name + '-typelib'
+ typelib_output = '%s-%s.typelib' % (ns, nsversion)
+ typelib_cmd = ['g-ir-compiler', scan_target, '--output', '@OUTPUT@']
+ kwargs['output'] = typelib_output
+ kwargs['command'] = typelib_cmd
+ typelib_target = build.CustomTarget(typelib_name, state.subdir, kwargs)
+ return [scan_target, typelib_target]