Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
0d5a559f | 2 | ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
208f7cd1 | 3 | ;;; |
233e7676 | 4 | ;;; This file is part of GNU Guix. |
208f7cd1 | 5 | ;;; |
233e7676 | 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
208f7cd1 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 |
208f7cd1 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/>. |
208f7cd1 LC |
18 | |
19 | (define-module (guix build-system) | |
c0cd1b3e | 20 | #:use-module (guix records) |
0d5a559f | 21 | #:use-module (ice-9 match) |
208f7cd1 LC |
22 | #:export (build-system |
23 | build-system? | |
24 | build-system-name | |
25 | build-system-description | |
0d5a559f LC |
26 | build-system-lower |
27 | ||
28 | bag | |
29 | bag? | |
30 | bag-name | |
d3d337d2 LC |
31 | bag-system |
32 | bag-target | |
0d5a559f LC |
33 | bag-build-inputs |
34 | bag-host-inputs | |
35 | bag-target-inputs | |
36 | bag-outputs | |
37 | bag-arguments | |
38 | bag-build | |
39 | ||
40 | make-bag)) | |
208f7cd1 LC |
41 | |
42 | (define-record-type* <build-system> build-system make-build-system | |
43 | build-system? | |
44 | (name build-system-name) ; symbol | |
45 | (description build-system-description) ; short description | |
0d5a559f LC |
46 | (lower build-system-lower)) ; args ... -> bags |
47 | ||
d3d337d2 LC |
48 | ;; "Bags" are low-level representations of "packages". The system and target |
49 | ;; of a bag is fixed when it's created. This is because build systems may | |
50 | ;; choose inputs as a function of the system and target. | |
0d5a559f LC |
51 | (define-record-type* <bag> bag %make-bag |
52 | bag? | |
53 | (name bag-name) ;string | |
d3d337d2 LC |
54 | |
55 | (system bag-system) ;string | |
56 | (target bag-target ;string | #f | |
57 | (default #f)) | |
58 | ||
59 | ;; Here we use build/host/target in the sense of the GNU tool chain (info | |
60 | ;; "(autoconf) Specifying Target Triplets"). | |
0d5a559f LC |
61 | (build-inputs bag-build-inputs ;list of packages |
62 | (default '())) | |
63 | (host-inputs bag-host-inputs ;list of packages | |
64 | (default '())) | |
65 | ||
66 | ;; "Target inputs" are packages that are built natively, but that are used | |
67 | ;; by target programs in a cross-compilation environment. Thus, they act | |
68 | ;; like 'inputs' as far as search paths are concerned. The only example of | |
69 | ;; that is the cross-libc: it is an input of 'cross-gcc', thus built | |
70 | ;; natively; yet, we want it to be considered as a target input for the | |
71 | ;; purposes of $CPATH, $LIBRARY_PATH, etc. | |
72 | (target-inputs bag-target-inputs | |
73 | (default '())) | |
74 | ||
75 | (outputs bag-outputs ;list of strings | |
76 | (default '("out"))) | |
77 | (arguments bag-arguments ;list | |
78 | (default '())) | |
79 | (build bag-build)) ;bag -> derivation | |
80 | ||
81 | (define* (make-bag build-system name | |
82 | #:key source (inputs '()) (native-inputs '()) | |
83 | (outputs '()) (arguments '()) | |
d3d337d2 | 84 | system target) |
0d5a559f LC |
85 | "Ask BUILD-SYSTEM to return a 'bag' for NAME, with the given SOURCE, |
86 | INPUTS, NATIVE-INPUTS, OUTPUTS, and additional ARGUMENTS. If TARGET is not | |
87 | #f, it must be a string with the GNU triplet of a cross-compilation target. | |
88 | ||
89 | This is the mechanism by which a package is \"lowered\" to a bag, which is the | |
90 | intermediate representation just above derivations." | |
91 | (match build-system | |
92 | (($ <build-system> _ description lower) | |
93 | (apply lower name | |
d3d337d2 | 94 | #:system system |
0d5a559f LC |
95 | #:source source |
96 | #:inputs inputs | |
97 | #:native-inputs native-inputs | |
98 | #:outputs outputs | |
99 | #:target target | |
100 | arguments)))) |