gnome: Use g-ir-scanner --extra-library option when avalaible

When generating the .gir file we need g-ir-scanner to link the
introspector binary against the right dependencies, for that
we used to use the --library option but this has a special meaning
and the libs passed in there end up being the ones in the .gir file
itself, which is not what we want.

A new --extra-library option is beeing added in goject-introspection
(https://bugzilla.gnome.org/show_bug.cgi?id=774625) to handle our use case
(ie. not using libtool which allows g-ir-scanner to know about those)
and we should make use of it.

Closes #981
pull/1136/head
Thibault Saunier 8 years ago committed by Jussi Pakkanen
parent 8e8f75005d
commit 9c0997dafd
  1. 24
      mesonbuild/modules/gnome.py

@ -36,6 +36,20 @@ gresource_dep_needed_version = '>= 2.52.0'
native_glib_version = None
girwarning_printed = False
gresource_warning_printed = False
_gir_has_extra_lib_arg = None
def gir_has_extra_lib_arg():
global _gir_has_extra_lib_arg
if _gir_has_extra_lib_arg is not None:
return _gir_has_extra_lib_arg
_gir_has_extra_lib_arg = False
try:
scanner_options = subprocess.check_output(['g-ir-scanner', '--help']).decode()
_gir_has_extra_lib_arg = '--extra-library' in scanner_options
except (FileNotFound, subprocess.CalledProcessError):
pass
return _gir_has_extra_lib_arg
def find_program(program_name, target_name):
program = dependencies.ExternalProgram(program_name)
@ -241,9 +255,13 @@ can not be used with the current version of glib-compiled-resources, due to
return dep_files, depends, subdirs
@staticmethod
def _get_link_args(state, lib, depends=None):
def _get_link_args(self, state, lib, depends=None):
if gir_has_extra_lib_arg():
link_command = ['--extra-library=%s' % lib.name]
else:
link_command = ['-l%s' % lib.name]
print('lib: %s - %s' % (lib.name, link_command))
if isinstance(lib, build.SharedLibrary):
link_command += ['-L%s' %
os.path.join(state.environment.get_build_dir(),
@ -323,6 +341,8 @@ can not be used with the current version of glib-compiled-resources, due to
# Hack to avoid passing some compiler options in
if lib.startswith("-W"):
continue
if gir_has_extra_lib_arg():
lib = lib.replace('-l', '--extra-library=')
ldflags.update([lib])
if isinstance(dep, dependencies.PkgConfigDependency):

Loading…
Cancel
Save