waf-build-system.scm 2.9 KB

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