[glib/wip/smcv/multiarch-triggers] gio: Optionally install trigger executables to architecture-specific paths




commit f606321e47c6847e768b6bf1e2392523c5a0414c
Author: Simon McVittie <smcv collabora com>
Date:   Thu Jul 14 14:24:33 2022 +0100

    gio: Optionally install trigger executables to architecture-specific paths
    
    In Debian-style multiarch (libdir = lib/x86_64-linux-gnu or similar),
    Red-Hat-style multilib (libdir = lib64 or lib) and Arch-style multilib
    (libdir = lib or lib32), we have to run a separate version of
    gio-querymodules to discover 32- or 64-bit modules on x86. Installing
    modules in the directory used for each word size needs to trigger
    recompilation of the correct modules list.
    
    Debian, Fedora and Arch currently all have patches to facilitate this:
    Debian moves gio-querymodules into ${libdir}/glib-2.0 and provides a
    compat symlink in ${bindir}, while Fedora and Arch rename one or both
    of the gio-querymodules executables to give it a -32 or -64 suffix.
    
    We can avoid the need for these patches by making this a build option.
    Doing this upstream has the advantage that the pkg-config metadata for
    each architecture points to the correct executable and is in sync with
    reality.
    
    I'm using Debian's installation scheme with a separate directory here,
    because the word-size suffix used in Fedora and Arch only works for the
    common case of 32- and 64-bit multilib, and does not cover scenarios
    where there can be more than one ABI with the same word size, such as
    multiarch cross-compilation or alternative ABIs like x32.
    
    Now that we have this infrastructure, it's also convenient to use it for
    glib-compile-schemas. This works with /usr/share, so it only needs to
    be run for one architecture (typically the system's primary
    architecture), but using /usr/bin/glib-compile-schemas for the trigger
    would result in either primary and secondary architectures trying to
    overwrite each other's /usr/bin/glib-compile-schemas binaries, or a
    circular dependency (the GLib library would have to depend on a
    common package that contains glib-compile-schemas, but
    glib-compile-schemas depends on the GLib library). Installing a
    glib-compile-schemas binary in an architecture-specific location
    alongside each GLib library bypasses this problem.
    
    Signed-off-by: Simon McVittie <smcv collabora com>

 gio/meson.build   | 18 ++++++++++++++++--
 meson.build       |  7 +++++++
 meson_options.txt |  5 +++++
 3 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/gio/meson.build b/gio/meson.build
index ca969309a4..5a5238596b 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -846,8 +846,8 @@ pkg.generate(libgio,
                'bindir=' + join_paths('${prefix}', get_option('bindir')),
                'giomoduledir=' + pkgconfig_giomodulesdir,
                'gio=' + join_paths('${bindir}', 'gio'),
-               'gio_querymodules=' + join_paths('${bindir}', 'gio-querymodules'),
-               'glib_compile_schemas=' + join_paths('${bindir}', 'glib-compile-schemas'),
+               'gio_querymodules=' + join_paths(pkgconfig_multiarch_bindir, 'gio-querymodules'),
+               'glib_compile_schemas=' + join_paths(pkgconfig_multiarch_bindir, 'glib-compile-schemas'),
                'glib_compile_resources=' + join_paths('${bindir}', 'glib-compile-resources'),
                'gdbus=' + join_paths('${bindir}', 'gdbus'),
                'gdbus_codegen=' + join_paths('${bindir}', 'gdbus-codegen'),
@@ -958,6 +958,7 @@ executable('gresource', 'gresource-tool.c',
 
 gio_querymodules = executable('gio-querymodules', 'gio-querymodules.c', 'giomodule-priv.c',
   install : true,
+  install_dir : multiarch_bindir,
   c_args : gio_c_args,
   # intl.lib is not compatible with SAFESEH
   link_args : noseh_link_args,
@@ -966,10 +967,23 @@ gio_querymodules = executable('gio-querymodules', 'gio-querymodules.c', 'giomodu
 glib_compile_schemas = executable('glib-compile-schemas',
   ['glib-compile-schemas.c'],
   install : true,
+  install_dir : multiarch_bindir,
   # intl.lib is not compatible with SAFESEH
   link_args : noseh_link_args,
   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep, gvdb_dep])
 
+if multiarch_bindir != get_option('bindir')
+  if meson.version().version_compare('>=0.61.0')
+    foreach exe : ['gio-querymodules', 'glib-compile-schemas']
+      install_symlink(
+        exe,
+        install_dir : get_option('bindir'),
+        pointing_to : get_option('prefix') / multiarch_bindir / exe,
+      )
+    endforeach
+  endif
+endif
+
 glib_compile_resources = executable('glib-compile-resources',
   [gconstructor_as_data_h, 'glib-compile-resources.c'],
   install : true,
diff --git a/meson.build b/meson.build
index b3dea2ea19..1b4eff3709 100644
--- a/meson.build
+++ b/meson.build
@@ -78,6 +78,13 @@ if get_option('gio_module_dir') != ''
 else
   glib_giomodulesdir = join_paths(glib_libdir, 'gio', 'modules')
 endif
+if get_option('multiarch')
+  multiarch_bindir = get_option('libdir') / 'glib-2.0'
+  pkgconfig_multiarch_bindir = '${libdir}/glib-2.0'
+else
+  multiarch_bindir = get_option('bindir')
+  pkgconfig_multiarch_bindir = '${bindir}'
+endif
 
 glib_pkgconfigreldir = join_paths(glib_libdir, 'pkgconfig')
 
diff --git a/meson_options.txt b/meson_options.txt
index a52eed9d26..f13cbfdd51 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -117,3 +117,8 @@ option('libelf',
        type : 'feature',
        value : 'auto',
        description : 'Enable support for listing and extracting from ELF resource files with gresource tool')
+
+option('multiarch',
+       type : 'boolean',
+       value : false,
+       description : 'Install some helper executables in per-architecture locations')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]