unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: 50201@debbugs.gnu.org
Cc: Maxime Devos <maximedevos@telenet.be>
Subject: [bug#50201] [PATCH 11/52] build-system/glib-or-gtk: Support cross-compilaton.
Date: Wed, 25 Aug 2021 20:02:51 +0200	[thread overview]
Message-ID: <20210825180332.5720-11-maximedevos@telenet.be> (raw)
In-Reply-To: <20210825180332.5720-1-maximedevos@telenet.be>

* guix/build-system/glib-or-gtk.scm
  (lower): Add 'implicit-cross-inputs?' argument.  Generate a bag
  when cross-compiling.
  (glib-or-gtk-cross-build): New procedure.
---
 guix/build-system/glib-or-gtk.scm | 146 ++++++++++++++++++++++++++----
 1 file changed, 127 insertions(+), 19 deletions(-)

diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm
index 2df49a2495..ec491ff0bd 100644
--- a/guix/build-system/glib-or-gtk.scm
+++ b/guix/build-system/glib-or-gtk.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
 ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -31,6 +32,7 @@
   #:use-module (ice-9 match)
   #:export (%glib-or-gtk-build-system-modules
             glib-or-gtk-build
+            glib-or-gtk-cross-build
             glib-or-gtk-build-system))
 
 ;; Commentary:
