summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/guix.texi4
-rw-r--r--guix/scripts/build.scm107
-rw-r--r--tests/guix-build.sh7
3 files changed, 70 insertions, 48 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 6b713aaf9c8..8c7522f286b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8030,7 +8030,9 @@ The following derivations will be built:
8030@item --system=@var{system} 8030@item --system=@var{system}
8031@itemx -s @var{system} 8031@itemx -s @var{system}
8032Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of 8032Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
8033the system type of the build host. 8033the system type of the build host. The @command{guix build} command allows
8034you to repeat this option several times, in which case it builds for all the
8035specified systems; other commands ignore extraneous @option{-s} options.
8034 8036
8035@quotation Note 8037@quotation Note
8036The @code{--system} flag is for @emph{native} compilation and must not 8038The @code{--system} flag is for @emph{native} compilation and must not
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index fc0c0e2ad36..ba143ad16bf 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -635,8 +635,7 @@ options handled by 'set-build-options-from-command-line', and listed in
635 635
636(define %default-options 636(define %default-options
637 ;; Alist of default option values. 637 ;; Alist of default option values.
638 `((system . ,(%current-system)) 638 `((build-mode . ,(build-mode normal))
639 (build-mode . ,(build-mode normal))
640 (graft? . #t) 639 (graft? . #t)
641 (substitutes? . #t) 640 (substitutes? . #t)
642 (build-hook? . #t) 641 (build-hook? . #t)
@@ -729,8 +728,7 @@ must be one of 'package', 'all', or 'transitive'~%")
729 rest))) 728 rest)))
730 (option '(#\s "system") #t #f 729 (option '(#\s "system") #t #f
731 (lambda (opt name arg result) 730 (lambda (opt name arg result)
732 (alist-cons 'system arg 731 (alist-cons 'system arg result)))
733 (alist-delete 'system result eq?))))
734 (option '("target") #t #f 732 (option '("target") #t #f
735 (lambda (opt name arg result) 733 (lambda (opt name arg result)
736 (alist-cons 'target arg 734 (alist-cons 'target arg
@@ -811,56 +809,71 @@ build."
811 (cut package-cross-derivation <> <> triplet <>)))) 809 (cut package-cross-derivation <> <> triplet <>))))
812 810
813 (define src (assoc-ref opts 'source)) 811 (define src (assoc-ref opts 'source))
814 (define system (assoc-ref opts 'system))
815 (define graft? (assoc-ref opts 'graft?)) 812 (define graft? (assoc-ref opts 'graft?))
813 (define systems
814 (match (filter-map (match-lambda
815 (('system . system) system)
816 (_ #f))
817 opts)
818 (() (list (%current-system)))
819 (systems systems)))
820
821 (define things-to-build
822 (map (cut transform store <>)
823 (options->things-to-build opts)))
824
825 (define (compute-derivation obj system)
826 ;; Compute the derivation of OBJ for SYSTEM.
827 (match obj
828 ((? package? p)
829 (let ((p (or (and graft? (package-replacement p)) p)))
830 (match src
831 (#f
832 (list (package->derivation store p system)))
833 (#t
834 (match (package-source p)
835 (#f
836 (format (current-error-port)
837 (G_ "~a: warning: \
838package '~a' has no source~%")
839 (location->string (package-location p))
840 (package-name p))
841 '())
842 (s
843 (list (package-source-derivation store s)))))
844 (proc
845 (map (cut package-source-derivation store <>)
846 (proc p))))))
847 ((? derivation? drv)
848 (list drv))
849 ((? procedure? proc)
850 (list (run-with-store store
851 (mbegin %store-monad
852 (set-guile-for-build (default-guile))
853 (proc))
854 #:system system)))
855 ((? file-like? obj)
856 (list (run-with-store store
857 (lower-object obj system
858 #:target (assoc-ref opts 'target))
859 #:system system)))
860 ((? gexp? gexp)
861 (list (run-with-store store
862 (mbegin %store-monad
863 (set-guile-for-build (default-guile))
864 (gexp->derivation "gexp" gexp
865 #:system system))
866 #:system system)))))
816 867
817 ;; We may get 'unbound-variable' errors while evaluating the 'inputs' fields 868 ;; We may get 'unbound-variable' errors while evaluating the 'inputs' fields
818 ;; of user packages. Since 'guix build' is the primary tool for people 869 ;; of user packages. Since 'guix build' is the primary tool for people
819 ;; testing new packages, report such errors gracefully. 870 ;; testing new packages, report such errors gracefully.
820 (with-unbound-variable-handling 871 (with-unbound-variable-handling
821 (parameterize ((%graft? graft?)) 872 (parameterize ((%graft? graft?))
822 (append-map (match-lambda 873 (append-map (lambda (system)
823 ((? package? p) 874 (append-map (cut compute-derivation <> system)
824 (let ((p (or (and graft? (package-replacement p)) p))) 875 things-to-build))
825 (match src 876 systems))))
826 (#f
827 (list (package->derivation store p system)))
828 (#t
829 (match (package-source p)
830 (#f
831 (format (current-error-port)
832 (G_ "~a: warning: \
833package '~a' has no source~%")
834 (location->string (package-location p))
835 (package-name p))
836 '())
837 (s
838 (list (package-source-derivation store s)))))
839 (proc
840 (map (cut package-source-derivation store <>)
841 (proc p))))))
842 ((? derivation? drv)
843 (list drv))
844 ((? procedure? proc)
845 (list (run-with-store store
846 (mbegin %store-monad
847 (set-guile-for-build (default-guile))
848 (proc))
849 #:system system)))
850 ((? file-like? obj)
851 (list (run-with-store store
852 (lower-object obj system
853 #:target (assoc-ref opts 'target))
854 #:system system)))
855 ((? gexp? gexp)
856 (list (run-with-store store
857 (mbegin %store-monad
858 (set-guile-for-build (default-guile))
859 (gexp->derivation "gexp" gexp
860 #:system system))
861 #:system system))))
862 (map (cut transform store <>)
863 (options->things-to-build opts))))))
864 877
865(define (show-build-log store file urls) 878(define (show-build-log store file urls)
866 "Show the build log for FILE, falling back to remote logs from URLS if 879 "Show the build log for FILE, falling back to remote logs from URLS if
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index d479296ef1e..63a9fe68dab 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -44,6 +44,13 @@ guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
44 guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'; \ 44 guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'; \
45 then exit 1; fi ) 45 then exit 1; fi )
46 46
47# Passing one '-s' flag.
48test `guix build sed -s x86_64-linux -d | wc -l` = 1
49
50# Passing multiple '-s' flags.
51all_systems="-s x86_64-linux -s i686-linux -s armhf-linux -s aarch64-linux"
52test `guix build sed $all_systems -d | sort -u | wc -l` = 4
53
47# Check --sources option with its arguments 54# Check --sources option with its arguments
48module_dir="t-guix-build-$$" 55module_dir="t-guix-build-$$"
49mkdir "$module_dir" 56mkdir "$module_dir"