gnu: picard: Return #t from phases.
[guix.git] / guix / build-system.scm
blob4174972b9849b2ff10e866375fe84f627a018c00
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
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 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
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
17 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix build-system)
20   #:use-module (guix records)
21   #:use-module (ice-9 match)
22   #:export (build-system
23             build-system?
24             build-system-name
25             build-system-description
26             build-system-lower
28             bag
29             bag?
30             bag-name
31             bag-system
32             bag-target
33             bag-build-inputs
34             bag-host-inputs
35             bag-target-inputs
36             bag-outputs
37             bag-arguments
38             bag-build
40             make-bag))
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
46   (lower       build-system-lower))       ; args ... -> bags
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.
51 (define-record-type* <bag> bag %make-bag
52   bag?
53   (name          bag-name)               ;string
55   (system        bag-system)             ;string
56   (target        bag-target              ;string | #f
57                  (default #f))
59   ;; Here we use build/host/target in the sense of the GNU tool chain (info
60   ;; "(autoconf) Specifying Target Triplets").
61   (build-inputs  bag-build-inputs        ;list of packages
62                  (default '()))
63   (host-inputs   bag-host-inputs         ;list of packages
64                  (default '()))
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 '()))
75   (outputs       bag-outputs             ;list of strings
76                  (default '("out")))
77   (arguments     bag-arguments           ;list
78                  (default '()))
79   (build         bag-build))             ;bag -> derivation
81 (define* (make-bag build-system name
82                    #:key source (inputs '()) (native-inputs '())
83                    (outputs '()) (arguments '())
84                    system target)
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.
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
94             #:system system
95             #:source source
96             #:inputs inputs
97             #:native-inputs native-inputs
98             #:outputs outputs
99             #:target target
100             arguments))))