waf.scm 4.5 KB

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