guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/20: utils: Define target-linux? predicate.


From: guix-commits
Subject: 01/20: utils: Define target-linux? predicate.
Date: Mon, 12 Jul 2021 11:15:40 -0400 (EDT)

mothacehe pushed a commit to branch wip-meson
in repository guix.

commit 020e575d1c9df79c052b5a34edabfe65bc1056f7
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sun Jul 11 13:47:04 2021 +0200

    utils: Define target-linux? predicate.
    
    * guix/utils.scm (target-linux?): New predicate.
    * tests/utils.scm
      ("target-linux?"): Test it.
      ("target-mingw?"): Also test ‘target-mingw?’.
    
    Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
---
 guix/utils.scm  |  8 ++++++++
 tests/utils.scm | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index 65d709a..016ad34 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -83,6 +84,7 @@
             %current-system
             %current-target-system
             package-name->name+version
+            target-linux?
             target-mingw?
             target-arm32?
             target-aarch64?
@@ -632,7 +634,13 @@ a character other than '@'."
     (idx (values (substring spec 0 idx)
                  (substring spec (1+ idx))))))
 
+(define* (target-linux? #:optional (target (or (%current-target-system)
+                                               (%current-system))))
+  "Is the operating system of TARGET Linux?"
+  (->bool (string-contains target "linux")))
+
 (define* (target-mingw? #:optional (target (%current-target-system)))
+  "Is the operating system of TARGET Windows 32 bits?"
   (and target
        (string-suffix? "-mingw32" target)))
 
diff --git a/tests/utils.scm b/tests/utils.scm
index 7fcbb25..7142ac2 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -289,6 +290,21 @@ skip these tests."
    (string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
    (string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
 
+(test-equal "target-linux?"
+  '(#t #f #f #t)
+  (map target-linux?
+       '("i686-linux-gnu" "i686-w64-mingw32"
+         ;; Checking that "gnu" is present is not sufficient,
+         ;; as GNU/Hurd exists.
+         "i686-pc-gnu"
+         ;; Some targets have a suffix.
+         "arm-linux-gnueabihf")))
+
+(test-equal "target-mingw?"
+  '(#f #f #t)
+  (map target-mingw?
+       '("i686-linux-gnu" "i686-pc-gnu" "i686-w64-mingw32")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]