diff mbox series

[bug#70985,v3,5/6] gnu: rust: Guard against unsupported rust targets.

Message ID a4b0befc51be866145bc61d7ee8b2423af431f48.1720791705.git.mail@cbaines.net
State New
Headers show
Series [bug#70985,v3,1/6] guix: packages: Add new &package-unsupported-target-error. | expand

Commit Message

Christopher Baines July 12, 2024, 1:41 p.m. UTC
As cross-libc may return #f in this case, and the config.toml file
construction will also fail if the platform rust-target is #f..

* gnu/packages/rust.scm (make-rust-sysroot/implementation): Guard against
unsupported rust targets.

Change-Id: Ia0d5c889c6f5cd3478ad985c79feb9ba1c472c29
---
 gnu/packages/rust.scm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Efraim Flashner July 12, 2024, 2:28 p.m. UTC | #1
I like this. We can always add more platforms later with their
platform-rust-target later as needed.

On Fri, Jul 12, 2024 at 02:41:44PM +0100, Christopher Baines wrote:
> As cross-libc may return #f in this case, and the config.toml file
> construction will also fail if the platform rust-target is #f..
> 
> * gnu/packages/rust.scm (make-rust-sysroot/implementation): Guard against
> unsupported rust targets.
> 
> Change-Id: Ia0d5c889c6f5cd3478ad985c79feb9ba1c472c29
> ---
>  gnu/packages/rust.scm | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
> index a385344473..8119f4560a 100644
> --- a/gnu/packages/rust.scm
> +++ b/gnu/packages/rust.scm
> @@ -73,7 +73,9 @@ (define-module (gnu packages rust)
>    #:use-module (ice-9 match)
>    #:use-module (ice-9 optargs)
>    #:use-module (srfi srfi-1)
> -  #:use-module (srfi srfi-26))
> +  #:use-module (srfi srfi-26)
> +  #:use-module (srfi srfi-34)
> +  #:use-module (srfi srfi-35))
>  
>  ;; This is the hash for the empty file, and the reason it's relevant is not
>  ;; the most obvious.
> @@ -1309,6 +1311,13 @@ (define*-public (make-rust-sysroot target)
>  
>  (define make-rust-sysroot/implementation
>    (mlambda (target base-rust)
> +    (unless (platform-rust-target (lookup-platform-by-target target))
> +      (raise
> +       (condition
> +        (&package-unsupported-target-error
> +         (package base-rust)
> +         (target target)))))
> +
>      (package
>        (inherit base-rust)
>        (name (string-append "rust-sysroot-for-" target))
> -- 
> 2.45.2
> 
> 
>
Christopher Baines July 18, 2024, 2:16 p.m. UTC | #2
Efraim Flashner <efraim@flashner.co.il> writes:

> I like this. We can always add more platforms later with their
> platform-rust-target later as needed.

Great. Late reply but I went ahead and pushed this to master as
32eda739664901b6df680e79f869e439a326572f.

Chris
diff mbox series

Patch

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index a385344473..8119f4560a 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -73,7 +73,9 @@  (define-module (gnu packages rust)
   #:use-module (ice-9 match)
   #:use-module (ice-9 optargs)
   #:use-module (srfi srfi-1)
-  #:use-module (srfi srfi-26))
+  #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-35))
 
 ;; This is the hash for the empty file, and the reason it's relevant is not
 ;; the most obvious.
@@ -1309,6 +1311,13 @@  (define*-public (make-rust-sysroot target)
 
 (define make-rust-sysroot/implementation
   (mlambda (target base-rust)
+    (unless (platform-rust-target (lookup-platform-by-target target))
+      (raise
+       (condition
+        (&package-unsupported-target-error
+         (package base-rust)
+         (target target)))))
+
     (package
       (inherit base-rust)
       (name (string-append "rust-sysroot-for-" target))