packages: 'package-grafts' trims native inputs.
[guix.git] / guix / build / waf-build-system.scm
blob85f0abcfd6262eb971ae9b2fe287b4dc38774d80
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/>.
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))
29 ;; Commentary:
31 ;; Builder-side code of the standard waf build procedure.
33 ;; Code:
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)
41          (zero? (apply system* "python" "waf" command params)))
42       (error "no waf found")))
44 (define* (configure #:key target native-inputs inputs outputs
45                     (configure-flags '())
46                     #:allow-other-keys)
47   "Build a given waf application."
48   (let* ((prefix (assoc-ref outputs "out"))
49          (flags  `(,(string-append "--prefix=" prefix)
50                    ,@configure-flags)))
51     (call-waf "configure" flags)))
53 (define* (build #:rest empty)
54   "Build a given waf application."
55   (call-waf "build" '()))
57 (define* (check #:key tests? test-target #:allow-other-keys)
58   "Run the test suite of a given waf application."
59   (if tests?
60     (call-waf test-target '())
61     #t))
63 (define* (install #:key outputs inputs (configure-flags '())
64                   #:allow-other-keys)
65   "Install a given waf application."
66   (let* ((out (assoc-ref outputs "out"))
67          (params (append (list (string-append "--prefix=" out))
68                          configure-flags)))
69         (call-waf "install" params)))
71 (define %standard-phases
72   (modify-phases gnu:%standard-phases
73     (replace 'configure configure)
74     (replace 'build build)
75     (replace 'check check)
76     (replace 'install install)))
78 (define* (waf-build #:key inputs (phases %standard-phases)
79                        #:allow-other-keys #:rest args)
80   "Build the given waf application, applying all of PHASES in order."
81   (apply gnu:gnu-build #:inputs inputs #:phases phases args))
83 ;;; waf-build-system.scm ends here