@@ -82,30 +84,42 @@
                 #:key source inputs native-inputs outputs system target
                 (glib (default-glib))
                 (implicit-inputs? #t)
+                (implicit-cross-inputs? #t)
                 (strip-binaries? #t)
                 #:allow-other-keys
                 #:rest arguments)
   "Return a bag for NAME."
   (define private-keywords
-    '(#:target #:glib #:inputs #:native-inputs
-      #:outputs #:implicit-inputs?))
-
-  (and (not target)                               ;XXX: no cross-compilation
-       (bag
-         (name name)
-         (system system)
-         (host-inputs (if source
-                          `(("source" ,source))
-                          '()))
-         (build-inputs `(,@native-inputs
-                         ,@inputs
-                         ("glib:bin" ,glib "bin") ; to compile schemas
-                         ,@(if implicit-inputs?
-                               (standard-packages)
-                               '())))
-         (outputs outputs)
-         (build glib-or-gtk-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+    `(#:glib #:inputs #:native-inputs
+      #:outputs #:implicit-inputs? #:implicit-cross-inputs?
+      ,@(if target '() '(#:target))))
+
+  (bag
+    (name name)
+    (system system) (target target)
+    (host-inputs `(,@(if source
+                         `(("source" ,source))
+                         '())
+                   ,@(if target
+                         inputs
+                         '())))
+    (build-inputs `(,@native-inputs
+                    ,@(if target '() inputs)
+                    ("glib:bin" ,glib "bin") ; to compile schemas
+                    ;; Keep standard inputs of gnu-build-system.
+                    ,@(if (and target implicit-cross-inputs?)
+                          (standard-cross-packages target 'host)
+                          '())
+                    ,@(if implicit-inputs?
+                          (standard-packages)
+                          '())))
+    ;; Keep standard inputs of 'gnu-build-system'.
+    (target-inputs (if (and target implicit-cross-inputs?)
+                       (standard-cross-packages target 'target)
+                       '()))
+    (outputs outputs)
+    (build (if target glib-or-gtk-cross-build glib-or-gtk-build))
+    (arguments (strip-keyword-arguments private-keywords arguments))))
 
 (define* (glib-or-gtk-build name inputs
                             #:key guile source
@@ -176,6 +190,100 @@
                       #:disallowed-references disallowed-references
                       #:guile-for-build guile)))
 
+(define* (glib-or-gtk-cross-build name
+                                  #:key
+                                  target
+                                  build-inputs target-inputs host-inputs
+                                  guile source
+                                  (outputs '("out"))
+                                  (search-paths '())
+                                  (native-search-paths '())
+                                  (configure-flags ''())
+                                  ;; Disable icon theme cache generation.
+                                  (make-flags ''("gtk_update_icon_cache=true"))
+                                  (out-of-source? #f)
+                                  (tests? #f)
+                                  (test-target "check")
+                                  (parallel-build? #t)
+                                  (parallel-tests? #t)
+                                  (validate-runpath? #t)
+                                  (make-dynamic-linker-cache? #f)
+                                  (patch-shebangs? #t)
+                                  (strip-binaries? #t)
+                                  (strip-flags ''("--strip-debug"))
+                                  (strip-directories ''("lib" "lib64" "libexec"
+                                                        "bin" "sbin"))
+                                  (phases '(@ (guix build glib-or-gtk-build-system)
+                                              %standard-phases))
+                                  (glib-or-gtk-wrap-excluded-outputs ''())
+                                  (system (%current-system))
+                                  (build (nix-system->gnu-triplet system))
+                                  (imported-modules %glib-or-gtk-build-system-modules)
+                                  (modules %default-modules)
+                                  allowed-references
+                                  disallowed-references)
+  "Cross-build SOURCE with INPUTS.  See GNU-BUILD for more details."
+  (define builder
+    #~(begin
+        (use-modules #$@(sexp->gexp modules))
+
+        (define %build-host-inputs
+          #+(input-tuples->gexp build-inputs))
+
+        (define %build-target-inputs
+          (append #$(input-tuples->gexp host-inputs)
+                  #+(input-tuples->gexp target-inputs)))
+
+        (define %build-inputs
+          (append %build-host-inputs %build-target-inputs))
+
+        (define %outputs
+          #$(outputs->gexp outputs))
+
+        (glib-or-gtk-build #:source #+source
+                           #:system #$system
+                           #:build #$build
+                           #:target #$target
+                           #:outputs %outputs
+                           #:inputs %build-target-inputs
+                           #:native-inputs %build-host-inputs
+                           #:search-paths '#$(sexp->gexp
+                                              (map search-path-specification->sexp
+                                                   search-paths))
+                           #:native-search-paths '#$(sexp->gexp
+                                                     (map search-path-specification->sexp
+                                                          native-search-paths))
+                           #:phases #$(if (pair? phases)
+                                          (sexp->gexp phases)
+                                          phases)
+                           #:glib-or-gtk-wrap-excluded-outputs
+                           #$glib-or-gtk-wrap-excluded-outputs
+                           #:configure-flags #$configure-flags
+                           #:make-flags #$make-flags
+                           #:out-of-source? #$out-of-source?
+                           #:tests? #$tests?
+                           #:test-target #$test-target
+                           #:parallel-build? #$parallel-build?
+                           #:parallel-tests? #$parallel-tests?
+                           #:validate-runpath? #$validate-runpath?
+                           #:make-dynamic-linker-cache? #$make-dynamic-linker-cache?
+                           #:patch-shebangs? #$patch-shebangs?
+                           #:strip-binaries? #$strip-binaries?
+                           #:strip-flags #$(sexp->gexp strip-flags)
+                           #:strip-directories
+                           #$(sexp->gexp strip-directories))))
+
+
+  (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+                                                  system #:graft? #f)))
+    (gexp->derivation name builder
+                      #:system system
+                      #:target target
+                      #:modules imported-modules
+                      #:allowed-references allowed-references
+                      #:disallowed-references disallowed-references
+                      #:guile-for-build guile)))
+
 (define glib-or-gtk-build-system
   (build-system
     (name 'glib-or-gtk)
-- 
2.33.0





  parent reply	other threads:[~2021-08-25 18:05 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 17:55 [bug#50201] [PATCH core-updates-frozen 0/52] Support cross-compilation in glib-or-gtk-build-system and fix cross-compilation errors Maxime Devos
2021-08-25 18:02 ` [bug#50201] [PATCH 01/52] gnu: dbus-glib: Support cross-compilation Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 02/52] gnu: elogind: Make #:configure-flags a G-exp Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 03/52] gnu: elogind: Fix cross-compilation Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 04/52] gnu: libcap: Fix cross-compilation build failures Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 05/52] gnu: perl: Find 'bash' when cross-compiling Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 06/52] gnu: nspr: Adjust to Mozilla cross-compilation conventions Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 07/52] gnu: nspr: Don't retain references to native inputs Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 08/52] gnu: mozjs-60: Fix cross-compilation build errors Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 09/52] gnu: poppler: Find pkg-config when cross-compiling Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 10/52] build-system/meson: Allow 'configure-flags' to be a G-exp Maxime Devos
2021-08-25 18:02   ` Maxime Devos [this message]
2021-08-25 18:02   ` [bug#50201] [PATCH 12/52] gnu: dbus-cairo: Add missing bash-minimal input Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 13/52] gnu: polkit: Prevent cross-compilation build error Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 14/52] gnu: gobject-introspection: Don't build introspection data when cross-compiling Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 15/52] gobject-introspection: Fix inputs " Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 16/52] gobject-introspection: Correct library name " Maxime Devos
2021-08-30 12:58     ` [bug#50201] [PATCH core-updates-frozen 0/52] Support cross-compilation in glib-or-gtk-build-system and fix cross-compilation errors Mathieu Othacehe
2021-09-03 12:35       ` Maxime Devos
2021-09-19 15:43         ` Mathieu Othacehe
2021-09-19 18:25           ` Maxime Devos
2021-09-20 11:22             ` bug#50201: " Mathieu Othacehe
2021-08-25 18:02   ` [bug#50201] [PATCH 17/52] gnu: atk: Disable introspection when cross-compiling Maxime Devos
2021-08-30 13:00     ` [bug#50201] [PATCH core-updates-frozen 0/52] Support cross-compilation in glib-or-gtk-build-system and fix cross-compilation errors Mathieu Othacehe
2021-08-30 16:45       ` Maxime Devos
2021-08-31  9:49         ` Mathieu Othacehe
2021-09-11 21:30           ` Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 18/52] gnu: bdb: Fix cross-compilation build errors Maxime Devos
2021-08-25 18:02   ` [bug#50201] [PATCH 19/52] gnu: graphene: Don't build introspection data when cross-compiling Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 20/52] gnu: gamin: Recognise aarch64 as architecture " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 21/52] gnu: gamin: Fix 'configure' script " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 22/52] gnu: iso-codes: Move inputs to native-inputs " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 23/52] gnu: heimdal: Fix inputs " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 24/52] gnu: heimdal: Fix linking error " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 25/52] gnu: heimdal: Refer to cross-compiled bash Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 26/52] gnu: heimdal: Use the cross-compiled bash in "su" Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 27/52] gnu: heimdal: Find tools when cross-compiling Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 28/52] gnu: heimdal: Use libcom_err from input " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 29/52] gnu: json-glib: Add missing 'bash-minimal' input Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 30/52] gnu: json-glib: Find docbook inputs when cross-compiling Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 31/52] gnu: json-glib: Don't build gtk documentation " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 32/52] gnu: json-glib: Don't build introspection data " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 33/52] gnu: libthai: Add datrie as native-input " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 34/52] gnu: libdaemon: Support cross-compilation to aarch64-linux-gnu Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 35/52] gnu: avahi: Find 'TARGET-pkg-config' when cross-compiling Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 36/52] gnu: avahi: Use the cross-compiled bash Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 37/52] gnu: at-spi2-core: Don't cross-compile documentation Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 38/52] gnu: at-spi2-core: Find docbook when cross-compiling Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 39/52] gnu: at-spi2-core: Add missing "bash-minimal" input Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 40/52] gnu: xorg: Unify --disable-malloc0-returnsnull code Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 41/52] gnu: libxinerama: Add --disable-malloc0-returnsnull when necessary Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 42/52] gnu: libxi: " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 43/52] gnu: libxrandr: " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 44/52] gnu: libxxf85vm: " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 45/52] gnu: Add pkg-config-for-build Maxime Devos
2021-08-30 13:13     ` [bug#50201] [PATCH core-updates-frozen 0/52] Support cross-compilation in glib-or-gtk-build-system and fix cross-compilation errors Mathieu Othacehe
2021-09-02 14:53       ` Maxime Devos
2021-09-22 19:10         ` Ludovic Courtès
2021-09-23 10:38           ` Maxime Devos
2021-09-23 16:53             ` Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 46/52] gnu: wayland: Find wayland-scanner when cross-compiling Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 47/52] gnu: wayland: Find docbook-xml " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 48/52] gnu: libproxy: Don't run tests " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 49/52] gnu: gdk-pixbuf: Find docbook " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 50/52] gnu: gdk-pixbuf: Add bash-minimal input " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 51/52] gnu: pango: " Maxime Devos
2021-08-25 18:03   ` [bug#50201] [PATCH 52/52] gnu: at-spi2-atk: Don't compile tests " Maxime Devos
2021-08-28 13:33 ` [bug#50201] [PATCH core-updates-frozen 0/52] Support cross-compilation in glib-or-gtk-build-system and fix cross-compilation errors Mathieu Othacehe
2021-08-30 12:16   ` Maxime Devos
2021-08-30 12:30     ` Mathieu Othacehe
2021-08-30 12:19 ` Maxime Devos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210825180332.5720-11-maximedevos@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=50201@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).