mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
utils: Define a target-x86-32? and target-x86-64? predicate.
* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates. * tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
This commit is contained in:
parent
b96ae47bb0
commit
b0519cc4b0
2 changed files with 43 additions and 0 deletions
|
@ -79,6 +79,8 @@ (define-module (guix utils)
|
||||||
%current-target-system
|
%current-target-system
|
||||||
package-name->name+version
|
package-name->name+version
|
||||||
target-mingw?
|
target-mingw?
|
||||||
|
target-x86-32?
|
||||||
|
target-x86-64?
|
||||||
target-arm32?
|
target-arm32?
|
||||||
target-aarch64?
|
target-aarch64?
|
||||||
target-arm?
|
target-arm?
|
||||||
|
@ -535,6 +537,24 @@ (define* (target-mingw? #:optional (target (%current-target-system)))
|
||||||
(and target
|
(and target
|
||||||
(string-suffix? "-mingw32" target)))
|
(string-suffix? "-mingw32" target)))
|
||||||
|
|
||||||
|
(define* (target-x86-32? #:optional (target (or (%current-target-system)
|
||||||
|
(%current-system))))
|
||||||
|
"Is the architecture of TARGET a variant of Intel's 32-bit architecture
|
||||||
|
(IA32)?"
|
||||||
|
;; Intel also has a 16-bit architecture in the iN86 series, i286
|
||||||
|
;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this
|
||||||
|
;; procedure is not named target-x86?.
|
||||||
|
(or (string-prefix? "i386-" target)
|
||||||
|
(string-prefix? "i486-" target)
|
||||||
|
(string-prefix? "i586-" target)
|
||||||
|
(string-prefix? "i686-" target)))
|
||||||
|
|
||||||
|
(define* (target-x86-64? #:optional (target (or (%current-target-system)
|
||||||
|
(%current-system))))
|
||||||
|
"Is the architecture of TARGET a variant of Intel/AMD's 64-bit
|
||||||
|
architecture (x86_64)?"
|
||||||
|
(string-prefix? "x86_64-" target))
|
||||||
|
|
||||||
(define* (target-arm32? #:optional (target (or (%current-target-system)
|
(define* (target-arm32? #:optional (target (or (%current-target-system)
|
||||||
(%current-system))))
|
(%current-system))))
|
||||||
(string-prefix? "arm" target))
|
(string-prefix? "arm" target))
|
||||||
|
|
|
@ -289,6 +289,29 @@ (define (test-compression/decompression method run?)
|
||||||
(string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
|
(string-closest "hello" '("kikoo" "helo" "hihihi" "halo"))
|
||||||
(string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
|
(string-closest "hello" '("aaaaa" "12345" "hellohello" "h"))))
|
||||||
|
|
||||||
|
(test-equal "target-x86-32?"
|
||||||
|
'(#f #f #f #t #t #t #t #f)
|
||||||
|
;; These are (according to Wikipedia) two RISC architectures
|
||||||
|
;; by Intel and presumably not compatible with the x86-32 series.
|
||||||
|
(map target-x86-32?
|
||||||
|
'("i860-gnu" "i960-gnu"
|
||||||
|
;; This is a 16-bit architecture
|
||||||
|
"i286-gnu"
|
||||||
|
;; These are part of the x86-32 series.
|
||||||
|
"i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu"
|
||||||
|
;; Maybe this one will exist some day, but not yet.
|
||||||
|
"i786-gnu")))
|
||||||
|
|
||||||
|
(test-equal "target-x86-64?"
|
||||||
|
'(#t #f #f #f)
|
||||||
|
(map target-x86-64?
|
||||||
|
`("x86_64-linux-gnu" "i386-linux-gnu"
|
||||||
|
;; Just because it includes "64" doesn't make it 64-bit.
|
||||||
|
"aarch64-linux-gnu"
|
||||||
|
;; Note that (expt 2 109) in decimal notation starts with 64.
|
||||||
|
;; However, it isn't 32-bit.
|
||||||
|
,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
||||||
(false-if-exception (delete-file temp-file))
|
(false-if-exception (delete-file temp-file))
|
||||||
|
|
Loading…
Reference in a new issue