waf.scm 4.5 KB

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