build: Add missing import in `hydra.scm'.
[jackhill/guix/guix.git] / hydra.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
0b5aa854 2;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
8c0e5b1e 3;;;
233e7676 4;;; This file is part of GNU Guix.
8c0e5b1e 5;;;
233e7676 6;;; GNU Guix is free software; you can redistribute it and/or modify it
8c0e5b1e
LC
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
233e7676 11;;; GNU Guix is distributed in the hope that it will be useful, but
8c0e5b1e
LC
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
233e7676 17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
8c0e5b1e
LC
18
19;;;
20;;; This file defines build jobs for the Hydra continuation integration
21;;; tool.
22;;;
23
0b5aa854
LC
24;; Attempt to use our very own Guix modules.
25(eval-when (compile load eval)
bb90ad83
LC
26
27 ;; Ignore any available .go, and force recompilation. This is because our
28 ;; checkout in the store has mtime set to the epoch, and thus .go files look
29 ;; newer, even though they may not correspond.
30 (set! %fresh-auto-compile #t)
31
0b5aa854
LC
32 (and=> (assoc-ref (current-source-location) 'filename)
33 (lambda (file)
34 (let ((dir (dirname file)))
35 (format (current-error-port) "prepending ~s to the load path~%"
36 dir)
37 (set! %load-path (cons dir %load-path))))))
38
8c0e5b1e
LC
39(use-modules (guix store)
40 (guix packages)
dce3a40b 41 ((guix utils) #:select (%current-system))
59a43334 42 (gnu packages)
1ffa7090 43 (gnu packages base)
923fbae1 44 (gnu packages gawk)
1ffa7090 45 (gnu packages guile)
929c0f69
LC
46 (gnu packages multiprecision)
47 (gnu packages make-bootstrap)
bdd7eb27 48 (srfi srfi-1)
dce3a40b 49 (srfi srfi-26)
8c0e5b1e
LC
50 (ice-9 match))
51
dce3a40b
LC
52;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
53;; port to the bit bucket, let us write to the error port instead.
54(setvbuf (current-error-port) _IOLBF)
55(set-current-output-port (current-error-port))
56
929c0f69
LC
57(define* (package->alist store package system
58 #:optional (package-derivation package-derivation))
8c0e5b1e
LC
59 "Convert PACKAGE to an alist suitable for Hydra."
60 `((derivation . ,(package-derivation store package system))
61 (description . ,(package-synopsis package))
62 (long-description . ,(package-description package))
63 (license . ,(package-license package))
bdd7eb27
LC
64 (home-page . ,(package-home-page package))
65 (maintainers . ("bug-guix@gnu.org"))))
8c0e5b1e
LC
66
67(define (package-job store job-name package system)
68 "Return a job called JOB-NAME that builds PACKAGE on SYSTEM."
dce3a40b 69 `(,job-name . ,(cut package->alist store package system)))
8c0e5b1e 70
929c0f69
LC
71(define (package-cross-job store job-name package target system)
72 "Return a job called TARGET.JOB-NAME that cross-builds PACKAGE for TARGET on
73SYSTEM."
74 `(,(symbol-append (string->symbol target) (string->symbol ".") job-name) .
75 ,(cute package->alist store package system
76 (cut package-cross-derivation <> <> target <>))))
77
78(define %packages-to-cross-build
598608c7
LC
79 (list gmp mpfr mpc coreutils findutils diffutils patch sed grep
80 gawk gettext hello guile-2.0
2ee5f56b
LC
81 ;; %bootstrap-binaries-tarball
82 ;; %binutils-bootstrap-tarball
83 ;; %glibc-bootstrap-tarball
84 ;; %gcc-bootstrap-tarball
85 ;; %guile-bootstrap-tarball
86 ))
929c0f69
LC
87
88(define %cross-targets
89 '("mips64el-linux-gnu"))
90
8c0e5b1e
LC
91(define (hydra-jobs store arguments)
92 "Return Hydra jobs."
93 (define system
dce3a40b
LC
94 (or (assoc-ref arguments system)
95 (%current-system)))
8c0e5b1e 96
929c0f69
LC
97 (define job-name
98 (compose string->symbol package-full-name))
99
100 (define cross-jobs
101 (append-map (lambda (target)
102 (map (lambda (package)
103 (package-cross-job store (job-name package)
104 package target system))
105 %packages-to-cross-build))
106 %cross-targets))
107
bdd7eb27
LC
108 ;; Return one job for each package, except bootstrap packages.
109 (let ((base-packages (delete-duplicates
110 (append-map (match-lambda
111 ((_ package _ ...)
112 (match (package-transitive-inputs
113 package)
114 (((_ inputs _ ...) ...)
115 inputs))))
116 %final-inputs))))
117 (fold-packages (lambda (package result)
118 (if (member package base-packages)
119 result
929c0f69
LC
120 (cons (package-job store (job-name package)
121 package system)
122 result)))
123 cross-jobs)))