summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2022-05-02 12:59:14 +0200
committerMathieu Othacehe <othacehe@gnu.org>2022-05-22 15:15:33 +0200
commitec42d287b4558b4d1908e3e71dcf9358d5c6ae8c (patch)
treee361ffc243182eeb3d6010420adc78b20d73b50d /guix
parentdd970122ddf3679482f658f73dd68307496c6215 (diff)
downloadguix-patches-ec42d287b4558b4d1908e3e71dcf9358d5c6ae8c.tar
guix-patches-ec42d287b4558b4d1908e3e71dcf9358d5c6ae8c.tar.gz
scripts: Add --list-systems and --list-targets options.
Also factorize the --system and --target build options. Check that the passed system and target arguments are known platforms. * doc/guix.texi (Additional Build Options): Document the new --list-systems and --list-targets options. * guix/scripts/build.scm (show-cross-build-options-help, show-emulated-build-options-help, list-systems, list-targets): New procedures. (%standard-cross-build-options, %standard-emulated-build-options): New variables. (show-help): Remove --system and --target entries and use show-cross-build-options-help and show-emulated-build-options-help procedures instead. (%options): Remove --system and --target entries and use %standard-cross-build-options and %standard-emulated-build-options variables instead. * guix/scripts/archive.scm (show-help, %options): Adapt them. * guix/scripts/environment.scm: Ditto. * guix/scripts/graph.scm: Ditto. * guix/scripts/pack.scm: Ditto. * guix/scripts/pull.scm: Ditto. * guix/scripts/size.scm: Ditto. * guix/scripts/weather.scm: Ditto. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/archive.scm20
-rw-r--r--guix/scripts/build.scm84
-rw-r--r--guix/scripts/environment.scm11
-rw-r--r--guix/scripts/graph.scm15
-rw-r--r--guix/scripts/pack.scm20
-rw-r--r--guix/scripts/pull.scm12
-rw-r--r--guix/scripts/size.scm13
-rw-r--r--guix/scripts/weather.scm11
8 files changed, 112 insertions, 74 deletions
diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index f8678aa5f9..1e961c84e6 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -93,14 +93,14 @@ Export/import one or more packages from/to the store.\n"))
(display (G_ "
-S, --source build the packages' source derivations"))
(display (G_ "
- -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
- (display (G_ "
- --target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
- (display (G_ "
-v, --verbosity=LEVEL use the given verbosity LEVEL"))
(newline)
(show-build-options-help)
+ (newline)
+ (show-cross-build-options-help)
+ (newline)
+ (show-native-build-options-help)
(newline)
(display (G_ "
@@ -166,14 +166,6 @@ Export/import one or more packages from/to the store.\n"))
(option '(#\S "source") #f #f
(lambda (opt name arg result)
(alist-cons 'source? #t result)))
- (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg
- (alist-delete 'system result eq?))))
- (option '("target") #t #f
- (lambda (opt name arg result)
- (alist-cons 'target arg
- (alist-delete 'target result eq?))))
(option '(#\e "expression") #t #f
(lambda (opt name arg result)
(alist-cons 'expression arg result)))
@@ -186,7 +178,9 @@ Export/import one or more packages from/to the store.\n"))
(lambda (opt name arg result)
(alist-cons 'dry-run? #t result)))
- %standard-build-options))
+ (append %standard-build-options
+ %standard-cross-build-options
+ %standard-native-build-options)))
(define (derivation-from-expression store str package-derivation
system source?)
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index d9cdb6e5e0..a09c54451f 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -47,6 +47,7 @@
#:use-module (srfi srfi-35)
#:use-module (srfi srfi-37)
#:use-module (gnu packages)
+ #:use-module (gnu platform)
#:use-module ((guix status) #:select (with-status-verbosity))
#:use-module ((guix progress) #:select (current-terminal-columns))
#:use-module ((guix build syscalls) #:select (terminal-columns))
@@ -54,9 +55,15 @@
#:export (log-url
%standard-build-options
+ %standard-cross-build-options
+ %standard-native-build-options
+
set-build-options-from-command-line
set-build-options-from-command-line*
+
show-build-options-help
+ show-cross-build-options-help
+ show-native-build-options-help
guix-build
register-root
@@ -184,6 +191,18 @@ options handled by 'set-build-options-from-command-line', and listed in
(display (G_ "
--debug=LEVEL produce debugging output at LEVEL")))
+(define (show-cross-build-options-help)
+ (display (G_ "
+ --list-targets list available targets"))
+ (display (G_ "
+ --target=TRIPLET cross-build for TRIPLET--e.g., \"aarch64-linux-gnu\"")))
+
+(define (show-native-build-options-help)
+ (display (G_ "
+ --list-systems list available systems"))
+ (display (G_ "
+ -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\"")))
+
(define (set-build-options-from-command-line store opts)
"Given OPTS, an alist as returned by 'args-fold' given
'%standard-build-options', set the corresponding build options on STORE."
@@ -319,6 +338,52 @@ use '--no-offload' instead~%")))
(leave (G_ "not a number: '~a' option argument: ~a~%")
name arg)))))))
+(define (list-systems)
+ "Print the available systems."
+ (display (G_ "The available systems are:\n"))
+ (newline)
+ (format #t "~{ - ~a ~%~}"
+ (sort (systems) string<?)))
+
+(define (list-targets)
+ "Print the available targets."
+ (display (G_ "The available targets are:\n"))
+ (newline)
+ (format #t "~{ - ~a ~%~}"
+ (sort (targets) string<?)))
+
+(define %standard-cross-build-options
+ ;; Build options related to cross builds.
+ (list
+ (option '("list-targets") #f #f
+ (lambda (opt name arg result)
+ (list-targets)
+ (exit 0)))
+ (option '("target") #t #f
+ (lambda (opt name arg result . rest)
+ (let ((t (false-if-exception
+ (first (member arg (targets))))))
+ (if t
+ (apply values (alist-cons 'target t result) rest)
+ (leave (G_ "'~a' is not a supported target~%")
+ arg)))))))
+
+(define %standard-native-build-options
+ ;; Build options related to native builds.
+ (list
+ (option '("list-systems") #f #f
+ (lambda (opt name arg result)
+ (list-systems)
+ (exit 0)))
+ (option '(#\s "system") #t #f
+ (lambda (opt name arg result . rest)
+ (let ((s (false-if-exception
+ (first (member arg (systems))))))
+ (if s
+ (apply values (alist-cons 'system s result) rest)
+ (leave (G_ "'~a' is not a supported system~%")
+ arg)))))))
+
;;;
;;; Command-line options.
@@ -353,10 +418,6 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
--sources[=TYPE] build source derivations; TYPE may optionally be one
of \"package\", \"all\" (default), or \"transitive\""))
(display (G_ "
- -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
- (display (G_ "
- --target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
- (display (G_ "
-d, --derivations return the derivation paths of the given packages"))
(display (G_ "
--check rebuild items to check for non-determinism issues"))
@@ -374,6 +435,10 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
(newline)
(show-build-options-help)
(newline)
+ (show-cross-build-options-help)
+ (newline)
+ (show-native-build-options-help)
+ (newline)
(show-transformation-options-help)
(newline)
(display (G_ "
@@ -420,13 +485,6 @@ must be one of 'package', 'all', or 'transitive'~%")
(alist-cons 'build-mode (build-mode repair)
result)
rest)))
- (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg result)))
- (option '("target") #t #f
- (lambda (opt name arg result)
- (alist-cons 'target arg
- (alist-delete 'target result eq?))))
(option '(#\d "derivations") #f #f
(lambda (opt name arg result)
(alist-cons 'derivations-only? #t result)))
@@ -459,7 +517,9 @@ must be one of 'package', 'all', or 'transitive'~%")
(alist-cons 'log-file? #t result)))
(append %transformation-options
- %standard-build-options)))
+ %standard-build-options
+ %standard-cross-build-options
+ %standard-native-build-options)))
(define (options->things-to-build opts)
"Read the arguments from OPTS and return a list of high-level objects to
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 07b54cd89b..3216235937 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -96,8 +96,6 @@ shell'."
(display (G_ "
--search-paths display needed environment variable definitions"))
(display (G_ "
- -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
- (display (G_ "
-r, --root=FILE make FILE a symlink to the result, and register it
as a garbage collector root"))
(display (G_ "
@@ -145,6 +143,8 @@ COMMAND or an interactive shell in that environment.\n"))
(newline)
(show-build-options-help)
(newline)
+ (show-native-build-options-help)
+ (newline)
(show-transformation-options-help)
(newline)
(display (G_ "
@@ -226,10 +226,6 @@ use '--preserve' instead~%"))
(option '(#\n "dry-run") #f #f
(lambda (opt name arg result)
(alist-cons 'dry-run? #t result)))
- (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg
- (alist-delete 'system result eq?))))
(option '(#\C "container") #f #f
(lambda (opt name arg result)
(alist-cons 'container? #t result)))
@@ -273,7 +269,8 @@ use '--preserve' instead~%"))
(alist-cons 'bootstrap? #t result)))
(append %transformation-options
- %standard-build-options)))
+ %standard-build-options
+ %standard-native-build-options)))
(define (pick-all alist key)
"Return a list of values in ALIST associated with KEY."
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 535875c858..2f102180c9 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -39,7 +39,9 @@
options->transformation
%transformation-options))
#:use-module ((guix scripts build)
- #:select (%standard-build-options))
+ #:select (%standard-build-options
+ %standard-native-build-options
+ show-native-build-options-help))
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
@@ -504,10 +506,6 @@ package modules, while attempting to retain user package modules."
(option '(#\e "expression") #t #f
(lambda (opt name arg result)
(alist-cons 'expression arg result)))
- (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg
- (alist-delete 'system result eq?))))
(find (lambda (option)
(member "load-path" (option-names option)))
%standard-build-options)
@@ -519,7 +517,8 @@ package modules, while attempting to retain user package modules."
(lambda args
(show-version-and-exit "guix graph")))
- %transformation-options))
+ (append %transformation-options
+ %standard-native-build-options)))
(define (show-help)
;; TRANSLATORS: Here 'dot' is the name of a program; it must not be
@@ -540,8 +539,6 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
--path display the shortest path between the given nodes"))
(display (G_ "
-e, --expression=EXPR consider the package EXPR evaluates to"))
- (display (G_ "
- -s, --system=SYSTEM consider the graph for SYSTEM--e.g., \"i686-linux\""))
(newline)
(display (G_ "
-L, --load-path=DIR prepend DIR to the package module search path"))
@@ -553,6 +550,8 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
(display (G_ "
-V, --version display version information and exit"))
(newline)
+ (show-native-build-options-help)
+ (newline)
(show-bug-report-information))
(define %default-options
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 32f0d3abb1..d3ee69840c 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -1244,17 +1244,9 @@ last resort for relocation."
(option '(#\m "manifest") #t #f
(lambda (opt name arg result)
(alist-cons 'manifest arg result)))
- (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg
- (alist-delete 'system result eq?))))
(option '("entry-point") #t #f
(lambda (opt name arg result)
(alist-cons 'entry-point arg result)))
- (option '("target") #t #f
- (lambda (opt name arg result)
- (alist-cons 'target arg
- (alist-delete 'target result eq?))))
(option '(#\C "compression") #t #f
(lambda (opt name arg result)
(alist-cons 'compressor (lookup-compressor arg)
@@ -1305,13 +1297,19 @@ last resort for relocation."
(append %deb-format-options
%transformation-options
- %standard-build-options)))
+ %standard-build-options
+ %standard-cross-build-options
+ %standard-native-build-options)))
(define (show-help)
(display (G_ "Usage: guix pack [OPTION]... PACKAGE...
Create a bundle of PACKAGE.\n"))
(show-build-options-help)
(newline)
+ (show-cross-build-options-help)
+ (newline)
+ (show-native-build-options-help)
+ (newline)
(show-transformation-options-help)
(newline)
(show-deb-format-options)
@@ -1325,10 +1323,6 @@ Create a bundle of PACKAGE.\n"))
(display (G_ "
-e, --expression=EXPR consider the package EXPR evaluates to"))
(display (G_ "
- -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
- (display (G_ "
- --target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
- (display (G_ "
-C, --compression=TOOL compress using TOOL--e.g., \"lzip\""))
(display (G_ "
-S, --symlink=SPEC create symlinks to the profile according to SPEC"))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 8eb9b31288..f01764637b 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -117,11 +117,12 @@ Download and deploy the latest version of Guix.\n"))
(display (G_ "
-v, --verbosity=LEVEL use the given verbosity LEVEL"))
(display (G_ "
- -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
- (display (G_ "
--bootstrap use the bootstrap Guile to build the new Guix"))
(newline)
(show-build-options-help)
+ (newline)
+ (show-native-build-options-help)
+ (newline)
(display (G_ "
-h, --help display this help and exit"))
(display (G_ "
@@ -182,10 +183,6 @@ Download and deploy the latest version of Guix.\n"))
(lambda (opt name arg result)
(alist-cons 'profile (canonicalize-profile arg)
result)))
- (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg
- (alist-delete 'system result eq?))))
(option '(#\n "dry-run") #f #f
(lambda (opt name arg result)
(alist-cons 'dry-run? #t result)))
@@ -206,7 +203,8 @@ Download and deploy the latest version of Guix.\n"))
(lambda args
(show-version-and-exit "guix pull")))
- %standard-build-options))
+ (append %standard-build-options
+ %standard-native-build-options)))
(define (warn-about-backward-updates channel start commit relation)
"Warn about non-forward updates of CHANNEL from START to COMMIT, without
diff --git a/guix/scripts/size.scm b/guix/scripts/size.scm
index e46983382a..5bb970443c 100644
--- a/guix/scripts/size.scm
+++ b/guix/scripts/size.scm
@@ -235,8 +235,6 @@ Report the size of the PACKAGE or STORE-ITEM, with its dependencies.\n"))
(display (G_ "
--substitute-urls=URLS
fetch substitute from URLS if they are authorized"))
- (display (G_ "
- -s, --system=SYSTEM consider packages for SYSTEM--e.g., \"i686-linux\""))
;; TRANSLATORS: "closure" and "self" must not be translated.
(display (G_ "
--sort=KEY sort according to KEY--\"closure\" or \"self\""))
@@ -251,15 +249,13 @@ Report the size of the PACKAGE or STORE-ITEM, with its dependencies.\n"))
(display (G_ "
-V, --version display version information and exit"))
(newline)
+ (show-native-build-options-help)
+ (newline)
(show-bug-report-information))
(define %options
;; Specifications of the command-line options.
- (list (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg
- (alist-delete 'system result eq?))))
- (option '("substitute-urls") #t #f
+ (cons* (option '("substitute-urls") #t #f
(lambda (opt name arg result . rest)
(apply values
(alist-cons 'substitute-urls
@@ -287,7 +283,8 @@ Report the size of the PACKAGE or STORE-ITEM, with its dependencies.\n"))
(exit 0)))
(option '(#\V "version") #f #f
(lambda args
- (show-version-and-exit "guix size")))))
+ (show-version-and-exit "guix size")))
+ %standard-native-build-options))
(define %default-options
`((system . ,(%current-system))
diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm
index adba614b8c..b7d8165262 100644
--- a/guix/scripts/weather.scm
+++ b/guix/scripts/weather.scm
@@ -40,6 +40,7 @@
#:use-module (guix ci)
#:use-module (guix sets)
#:use-module (guix graph)
+ #:use-module (guix scripts build)
#:autoload (guix scripts graph) (%bag-node-type)
#:use-module (gnu packages)
#:use-module (web uri)
@@ -339,18 +340,18 @@ Report the availability of substitutes.\n"))
COUNT dependents"))
(display (G_ "
--display-missing display the list of missing substitutes"))
- (display (G_ "
- -s, --system=SYSTEM consider substitutes for SYSTEM--e.g., \"i686-linux\""))
(newline)
(display (G_ "
-h, --help display this help and exit"))
(display (G_ "
-V, --version display version information and exit"))
(newline)
+ (show-native-build-options-help)
+ (newline)
(show-bug-report-information))
(define %options
- (list (option '(#\h "help") #f #f
+ (cons* (option '(#\h "help") #f #f
(lambda args
(show-help)
(exit 0)))
@@ -380,9 +381,7 @@ Report the availability of substitutes.\n"))
(option '("display-missing") #f #f
(lambda (opt name arg result)
(alist-cons 'display-missing? #t result)))
- (option '(#\s "system") #t #f
- (lambda (opt name arg result)
- (alist-cons 'system arg result)))))
+ %standard-native-build-options))
(define %default-options
`((substitute-urls . ,%default-substitute-urls)))