Commit | Line | Data |
---|---|---|
a677c726 RW |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net> | |
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/>. | |
18 | ||
19 | (define-module (guix build-system waf) | |
20 | #:use-module (guix store) | |
21 | #:use-module (guix utils) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix derivations) | |
e89431bf | 24 | #:use-module (guix search-paths) |
a677c726 RW |
25 | #:use-module (guix build-system) |
26 | #:use-module (guix build-system gnu) | |
27 | #:use-module ((guix build-system python) | |
28 | #:select (default-python default-python2)) | |
29 | #:use-module (ice-9 match) | |
30 | #:use-module (srfi srfi-26) | |
bb42c78a LC |
31 | #:export (%waf-build-system-modules |
32 | waf-build | |
a677c726 RW |
33 | waf-build-system)) |
34 | ||
35 | ;; Commentary: | |
36 | ;; | |
37 | ;; Standard build procedure for applications using 'waf'. This is very | |
38 | ;; similar to the 'python-build-system' and is implemented as an extension of | |
39 | ;; 'gnu-build-system'. | |
40 | ;; | |
41 | ;; Code: | |
42 | ||
bb42c78a LC |
43 | (define %waf-build-system-modules |
44 | ;; Build-side modules imported by default. | |
45 | `((guix build waf-build-system) | |
46 | ,@%gnu-build-system-modules)) | |
47 | ||
a677c726 RW |
48 | (define* (lower name |
49 | #:key source inputs native-inputs outputs system target | |
50 | (python (default-python)) | |
51 | #:allow-other-keys | |
52 | #:rest arguments) | |
53 | "Return a bag for NAME." | |
54 | (define private-keywords | |
55 | '(#:source #:target #:python #:inputs #:native-inputs)) | |
56 | ||
57 | (and (not target) ;XXX: no cross-compilation | |
58 | (bag | |
59 | (name name) | |
60 | (system system) | |
61 | (host-inputs `(,@(if source | |
62 | `(("source" ,source)) | |
63 | '()) | |
64 | ,@inputs | |
65 | ||
66 | ;; Keep the standard inputs of 'gnu-build-system'. | |
67 | ,@(standard-packages))) | |
68 | (build-inputs `(("python" ,python) | |
69 | ,@native-inputs)) | |
70 | (outputs outputs) | |
71 | (build waf-build) ; only change compared to 'lower' in python.scm | |
72 | (arguments (strip-keyword-arguments private-keywords arguments))))) | |
73 | ||
74 | (define* (waf-build store name inputs | |
75 | #:key | |
76 | (tests? #t) | |
77 | (test-target "check") | |
78 | (configure-flags ''()) | |
79 | (phases '(@ (guix build waf-build-system) | |
80 | %standard-phases)) | |
81 | (outputs '("out")) | |
82 | (search-paths '()) | |
83 | (system (%current-system)) | |
84 | (guile #f) | |
bb42c78a | 85 | (imported-modules %waf-build-system-modules) |
a677c726 RW |
86 | (modules '((guix build waf-build-system) |
87 | (guix build utils)))) | |
88 | "Build SOURCE with INPUTS. This assumes that SOURCE provides a 'waf' file | |
89 | as its build system." | |
90 | (define builder | |
91 | `(begin | |
92 | (use-modules ,@modules) | |
93 | (waf-build #:name ,name | |
94 | #:source ,(match (assoc-ref inputs "source") | |
95 | (((? derivation? source)) | |
96 | (derivation->output-path source)) | |
97 | ((source) | |
98 | source) | |
99 | (source | |
100 | source)) | |
101 | #:configure-flags ,configure-flags | |
102 | #:system ,system | |
103 | #:test-target ,test-target | |
104 | #:tests? ,tests? | |
105 | #:phases ,phases | |
106 | #:outputs %outputs | |
107 | #:search-paths ',(map search-path-specification->sexp | |
108 | search-paths) | |
109 | #:inputs %build-inputs))) | |
110 | ||
111 | (define guile-for-build | |
112 | (match guile | |
113 | ((? package?) | |
114 | (package-derivation store guile system #:graft? #f)) | |
115 | (#f ; the default | |
116 | (let* ((distro (resolve-interface '(gnu packages commencement))) | |
117 | (guile (module-ref distro 'guile-final))) | |
118 | (package-derivation store guile system #:graft? #f))))) | |
119 | ||
120 | (build-expression->derivation store name builder | |
121 | #:inputs inputs | |
122 | #:system system | |
123 | #:modules imported-modules | |
124 | #:outputs outputs | |
125 | #:guile-for-build guile-for-build)) | |
126 | ||
127 | (define waf-build-system | |
128 | (build-system | |
129 | (name 'waf) | |
130 | (description "The standard waf build system") | |
131 | (lower lower))) | |
132 | ||
133 | ;;; waf.scm ends here |