Skip to content

Commit 62dd804

Browse files
sp1ritCSjpakkane
authored andcommitted
gnome: generate_gir: Rely on dependency if scanner is from subproject
The gobject-introspection subproject just registers g-ir-scanner as a python script, with meson unaware of the native module the script depends upon that has to be built first. This patch works around this issue by adding an the gobject-introspection-1.0 dependency (which indirectly depends on the native module) if g-ir-scanner was overriden by the g-i subproject.
1 parent 9d1ae97 commit 62dd804

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

mesonbuild/modules/gnome.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ class GnomeModule(ExtensionModule):
255255
def __init__(self, interpreter: 'Interpreter') -> None:
256256
super().__init__(interpreter)
257257
self.giscanner: T.Optional[ToolType] = None
258+
self.giscanner_extra: T.List[Dependency] = []
258259
self.gicompiler: T.Optional[ToolType] = None
259260
self.install_glib_compile_schemas = False
260261
self.install_gio_querymodules: T.List[str] = []
@@ -787,18 +788,26 @@ def postconf_hook(self, b: build.Build) -> None:
787788
if self.devenv is not None:
788789
b.devenv.append(self.devenv)
789790

790-
def _get_gi(self, state: 'ModuleState') -> T.Tuple[ToolType, ToolType]:
791+
def _get_gi(self, state: 'ModuleState') -> T.Tuple[ToolType, T.List[Dependency], ToolType]:
791792
if not self.giscanner:
792-
self.giscanner = self._find_tool(state, 'g-ir-scanner', for_machine=MachineChoice.BUILD)
793+
self.giscanner = self._find_tool(state, 'g-ir-scanner')
794+
if isinstance(self.giscanner, OverrideProgram):
795+
# The gobject-introspection subproject just registers g-ir-scanner
796+
# as a python script, with meson unaware of the native module the
797+
# script depends upton that has to be built first. If g-i was
798+
# configured with the right option, the gobject-introspection-1.0
799+
# dependency itself indirectly depends on the native module; so if
800+
# g-ir-scanner originates from a subproject, also add the g-i dep.
801+
self.giscanner_extra.append(state.dependency('gobject-introspection-1.0'))
793802
self.gicompiler = self._find_tool(state, 'g-ir-compiler', for_machine=MachineChoice.HOST)
794-
return self.giscanner, self.gicompiler
803+
return self.giscanner, self.giscanner_extra, self.gicompiler
795804

796805
def _giscanner_version_compare(self, state: 'ModuleState', cmp: str) -> bool:
797806
# Support for --version was introduced in g-i 1.58, but Ubuntu
798807
# Bionic shipped 1.56.1. As all our version checks are greater
799808
# than 1.58, we can just return False if get_version fails.
800809
try:
801-
giscanner, _ = self._get_gi(state)
810+
giscanner, _, _ = self._get_gi(state)
802811
return mesonlib.version_compare(giscanner.get_version(), cmp)
803812
except MesonException:
804813
return False
@@ -994,7 +1003,7 @@ def _make_gir_target(
9941003
run_env.set('CFLAGS', [quote_arg(x) for x in env_flags], ' ')
9951004
run_env.merge(kwargs['env'])
9961005

997-
giscanner, _ = self._get_gi(state)
1006+
giscanner, _, _ = self._get_gi(state)
9981007

9991008
# response file supported?
10001009
rspable = self._giscanner_version_compare(state, '>= 1.85.0')
@@ -1149,7 +1158,7 @@ def generate_gir(self, state: 'ModuleState', args: T.Tuple[T.List[T.Union[Execut
11491158
if len(girtargets) > 1 and any(isinstance(el, Executable) for el in girtargets):
11501159
raise MesonException('generate_gir only accepts a single argument when one of the arguments is an executable')
11511160

1152-
giscanner, gicompiler = self._get_gi(state)
1161+
giscanner, giscanner_extra, gicompiler = self._get_gi(state)
11531162

11541163
ns = kwargs['namespace']
11551164
nsversion = kwargs['nsversion']
@@ -1160,12 +1169,15 @@ def generate_gir(self, state: 'ModuleState', args: T.Tuple[T.List[T.Union[Execut
11601169
builddir = os.path.join(state.environment.get_build_dir(), state.subdir)
11611170

11621171
depends: T.List[T.Union['FileOrString', 'build.GeneratedTypes', build.BuildTarget, build.StructuredSources]] = []
1172+
for extra in giscanner_extra:
1173+
depends.extend(extra.sources)
11631174
depends.extend(girtargets)
11641175

11651176
langs_compilers = self._get_girtargets_langs_compilers(girtargets)
11661177
cflags, internal_ldflags, external_ldflags = self._get_langs_compilers_flags(state, langs_compilers)
11671178
deps = self._get_gir_targets_deps(girtargets)
11681179
deps += kwargs['dependencies']
1180+
deps += giscanner_extra # probably not necessary
11691181
deps += [state.dependency('glib-2.0'), state.dependency('gobject-2.0'), state.dependency('gmodule-2.0'), state.dependency('gio-2.0')]
11701182
typelib_includes, depends = self._gather_typelib_includes_and_update_depends(state, deps, depends)
11711183
# ldflags will be misinterpreted by gir scanner (showing

0 commit comments

Comments
 (0)