waf.scm 5.0 KB

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