Subject: [PATCH v3 01/10] guix: Add build-system transformation for target.

From: Julien Lepiller <[email-masked]>
Date: Sat, 16 Jul 2022 21:47:58 +0200

* guix/build-system.scm (build-system-with-target): New procedure.
---
 guix/build-system.scm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/guix/build-system.scm b/guix/build-system.scm
index 76d670995c..7d864423e3 100644
--- a/guix/build-system.scm
+++ b/guix/build-system.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix build-system)
   #:use-module (guix records)
+  #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
   #:export (build-system
@@ -40,7 +41,8 @@ (define-module (guix build-system)
 
             make-bag
 
-            build-system-with-c-toolchain))
+            build-system-with-c-toolchain
+            build-system-with-target))
 
 (define-record-type* <build-system> build-system make-build-system
   build-system?
@@ -129,3 +131,20 @@ (define (lower* . args)
   (build-system
     (inherit bs)
     (lower lower*)))
+
+(define (build-system-with-target bs target)
+  "Return a variant of @var{bs}, a build system, that user @var{target} instead
+of the default target."
+  (define lower
+    (build-system-lower bs))
+
+  (define (lower* . args)
+    (parameterize ((%current-target-system target))
+      (apply lower
+             (append
+               (strip-keyword-arguments (list #:target) args)
+               (list #:target target)))))
+
+  (build-system
+    (inherit bs)
+    (lower lower*)))
-- 
2.37.0