gnome: Fix glib tool lookup consistency

It was not always using the pkg-config file.
pull/10855/head
Xavier Claessens 2 years ago committed by Xavier Claessens
parent b2654b2d43
commit c663476075
  1. 44
      mesonbuild/modules/gnome.py

@ -203,6 +203,8 @@ if T.TYPE_CHECKING:
vtail: T.Optional[str]
depends: T.List[T.Union[BuildTarget, CustomTarget, CustomTargetIndex]]
ToolType = T.Union[Executable, ExternalProgram, OverrideProgram]
# Differs from the CustomTarget version in that it straight defaults to True
_BUILD_BY_DEFAULT: KwargInfo[bool] = KwargInfo(
@ -317,6 +319,22 @@ class GnomeModule(ExtensionModule):
mlog.bold('https://github.com/mesonbuild/meson/issues/1387'),
once=True, fatal=False)
@staticmethod
def _find_tool(state: 'ModuleState', tool: str) -> 'ToolType':
tool_map = {
'gio-querymodules': 'gio-2.0',
'glib-compile-schemas': 'gio-2.0',
'glib-compile-resources': 'gio-2.0',
'gdbus-codegen': 'gio-2.0',
'glib-genmarshal': 'glib-2.0',
'glib-mkenums': 'glib-2.0',
'g-ir-scanner': 'gobject-introspection-1.0',
'g-ir-compiler': 'gobject-introspection-1.0',
}
depname = tool_map[tool]
varname = tool.replace('-', '_')
return state.find_tool(tool, depname, varname)
@typed_kwargs(
'gnome.post_install',
KwargInfo('glib_compile_schemas', bool, default=False),
@ -332,7 +350,7 @@ class GnomeModule(ExtensionModule):
datadir_abs = os.path.join(state.environment.get_prefix(), state.environment.get_datadir())
if kwargs['glib_compile_schemas'] and not self.install_glib_compile_schemas:
self.install_glib_compile_schemas = True
prog = state.find_tool('glib-compile-schemas', 'gio-2.0', 'glib_compile_schemas')
prog = self._find_tool(state, 'glib-compile-schemas')
schemasdir = os.path.join(datadir_abs, 'glib-2.0', 'schemas')
script = state.backend.get_executable_serialisation([prog, schemasdir])
script.skip_if_destdir = True
@ -340,7 +358,7 @@ class GnomeModule(ExtensionModule):
for d in kwargs['gio_querymodules']:
if d not in self.install_gio_querymodules:
self.install_gio_querymodules.append(d)
prog = state.find_tool('gio-querymodules', 'gio-2.0', 'gio_querymodules')
prog = self._find_tool(state, 'gio-querymodules')
moduledir = os.path.join(state.environment.get_prefix(), d)
script = state.backend.get_executable_serialisation([prog, moduledir])
script.skip_if_destdir = True
@ -390,8 +408,8 @@ class GnomeModule(ExtensionModule):
self.__print_gresources_warning(state)
glib_version = self._get_native_glib_version(state)
glib_compile_resources = state.find_program('glib-compile-resources')
cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [glib_compile_resources, '@INPUT@']
glib_compile_resources = self._find_tool(state, 'glib-compile-resources')
cmd: T.List[T.Union['ToolType', str]] = [glib_compile_resources, '@INPUT@']
source_dirs = kwargs['source_dir']
dependencies = kwargs['dependencies']
@ -481,7 +499,7 @@ class GnomeModule(ExtensionModule):
raise MesonException('GResource header is installed yet export is not enabled')
depfile: T.Optional[str] = None
target_cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]]
target_cmd: T.List[T.Union['ToolType', str]]
if not mesonlib.version_compare(glib_version, gresource_dep_needed_version):
# This will eventually go out of sync if dependencies are added
target_cmd = cmd
@ -780,8 +798,8 @@ class GnomeModule(ExtensionModule):
T.Union[Executable, 'ExternalProgram', 'OverrideProgram']]:
if not self.gir_dep:
self.gir_dep = state.dependency('gobject-introspection-1.0')
self.giscanner = state.find_tool('g-ir-scanner', 'gobject-introspection-1.0', 'g_ir_scanner')
self.gicompiler = state.find_tool('g-ir-compiler', 'gobject-introspection-1.0', 'g_ir_compiler')
self.giscanner = self._find_tool(state, 'g-ir-scanner')
self.gicompiler = self._find_tool(state, 'g-ir-compiler')
return self.gir_dep, self.giscanner, self.gicompiler
@functools.lru_cache(maxsize=None)
@ -1230,7 +1248,7 @@ class GnomeModule(ExtensionModule):
srcdir = os.path.join(state.build_to_src, state.subdir)
outdir = state.subdir
cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program('glib-compile-schemas'), '--targetdir', outdir, srcdir]
cmd: T.List[T.Union['ToolType', str]] = [self._find_tool(state, 'glib-compile-schemas'), '--targetdir', outdir, srcdir]
if state.subdir == '':
targetname = 'gsettings-compile'
else:
@ -1602,7 +1620,7 @@ class GnomeModule(ExtensionModule):
kwargs: 'GdbusCodegen') -> ModuleReturnValue:
namebase = args[0]
xml_files: T.List[T.Union['FileOrString', build.GeneratedTypes]] = [args[1]] if args[1] else []
cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program('gdbus-codegen')]
cmd: T.List[T.Union['ToolType', str]] = [self._find_tool(state, 'gdbus-codegen')]
cmd.extend(kwargs['extra_args'])
# Autocleanup supported?
@ -1912,8 +1930,8 @@ class GnomeModule(ExtensionModule):
return ModuleReturnValue([c_file, h_file], [c_file, h_file])
@staticmethod
def _make_mkenum_impl(
self,
state: 'ModuleState',
sources: T.Sequence[T.Union[str, mesonlib.File, CustomTarget, CustomTargetIndex, GeneratedList]],
output: str,
@ -1922,8 +1940,8 @@ class GnomeModule(ExtensionModule):
install: bool = False,
install_dir: T.Optional[T.Sequence[T.Union[str, bool]]] = None,
depends: T.Optional[T.Sequence[T.Union[CustomTarget, CustomTargetIndex, BuildTarget]]] = None
) -> CustomTarget:
real_cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program(['glib-mkenums', 'mkenums'])]
) -> build.CustomTarget:
real_cmd: T.List[T.Union[str, 'ToolType']] = [self._find_tool(state, 'glib-mkenums')]
real_cmd.extend(cmd)
_install_dir = install_dir or state.environment.coredata.get_option(mesonlib.OptionKey('includedir'))
assert isinstance(_install_dir, str), 'for mypy'
@ -1968,7 +1986,7 @@ class GnomeModule(ExtensionModule):
new_genmarshal = mesonlib.version_compare(self._get_native_glib_version(state), '>= 2.53.3')
cmd: T.List[T.Union[ExternalProgram, Executable, OverrideProgram, str]] = [state.find_program('glib-genmarshal')]
cmd: T.List[T.Union['ToolType', str]] = [self._find_tool(state, 'glib-genmarshal')]
if kwargs['prefix']:
cmd.extend(['--prefix', kwargs['prefix']])
if kwargs['extra_args']:

Loading…
Cancel
Save