Skip to content

Commit

Permalink
WIP: gobject-introspection cross with pkg-config
Browse files Browse the repository at this point in the history
gobject-introspection is infamous for being difficult to get working
with cross compilation. But the situation has improved recently with
https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/64,
thanks to @kanavin from the Yocto project. The upshot is now only
*some*, not all, of the executables need to be run on the host platform
with the exe wrapper.

On the meson side, there have been two attempts to fix things for cross:

- https://github.com/mesonbuild/meson/pull/2965from @kanavin and the
Yocto projejct, which because it predates
mesonbuild#4010 had to be somewhat hacky

- mesonbuild#7072 recently merged which
allows specifying some binaries with a cross file.

But, I think we can make a more seamless user interface that won't
require extra config, like for native builds. gobject-introspection
provides the binaries in its pkg-config file, and Meson now cleanly
supports separate `native: true` and `native: false` pkg-config paths
and lookup.

We should just need to add separate `native: true` and `native: false`
deps, and I have done that, but I am not sure exactly which should be
used when. I am coming at this as a distro maintainer not even
particularly involved with gnome things and so I'll need some advice on
what to do next.
  • Loading branch information
Ericson2314 committed May 16, 2020
1 parent 3d41fa9 commit 8c3af43
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from . import ExtensionModule
from . import ModuleReturnValue
from ..mesonlib import (
MachineChoice, MesonException, OrderedSet, Popen_safe, extract_as_list,
join_args, unholder,
MachineChoice, MesonException, OrderedSet, Popen_safe, PerMachine,
extract_as_list, join_args, unholder,
)
from ..dependencies import Dependency, PkgConfigDependency, InternalDependency, ExternalProgram
from ..interpreterbase import noKwargs, permittedKwargs, FeatureNew, FeatureNewKwargs
Expand All @@ -45,7 +45,7 @@
native_glib_version = None

class GnomeModule(ExtensionModule):
gir_dep = None
gir_dep = PerMachine(None, None)

@staticmethod
def _get_native_glib_version(state):
Expand Down Expand Up @@ -401,26 +401,26 @@ def _unwrap_gir_target(self, girtarget, state):

return girtarget

def _get_gir_dep(self, state):
if not self.gir_dep:
kwargs = {'native': True, 'required': True}
def _get_gir_dep(self, state, for_machine: MachineChoice = MachineChoice.HOST):
if not self.gir_dep[for_machine]:
kwargs = {'native': True if for_machine == MachineChoice.BUILD else False, 'required': True}
holder = self.interpreter.func_dependency(state.current_node, ['gobject-introspection-1.0'], kwargs)
self.gir_dep = holder.held_object
giscanner = state.environment.lookup_binary_entry(MachineChoice.HOST, 'g-ir-scanner')
self.gir_dep[for_machine] = holder.held_object
giscanner = state.environment.lookup_binary_entry(for_machine, 'g-ir-scanner')
if giscanner is not None:
self.giscanner = ExternalProgram.from_entry('g-ir-scanner', giscanner)
elif self.gir_dep.type_name == 'pkgconfig':
elif self.gir_dep[for_machine].type_name == 'pkgconfig':
self.giscanner = ExternalProgram('g_ir_scanner', self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {}))
else:
self.giscanner = self.interpreter.find_program_impl('g-ir-scanner')
gicompiler = state.environment.lookup_binary_entry(MachineChoice.HOST, 'g-ir-compiler')
self.giscanner = self.interpreter.find_program_impl('g-ir-scanner', kwargs)
gicompiler = state.environment.lookup_binary_entry(for_machine, 'g-ir-compiler')
if gicompiler is not None:
self.gicompiler = ExternalProgram.from_entry('g-ir-compiler', gicompiler)
elif self.gir_dep.type_name == 'pkgconfig':
elif self.gir_dep[for_machine].type_name == 'pkgconfig':
self.gicompiler = ExternalProgram('g_ir_compiler', self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {}))
else:
self.gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
return self.gir_dep, self.giscanner, self.gicompiler
self.gicompiler = self.interpreter.find_program_impl('g-ir-compiler', kwargs)
return self.gir_dep[for_machine], self.giscanner, self.gicompiler

@functools.lru_cache(maxsize=None)
def _gir_has_option(self, option):
Expand Down

0 comments on commit 8c3af43

Please sign in to comment.