Message ID | 20210711114723.27568-2-maximedevos@telenet.be |
---|---|
State | Accepted |
Headers | show |
Series | Support cross-compilation with Meson | expand |
Context | Check | Description |
---|---|---|
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | fail | View Laminar job |
cbaines/issue | success | View issue |
Hey, > +(define* (target-linux? #:optional (target (or (%current-target-system) > + (%current-system)))) You can add a docstring here, something like: "Is the operating system of TARGET Linux?" > + (string-contains target "linux")) You should use the "->bool" procedure to return a boolean here. > (define* (target-mingw? #:optional (target (%current-target-system))) You can add a docstring, something like: "Is the operating system of TARGET Windows 32 bits?" > + (map (compose ->bool target-linux?) target-linux? should return a boolean > +(test-equal "target-mingw?" > + '(#f #f #t) > + (map (compose ->bool target-mingw?) You can write: --8<---------------cut here---------------start------------->8--- (map target-mingw? '("i686-linux-gnu" "i686-pc-gnu" "i686-w64-mingw32"))) --8<---------------cut here---------------end--------------->8--- here. Thanks, Mathieu
Mathieu Othacehe schreef op ma 12-07-2021 om 14:35 [+0200]: > Hey, > > > +(define* (target-linux? #:optional (target (or (%current-target-system) > > + (%current-system)))) > > You can add a docstring here, something like: > > "Is the operating system of TARGET Linux?" The Linux kernel by itself doesn't make an operating system, as the kernel doesn't have a package manager, display manager, basic text editors, application to configure network connections ..., so I made this "Does the operating system of TARGET use the Linux kernel?" > > + (string-contains target "linux")) > > You should use the "->bool" procedure to return a boolean here. Done in v5. > > (define* (target-mingw? #:optional (target (%current-target-system))) > > You can add a docstring, something like: > > "Is the operating system of TARGET Windows 32 bits?" Done in v5, but I dropped the '32-bits' and added a comment: ;; The "-32" doesn't mean TARGET is 32-bit, as "x86_64-w64-mingw32" ;; is a valid triplet (see the (gnu ci) module) and 'w64' and 'x86_64' ;; are 64-bit. I wouldn't know what the "32" in "mingw32" refers to. > > + (map (compose ->bool target-linux?) > > target-linux? should return a boolean > > > +(test-equal "target-mingw?" > > + '(#f #f #t) > > + (map (compose ->bool target-mingw?) > > You can write: > > --8<---------------cut here---------------start------------->8--- > (map target-mingw? > '("i686-linux-gnu" "i686-pc-gnu" "i686-w64-mingw32"))) > --8<---------------cut here---------------end--------------->8--- > > here. Done in v5. I'll send the v5 once everything is tested again and commits have been properly rebased. Greetings, Maxime.
Maxime Devos schreef op di 13-07-2021 om 15:33 [+0200]:
> Done in v5.
I meant v6 here.
diff --git a/guix/utils.scm b/guix/utils.scm index 19990ceb8a..4ff2602e23 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. ;;; @@ -81,6 +82,7 @@ %current-system %current-target-system package-name->name+version + target-linux? target-mingw? target-arm32? target-aarch64? @@ -543,6 +545,10 @@ 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)))) + (string-contains target "linux")) + (define* (target-mingw? #:optional (target (%current-target-system))) (and target (string-suffix? "-mingw32" target))) diff --git a/tests/utils.scm b/tests/utils.scm index 7fcbb25552..80a0e669a4 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,22 @@ 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 (compose ->bool 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 (compose ->bool target-mingw?) + '("i686-linux-gnu" "i686-pc-gnu" + "i686-w64-mingw32"))) + (test-end) (false-if-exception (delete-file temp-file))