[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
16/52: gobject-introspection: Correct library name when cross-compiling.
From: |
guix-commits |
Subject: |
16/52: gobject-introspection: Correct library name when cross-compiling. |
Date: |
Mon, 20 Sep 2021 07:19:30 -0400 (EDT) |
mothacehe pushed a commit to branch core-updates-frozen
in repository guix.
commit 838dcb7c2b162532df71d1fec1dacb73042ce131
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Aug 24 13:10:21 2021 +0200
gobject-introspection: Correct library name when cross-compiling.
* gnu/packages/glib.scm
(python-extension-suffix, correct-library-name-phase): New procedures.
(gobject-introspection)[arguments]<#:phases>{rename-library}:
New phase, correct the name of the python extension when cross-compiling.
---
gnu/packages/glib.scm | 65 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 56 insertions(+), 9 deletions(-)
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index f2606a7..fd57041 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -393,6 +393,42 @@ functions for strings and common data structures.")
(string-append doc html))
#t)))))))))
+(define (python-extension-suffix python triplet)
+ "Determine the suffix for C extensions for PYTHON when compiled
+for TRIPLET."
+ ;; python uses strings like 'x86_64-linux-gnu' instead of
+ ;; 'x86_64-unknown-linux-gnu'.
+ (define normalised-system
+ (string-replace-substring triplet "-unknown-" "-"))
+ (define major.minor (version-major+minor (package-version python)))
+ (define majorminor (string-delete #\. major.minor))
+ (string-append
+ ;; If guix' python package used "--with-pydebug", a #\d would
+ ;; need to be added, likewise "--with-pymalloc" and "--with-wide-unicode"
+ ;; would require a #\m and #\u, see cpython's configure.ac.
+ ".cpython-" majorminor "-" normalised-system
+ (if (target-mingw? triplet)
+ ".dll"
+ ".so")))
+
+(define (correct-library-name-phase python name)
+ "Return a G-exp evaluating to a phase renaming the python extension NAME
+from what Meson thinks its name should be to what python expects its name
+to be. NAME must not include the platform-specific suffix. This can only
+be used when cross-compiling."
+ #~(lambda _
+ (define name #$name)
+ (define native-suffix
+ #$(python-extension-suffix python
+ (nix-system->gnu-triplet
(%current-system))))
+ (define target-suffix
+ #$(python-extension-suffix python (%current-target-system)))
+ (define native-name
+ (string-append name native-suffix))
+ (define target-name
+ (string-append name target-suffix))
+ (rename-file native-name target-name)))
+
(define gobject-introspection
(package
(name "gobject-introspection")
@@ -421,21 +457,32 @@ functions for strings and common data structures.")
"-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: []")))))
- '())
+ #$@(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"
(("#!@PYTHON_CMD@")
(string-append "#!" (which "python3"))))
- #t)))))
+ #t))
+ #$@(if (%current-target-system)
+ ;; Meson gives python extensions an incorrect name, see
+ ;; <https://github.com/mesonbuild/meson/issues/7049>.
+ #~((add-after 'install 'rename-library
+ #$(correct-library-name-phase
+ (this-package-input "python")
+ #~(string-append #$output
+
"/lib/gobject-introspection/giscanner"
+ "/_giscanner"))))
+ #~()))))
(native-inputs
`(("glib" ,glib "bin")
("pkg-config" ,pkg-config)
- 01/52: gnu: dbus-glib: Support cross-compilation., (continued)
- 01/52: gnu: dbus-glib: Support cross-compilation., guix-commits, 2021/09/20
- 07/52: gnu: nspr: Don't retain references to native inputs., guix-commits, 2021/09/20
- 11/52: build-system/glib-or-gtk: Support cross-compilaton., guix-commits, 2021/09/20
- 23/52: gnu: heimdal: Fix inputs when cross-compiling., guix-commits, 2021/09/20
- 24/52: gnu: heimdal: Fix linking error when cross-compiling., guix-commits, 2021/09/20
- 12/52: gnu: dbus-cairo: Add missing bash-minimal input., guix-commits, 2021/09/20
- 18/52: gnu: bdb: Fix cross-compilation build errors., guix-commits, 2021/09/20
- 06/52: gnu: nspr: Adjust to Mozilla cross-compilation conventions., guix-commits, 2021/09/20
- 13/52: gnu: polkit: Prevent cross-compilation build error., guix-commits, 2021/09/20
- 17/52: gnu: atk: Disable introspection when cross-compiling., guix-commits, 2021/09/20
- 16/52: gobject-introspection: Correct library name when cross-compiling.,
guix-commits <=
- 34/52: gnu: libdaemon: Support cross-compilation to aarch64-linux-gnu., guix-commits, 2021/09/20
- 35/52: gnu: avahi: Find 'TARGET-pkg-config' when cross-compiling., guix-commits, 2021/09/20
- 28/52: gnu: heimdal: Use libcom_err from input when cross-compiling., guix-commits, 2021/09/20
- 21/52: gnu: gamin: Fix 'configure' script when cross-compiling., guix-commits, 2021/09/20
- 09/52: gnu: poppler: Find pkg-config when cross-compiling., guix-commits, 2021/09/20
- 19/52: gnu: graphene: Don't build introspection data when cross-compiling., guix-commits, 2021/09/20
- 25/52: gnu: heimdal: Refer to cross-compiled bash., guix-commits, 2021/09/20
- 15/52: gobject-introspection: Fix inputs when cross-compiling., guix-commits, 2021/09/20
- 27/52: gnu: heimdal: Find tools when cross-compiling., guix-commits, 2021/09/20
- 32/52: gnu: json-glib: Don't build introspection data when cross-compiling., guix-commits, 2021/09/20