summaryrefslogtreecommitdiff
path: root/guix/scripts/build.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-08-03 23:01:01 +0200
committerLudovic Courtès <ludo@gnu.org>2022-08-04 12:05:46 +0200
commitf44c13560885a8751fe59ba2e512a726c1674b1e (patch)
tree7c19155fb83aea879e481bf6adf910e6e8b646fc /guix/scripts/build.scm
parent933d3cf7f7fe7ed6eae130ae8275176573af1638 (diff)
guix build: Print hints when -s or --target is passed an invalid string.
* guix/scripts/build.scm (%standard-cross-build-options) (%standard-native-build-options): Print hints when the target/system is not found.
Diffstat (limited to 'guix/scripts/build.scm')
-rw-r--r--guix/scripts/build.scm29
1 files changed, 25 insertions, 4 deletions
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 75bbb701ae..06d9ad1f0c 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -373,8 +373,19 @@ use '--no-offload' instead~%")))
(first (member arg (targets))))))
(if t
(apply values (alist-cons 'target t result) rest)
- (leave (G_ "'~a' is not a supported target~%")
- arg)))))))
+ (let ((closest (string-closest arg (targets)
+ #:threshold 5)))
+ (report-error
+ (G_ "'~a' is not a supported cross-compilation target~%")
+ arg)
+ (if closest
+ (display-hint
+ (format #f (G_ "Did you mean @code{~a}?
+Try @option{--list-targets} to view available targets.~%")
+ closest))
+ (display-hint (G_ "\
+Try @option{--list-targets} to view available targets.~%")))
+ (exit 1))))))))
(define %standard-native-build-options
;; Build options related to native builds.
@@ -389,8 +400,18 @@ use '--no-offload' instead~%")))
(first (member arg (systems))))))
(if s
(apply values (alist-cons 'system s result) rest)
- (leave (G_ "'~a' is not a supported system~%")
- arg)))))))
+ (let ((closest (string-closest arg (systems)
+ #:threshold 5)))
+ (report-error (G_ "'~a' is not a supported system~%")
+ arg)
+ (if closest
+ (display-hint
+ (format #f (G_ "Did you mean @code{~a}?
+Try @option{--list-systems} to view available system types.~%")
+ closest))
+ (display-hint (G_ "\
+Try @option{--list-systems} to view available system types.~%")))
+ (exit 1))))))))
;;;