GNU bug report logs - #59885
[PATCH] gnu: cross-base: Standardize API to use keyword arguments.

Previous Next

Package: guix-patches;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Wed, 7 Dec 2022 15:45:02 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59885 in the body.
You can then email your comments to 59885 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#59885; Package guix-patches. (Wed, 07 Dec 2022 15:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 07 Dec 2022 15:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH] gnu: cross-base: Standardize API to use keyword arguments.
Date: Wed,  7 Dec 2022 10:44:33 -0500
This makes it possible to invoke the procedures with a single or fewer
optional arguments.

* gnu/packages/cross-base.scm (contains-keyword?): New procedure.
(cross-binutils): Dispatch to either...
(cross-binutils/deprecated): ... this renamed procedure or ...
(cross-binutils*): ... this new procedure.
(cross-kernel-headers, cross-libc/deprecated): Likewise.
---
 gnu/packages/cross-base.scm | 74 +++++++++++++++++++++++++++++++------
 1 file changed, 62 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 44c1bb0ef2..add9a2f901 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <marius <at> gnu.org>
 ;;; Copyright © 2019 Carl Dong <contact <at> carldong.me>
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe <at> gmail.com>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,7 +33,9 @@ (define-module (gnu packages cross-base)
   #:use-module (gnu packages mingw)
   #:use-module (guix platform)
   #:use-module (guix packages)
+  #:use-module (guix diagnostics)
   #:use-module (guix download)
+  #:use-module (guix i18n)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
@@ -74,7 +77,20 @@ (define (cross p target)
         `(cons ,(string-append "--target=" target)
                ,flags))))))
 
-(define* (cross-binutils target #:optional (binutils binutils))
+(define (contains-keyword? args)
+  "Check if ARGS contains a keyword object."
+  (find keyword? args))
+
+(define* (cross-binutils . args)
+  (if (or (= (length args) 1) (contains-keyword? args))
+      (apply cross-binutils* args)
+      (apply cross-binutils/deprecated args)))
+
+(define* (cross-binutils/deprecated target #:optional (binutils binutils))
+  (warning (G_ "'cross-binutils' must be used with keyword arguments~%"))
+  (cross-binutils* target #:binutils binutils))
+
+(define* (cross-binutils* target #:key (binutils binutils))
   "Return a cross-Binutils for TARGET using BINUTILS."
   (let ((binutils (package
                     (inherit binutils)
@@ -333,11 +349,27 @@ (define* (cross-gcc target
                              %gcc-cross-include-paths)))
     (native-search-paths '())))
 
-(define* (cross-kernel-headers target
-                               #:optional
-                               (linux-headers linux-libre-headers)
-                               (xgcc (cross-gcc target))
-                               (xbinutils (cross-binutils target)))
+(define* (cross-kernel-headers . args)
+  (if (or (= (length args) 1) (contains-keyword? args))
+      (apply cross-kernel-headers* args)
+      (apply cross-kernel-headers/deprecated args)))
+
+(define* (cross-kernel-headers/deprecated target
+                                          #:optional
+                                          (linux-headers linux-libre-headers)
+                                          (xgcc (cross-gcc target))
+                                          (xbinutils (cross-binutils target)))
+  (warning (G_ "'cross-kernel-headers' must be used with keyword arguments~%"))
+  (cross-kernel-headers* target
+                         #:linux-headers linux-headers
+                         #:xgcc xgcc
+                         #:xbinutils xbinutils))
+
+(define* (cross-kernel-headers* target
+                                #:key
+                                (linux-headers linux-libre-headers)
+                                (xgcc (cross-gcc target))
+                                (xbinutils (cross-binutils target)))
   "Return headers depending on TARGET."
 
   (define xlinux-headers
@@ -491,12 +523,30 @@ (define xhurd-core-headers
     ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
     (_ xlinux-headers)))
 
-(define* (cross-libc target
-                     #:optional
-                     (libc glibc)
-                     (xgcc (cross-gcc target))
-                     (xbinutils (cross-binutils target))
-                     (xheaders (cross-kernel-headers target)))
+(define* (cross-libc . args)
+  (if (or (= (length args) 1) (contains-keyword? args))
+      (apply cross-libc* args)
+      (apply cross-libc/deprecated args)))
+
+(define* (cross-libc/deprecated target
+                                #:optional
+                                (libc glibc)
+                                (xgcc (cross-gcc target))
+                                (xbinutils (cross-binutils target))
+                                (xheaders (cross-kernel-headers target)))
+  (warning (G_ "'cross-libc' must be used with keyword arguments~%"))
+  (cross-libc* target
+               #:libc libc
+               #:xgcc xgcc
+               #:xbinutils xbinutils
+               #:xheaders xheaders))
+
+(define* (cross-libc* target
+                      #:key
+                      (libc glibc)
+                      (xgcc (cross-gcc target))
+                      (xbinutils (cross-binutils target))
+                      (xheaders (cross-kernel-headers target)))
   "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
 and the cross tool chain."
   (if (target-mingw? target)

base-commit: dfc6957a5af7d179d4618eb19d4f555c519bc6f2
prerequisite-patch-id: 660177fb9eee55d11983ea9360c072730d0d21a5
prerequisite-patch-id: 776778c03bce9b7ad3ab94a120f42b764c00fcae
prerequisite-patch-id: eeb2523a77c9c422a5785549dbd29ec0220118d7
prerequisite-patch-id: fd4074fb4cf068ccac3122c19138f098a610542a
-- 
2.38.1





Added indication that bug 59885 blocks60056 Request was from Maxim Cournoyer <maxim.cournoyer <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 14 Dec 2022 20:35:02 GMT) Full text and rfc822 format available.

Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Tue, 03 Jan 2023 21:15:01 GMT) Full text and rfc822 format available.

Notification sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
bug acknowledged by developer. (Tue, 03 Jan 2023 21:15:01 GMT) Full text and rfc822 format available.

Message #12 received at 59885-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 59885-done <at> debbugs.gnu.org
Subject: Re: bug#59885: [PATCH] gnu: cross-base: Standardize API to use
 keyword arguments.
Date: Tue, 03 Jan 2023 16:14:32 -0500
Hello,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> This makes it possible to invoke the procedures with a single or fewer
> optional arguments.
>
> * gnu/packages/cross-base.scm (contains-keyword?): New procedure.
> (cross-binutils): Dispatch to either...
> (cross-binutils/deprecated): ... this renamed procedure or ...
> (cross-binutils*): ... this new procedure.
> (cross-kernel-headers, cross-libc/deprecated): Likewise.

Applied with 2707b6ccd7.

Closing.

-- 
Thanks,
Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 01 Feb 2023 12:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 140 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.