Added gobject-introspection to gnome module.

pull/39/merge
Jussi Pakkanen 10 years ago
parent c0f097c0c7
commit 3f46cd7fb3
  1. 1
      meson.py
  2. 34
      modules/gnome.py
  3. 12
      test cases/frameworks/10 gresource/meson.build
  4. 35
      test cases/frameworks/7 gir/meson.build
  5. 0
      test cases/frameworks/7 gnome/data/res1.txt
  6. 0
      test cases/frameworks/7 gnome/golib.c
  7. 0
      test cases/frameworks/7 gnome/golib.h
  8. 0
      test cases/frameworks/7 gnome/installed_files.txt
  9. 0
      test cases/frameworks/7 gnome/main.c
  10. 31
      test cases/frameworks/7 gnome/meson.build
  11. 0
      test cases/frameworks/7 gnome/myresource.gresource.xml
  12. 0
      test cases/frameworks/7 gnome/prog.c

@ -150,7 +150,6 @@ if __name__ == '__main__':
else:
handshake = False
options = parser.parse_args(args[1:])
print(options.directories)
args = options.directories
if len(args) == 0 or len(args) > 2:
print('%s <source directory> <build directory>' % sys.argv[0])

@ -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]

@ -1,12 +0,0 @@
project('glib compile resource', 'c')
gnome = import('gnome')
gio = dependency('gio-2.0')
myres = gnome.compile_resources('myresources', 'myresource.gresource.xml',
source_dir : 'data',
c_name : 'myres')
exe = executable('resprog', 'main.c', myres,
dependencies : gio)
test('resource test', exe)

@ -1,35 +0,0 @@
project('gobject-introspection', 'c')
glib = dependency('glib-2.0')
gobj = dependency('gobject-2.0')
gir = dependency('gobject-introspection-1.0')
gmod = dependency('gmodule-2.0')
girscan = find_program('g-ir-scanner')
girc = find_program('g-ir-compiler')
libsources = ['golib.c', 'golib.h']
exe = executable('goprog', libsources, 'prog.c',
dependencies : [glib, gobj, gir, gmod])
test('gobjtest', exe)
# Let's create Gir data with custom targets to prove that
# Meson's syntax is expressive enough.
r = run_command('pkg-config', '--cflags', 'gobject-introspection-1.0')
custom_gir_args = r.stdout().strip().split()
golibgir = custom_target('golibgir',
output : 'Meson-1.0.gir',
input : libsources,
command : [girscan, '@INPUT@', '--program', exe, custom_gir_args, '--include=GObject-2.0',
'--namespace=Meson', '--nsversion=1.0', '--output', '@OUTPUT@'],
)
custom_target('golibtypelib',
output : 'Meson-1.0.typelib',
command : [girc, golibgir,'--output', '@OUTPUT@'],
install : true,
install_dir : 'typelibdir'
)

@ -0,0 +1,31 @@
project('gobject-introspection', 'c')
gnome = import('gnome')
gio = dependency('gio-2.0')
glib = dependency('glib-2.0')
gobj = dependency('gobject-2.0')
gir = dependency('gobject-introspection-1.0')
gmod = dependency('gmodule-2.0')
myres = gnome.compile_resources('myresources', 'myresource.gresource.xml',
source_dir : 'data',
c_name : 'myres')
resexe = executable('resprog', 'main.c', myres,
dependencies : gio)
test('resource test', resexe)
libsources = ['golib.c', 'golib.h']
girexe = executable('girprog', libsources, 'prog.c',
dependencies : [glib, gobj, gir, gmod])
gnome.generate_gir(girexe,
sources : libsources,
nsversion : '1.0',
namespace : 'Meson',
install : true,
install_dir : 'typelibdir',
)
test('gobject introspection', girexe)
Loading…
Cancel
Save