Merge pull request #77 from ignatenkobrain/wip/gnome
modules/gnome: make program name as optional argument. Closes #76
This commit is contained in:
commit
4e097ec702
|
@ -47,18 +47,17 @@ 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,
|
||||
scan_command += ['--namespace='+ns, '--nsversion=' + nsversion, '--warn-all',
|
||||
'--output', '@OUTPUT@']
|
||||
if 'includes' in kwargs:
|
||||
includes = kwargs.pop('includes')
|
||||
|
@ -72,15 +71,36 @@ 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 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):
|
||||
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 +108,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):
|
||||
|
|
|
@ -8,6 +8,8 @@ gnome.generate_gir(girexe,
|
|||
sources : libsources,
|
||||
nsversion : '1.0',
|
||||
namespace : 'Meson',
|
||||
symbol_prefix : 'meson_',
|
||||
identifier_prefix : 'Meson',
|
||||
includes : ['GObject-2.0', 'Gio-2.0'],
|
||||
install : true
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue