Subject: [PATCH 14/52] gnu: gobject-introspection: Don't build introspection data when cross-compiling.

From: Maxime Devos <[email-masked]>
Date: Wed, 25 Aug 2021 20:02:54 +0200

* gnu/packages/glib.scm
  (gobject-introspection)[arguments]<#:configure-flags>: Set
  gi_cross_use_prebuilt_gi to 'true'.
  (gobject-introspection)[arguments]<#:phases>{set-typelibs}: New phase,
  avoid undefined variable in "meson.build".
---
 gnu/packages/glib.scm | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index fc1c5eb271..060122f42b 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -398,8 +398,28 @@ functions for strings and common data structures.")
                        "gobject-introspection-absolute-shlib-path.patch"))))
     (build-system meson-build-system)
     (arguments
-     `(#:phases
+     `(,@(if (%current-target-system)
+             `(#:configure-flags
+               '("-Dgi_cross_use_prebuilt_gi=true"
+                 ;; Building introspection data requires running binaries
+                 ;; for ‘host’ on ‘build’, so don't do that.
+                 ;;
+                 ;; TODO: it would be nice to have introspection data anyways.
+                 ;; Would copying the introspection data from a native
+                 ;; 'gobject-introspection' work, or is introspection data
+                 ;; architecture-dependent?
+                 "-Dbuild_introspection_data=false"))
+             '())
+       #:phases
        (modify-phases %standard-phases
+         ,@(if (%current-target-system)
+               ;; 'typelibs' is undefined.
+               `((add-after 'unpack 'set-typelibs
+                   (lambda _
+                     (substitute* "meson.build"
+                       (("\\bsources: typelibs\\b")
+                        "sources: []")))))
+               '())
          (add-after 'unpack 'do-not-use-/usr/bin/env
            (lambda _
              (substitute* "tools/g-ir-tool-template.in"
-- 
2.33.0