diff mbox series

[bug#66263,v1,04/22] guix: Add target-avr?.

Message ID 20231128113510.11214-4-jean@foundationdevices.com
State New
Headers show
Series None | expand

Commit Message

Jean-Pierre De Jesus DIAZ Nov. 28, 2023, 11:34 a.m. UTC
* guix/utils.scm (target-avr?): New procedure.
* tests/utils.scm: Add tests for target-avr? procedure.

Change-Id: Iaa0fa97a2b6bc45d45f907f43157f1548a0ba3fa
---
 guix/utils.scm  |  6 ++++++
 tests/utils.scm | 12 ++++++++++++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/guix/utils.scm b/guix/utils.scm
index 7a42b49df2..8e71f97e1c 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -19,6 +19,7 @@ 
 ;;; Copyright © 2023 Philip McGrath <philip@philipmcgrath.com>
 ;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2023 Zheng Junjie <873216071@qq.com>
+;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -99,6 +100,7 @@  (define-module (guix utils)
             target-arm32?
             target-aarch64?
             target-arm?
+            target-avr?
             target-ppc32?
             target-ppc64le?
             target-powerpc?
@@ -724,6 +726,10 @@  (define* (target-arm? #:optional (target (or (%current-target-system)
                                              (%current-system))))
   (or (target-arm32? target) (target-aarch64? target)))
 
+(define* (target-avr? #:optional (target (%current-target-system)))
+  "Is the architecture of TARGET a variant of Microchip's AVR architecture?"
+  (or (string=? target "avr") (string-prefix? "avr-" target)))
+
 (define* (target-ppc32? #:optional (target (or (%current-target-system)
                                                (%current-system))))
   (string-prefix? "powerpc-" target))
diff --git a/tests/utils.scm b/tests/utils.scm
index 648e91f242..5664165c85 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -4,6 +4,7 @@ 
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -329,6 +330,17 @@  (define (test-compression/decompression method run?)
          ;; However, it isn't 32-bit.
          ,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
 
+(test-equal "target-avr?"
+  '(#t #t #t #f #f)
+  (map target-avr?
+       '("avr" "avr-unknown-none"
+         ;; In addition LLVM also uses this form.
+         "avr-unknown-unknown"
+         ;; The AVR32 architecture also was made by Atmel/Microchip but it
+         ;; does not resemble the AVR family, they aren't compatible in any
+         ;; way.
+         "avr32" "avr32-unknown-none")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))