From c3f426cd21998aa61eda43e60cb8d458992f14de Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 24 Mar 2015 16:33:21 +0300 Subject: [PATCH 1/4] modules/gnome: allow argument for gir to be SharedLibrary. Closes #76 Signed-off-by: Igor Gnatenko --- modules/gnome.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/gnome.py b/modules/gnome.py index 539ed273c..80fef7c7f 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -47,16 +47,15 @@ class GnomeModule: 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') + if not (isinstance(girtarget, build.Executable) or isinstance(girtarget, build.SharedLibrary)): + raise MesonException('Gir target must be an executable or shared library') 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 = ['g-ir-scanner', '@INPUT@'] scan_command += pkgargs scan_command += ['--namespace='+ns, '--nsversion=' + nsversion, '--output', '@OUTPUT@'] @@ -72,15 +71,18 @@ class GnomeModule: scan_command += ['--cflags-begin'] scan_command += state.global_args['c'] scan_command += ['--cflags-end'] + if isinstance(girtarget, build.Executable): + scan_command += ['--program', girtarget] + elif isinstance(girtarget, build.SharedLibrary): + scan_command += ['--library', girtarget.get_basename()] scankwargs = {'output' : girfile, 'input' : libsources, 'command' : scan_command} if kwargs.get('install'): scankwargs['install'] = kwargs['install'] scankwargs['install_dir'] = os.path.join(state.environment.get_datadir(), 'gir-1.0') - scan_target = GirTarget(scan_name, state.subdir, scankwargs) + scan_target = GirTarget(girfile, 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 @@ -88,7 +90,7 @@ class GnomeModule: # Note that this can't be libdir, because e.g. on Debian it points to # lib/x86_64-linux-gnu but the girepo dir is always under lib. kwargs['install_dir'] = 'lib/girepository-1.0' - typelib_target = TypelibTarget(typelib_name, state.subdir, kwargs) + typelib_target = TypelibTarget(typelib_output, state.subdir, kwargs) return [scan_target, typelib_target] def compile_schemas(self, state, args, kwargs): From 92d32c45a77eb9b7e8002c2929cd1db7272dea73 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 25 Mar 2015 13:43:50 +0300 Subject: [PATCH 2/4] modules/gnome: enable warnings for g-ir-scanner without warnings - scanner not useful for developer Signed-off-by: Igor Gnatenko --- modules/gnome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gnome.py b/modules/gnome.py index 80fef7c7f..11c1cc3f9 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -57,7 +57,7 @@ class GnomeModule: girfile = '%s-%s.gir' % (ns, nsversion) scan_command = ['g-ir-scanner', '@INPUT@'] scan_command += pkgargs - scan_command += ['--namespace='+ns, '--nsversion=' + nsversion, + scan_command += ['--namespace='+ns, '--nsversion=' + nsversion, '--warn-all', '--output', '@OUTPUT@'] if 'includes' in kwargs: includes = kwargs.pop('includes') From 2db5f974026b619cea93e34900dfbff9ead5b2e0 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 25 Mar 2015 13:44:57 +0300 Subject: [PATCH 3/4] modules/gnome: add symbol_prefix kwarg to g-ir-scanner Signed-off-by: Igor Gnatenko --- modules/gnome.py | 10 ++++++++++ test cases/frameworks/7 gnome/gir/meson.build | 1 + 2 files changed, 11 insertions(+) diff --git a/modules/gnome.py b/modules/gnome.py index 11c1cc3f9..b90c109e1 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -71,6 +71,16 @@ class GnomeModule: scan_command += ['--cflags-begin'] scan_command += state.global_args['c'] scan_command += ['--cflags-end'] + if kwargs.get('symbol_prefix'): + sym_prefix = kwargs.pop('symbol_prefix') + if not isinstance(sym_prefix, str): + raise MesonException('Gir symbol prefix must be str') + scan_command += ['--symbol-prefix=%s' % sym_prefix] + if kwargs.get('identifier_prefix'): + identifier_prefix = kwargs.pop('identifier_prefix') + if not isinstance(identifier_prefix, str): + raise MesonException('Gir identifier prefix must be str') + scan_command += ['--identifier-prefix=%s' % identifier_prefix] if isinstance(girtarget, build.Executable): scan_command += ['--program', girtarget] elif isinstance(girtarget, build.SharedLibrary): diff --git a/test cases/frameworks/7 gnome/gir/meson.build b/test cases/frameworks/7 gnome/gir/meson.build index f4b118d29..58fc9fdd9 100644 --- a/test cases/frameworks/7 gnome/gir/meson.build +++ b/test cases/frameworks/7 gnome/gir/meson.build @@ -8,6 +8,7 @@ gnome.generate_gir(girexe, sources : libsources, nsversion : '1.0', namespace : 'Meson', +symbol_prefix : 'meson_', includes : ['GObject-2.0', 'Gio-2.0'], install : true ) From d121b7cd55560829f26a082826a990ca0e38847e Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 25 Mar 2015 13:45:38 +0300 Subject: [PATCH 4/4] modules/gnome: add export_packages kwarg to g-ir-scanner Signed-off-by: Igor Gnatenko --- modules/gnome.py | 8 ++++++++ test cases/frameworks/7 gnome/gir/meson.build | 1 + 2 files changed, 9 insertions(+) diff --git a/modules/gnome.py b/modules/gnome.py index b90c109e1..458221e21 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -81,6 +81,14 @@ class GnomeModule: if not isinstance(identifier_prefix, str): raise MesonException('Gir identifier prefix must be str') scan_command += ['--identifier-prefix=%s' % identifier_prefix] + if kwargs.get('export_packages'): + pkgs = kwargs.pop('export_packages') + if isinstance(pkgs, str): + scan_command += ['--pkg-export=%s' % pkgs] + elif isinstance(pkgs, list): + scan_command += ['--pkg-export=%s' % pkg for pkg in pkgs] + else: + raise MesonException('Gir export packages must be str or list') if isinstance(girtarget, build.Executable): scan_command += ['--program', girtarget] elif isinstance(girtarget, build.SharedLibrary): diff --git a/test cases/frameworks/7 gnome/gir/meson.build b/test cases/frameworks/7 gnome/gir/meson.build index 58fc9fdd9..dcc0ad851 100644 --- a/test cases/frameworks/7 gnome/gir/meson.build +++ b/test cases/frameworks/7 gnome/gir/meson.build @@ -9,6 +9,7 @@ sources : libsources, nsversion : '1.0', namespace : 'Meson', symbol_prefix : 'meson_', +identifier_prefix : 'Meson', includes : ['GObject-2.0', 'Gio-2.0'], install : true )