Commit | Line | Data |
---|---|---|
a677c726 | 1 | ;;; GNU Guix --- Functional package management for GNU |
b194da0d | 2 | ;;; Copyright © 2015, 2018 Ricardo Wurmus <rekado@elephly.net> |
a677c726 RW |
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 waf-build-system) | |
20 | #:use-module ((guix build gnu-build-system) #:prefix gnu:) | |
21 | #:use-module (guix build utils) | |
22 | #:use-module (ice-9 match) | |
23 | #:use-module (ice-9 ftw) | |
24 | #:use-module (srfi srfi-1) | |
25 | #:use-module (srfi srfi-26) | |
26 | #:export (%standard-phases | |
27 | waf-build)) | |
28 | ||
29 | ;; Commentary: | |
30 | ;; | |
31 | ;; Builder-side code of the standard waf build procedure. | |
32 | ;; | |
33 | ;; Code: | |
34 | ||
35 | ||
36 | (define (call-waf command params) | |
37 | (if (file-exists? "waf") | |
38 | (begin | |
39 | (format #t "running \"python waf\" with command ~s and parameters ~s~%" | |
40 | command params) | |
b194da0d RW |
41 | (apply invoke "python" "waf" command params) |
42 | #t) | |
a677c726 RW |
43 | (error "no waf found"))) |
44 | ||
45 | (define* (configure #:key target native-inputs inputs outputs | |
46 | (configure-flags '()) | |
47 | #:allow-other-keys) | |
48 | "Build a given waf application." | |
49 | (let* ((prefix (assoc-ref outputs "out")) | |
50 | (flags `(,(string-append "--prefix=" prefix) | |
51 | ,@configure-flags))) | |
52 | (call-waf "configure" flags))) | |
53 | ||
54 | (define* (build #:rest empty) | |
55 | "Build a given waf application." | |
56 | (call-waf "build" '())) | |
57 | ||
58 | (define* (check #:key tests? test-target #:allow-other-keys) | |
59 | "Run the test suite of a given waf application." | |
60 | (if tests? | |
61 | (call-waf test-target '()) | |
62 | #t)) | |
63 | ||
64 | (define* (install #:key outputs inputs (configure-flags '()) | |
65 | #:allow-other-keys) | |
66 | "Install a given waf application." | |
67 | (let* ((out (assoc-ref outputs "out")) | |
68 | (params (append (list (string-append "--prefix=" out)) | |
69 | configure-flags))) | |
70 | (call-waf "install" params))) | |
71 | ||
72 | (define %standard-phases | |
f84218ac | 73 | (modify-phases gnu:%standard-phases |
189be331 | 74 | (delete 'bootstrap) |
f8503e2b LC |
75 | (replace 'configure configure) |
76 | (replace 'build build) | |
77 | (replace 'check check) | |
78 | (replace 'install install))) | |
a677c726 RW |
79 | |
80 | (define* (waf-build #:key inputs (phases %standard-phases) | |
81 | #:allow-other-keys #:rest args) | |
82 | "Build the given waf application, applying all of PHASES in order." | |
83 | (apply gnu:gnu-build #:inputs inputs #:phases phases args)) | |
84 | ||
85 | ;;; waf-build-system.scm ends here |