clojure.scm 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
  3. ;;; Copyright © 2020, 2021 Ludovic Courtès <ludo@gnu.org>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (guix build-system clojure)
  20. #:use-module (guix build clojure-utils)
  21. #:use-module (guix build-system)
  22. #:use-module (guix build-system ant)
  23. #:use-module ((guix build-system gnu)
  24. #:select (standard-packages)
  25. #:prefix gnu:)
  26. #:use-module (guix gexp)
  27. #:use-module (guix store)
  28. #:use-module (guix monads)
  29. #:use-module (guix packages)
  30. #:use-module ((guix search-paths)
  31. #:select
  32. ((search-path-specification->sexp . search-path-spec->sexp)))
  33. #:use-module (guix utils)
  34. #:use-module (ice-9 match)
  35. #:export (%clojure-build-system-modules
  36. clojure-build
  37. clojure-build-system))
  38. ;; Commentary:
  39. ;;
  40. ;; Standard build procedure for Clojure packages.
  41. ;;
  42. ;; Code:
  43. (define-with-docs %clojure-build-system-modules
  44. "Build-side modules imported by default."
  45. `((guix build clojure-build-system)
  46. (guix build clojure-utils)
  47. (guix build guile-build-system)
  48. ,@%ant-build-system-modules))
  49. (define %default-modules
  50. ;; Modules in scope in the build-side environment.
  51. '((guix build clojure-build-system)
  52. (guix build clojure-utils)
  53. (guix build utils)))
  54. (define-with-docs %default-clojure
  55. "The default Clojure package."
  56. (delay (@* (gnu packages clojure) clojure)))
  57. (define-with-docs %default-jdk
  58. "The default JDK package."
  59. (delay (@* (gnu packages java) icedtea)))
  60. (define-with-docs %default-zip
  61. "The default ZIP package."
  62. (delay (@* (gnu packages compression) zip)))
  63. (define* (lower name
  64. #:key
  65. source target
  66. inputs native-inputs
  67. (clojure (force %default-clojure))
  68. (jdk (force %default-jdk))
  69. (zip (force %default-zip))
  70. outputs system
  71. #:allow-other-keys
  72. #:rest arguments)
  73. "Return a bag for NAME."
  74. (let ((private-keywords '(#:source #:target
  75. #:inputs #:native-inputs
  76. #:clojure #:jdk #:zip)))
  77. (if target
  78. (error "No cross-compilation for clojure-build-system yet: LOWER"
  79. target) ; FIXME
  80. (bag (name name)
  81. (system system)
  82. (host-inputs `(,@(if source
  83. `(("source" ,source))
  84. '())
  85. ,@inputs
  86. ,@(gnu:standard-packages)))
  87. (build-inputs `(("clojure" ,clojure)
  88. ("jdk" ,jdk "jdk")
  89. ("zip" ,zip)
  90. ,@native-inputs))
  91. (outputs outputs)
  92. (build clojure-build)
  93. (arguments (strip-keyword-arguments private-keywords
  94. arguments))))))
  95. (define* (clojure-build name inputs
  96. #:key
  97. source
  98. (source-dirs `',%source-dirs)
  99. (test-dirs `',%test-dirs)
  100. (compile-dir %compile-dir)
  101. (jar-names `',(package-name->jar-names name))
  102. (main-class %main-class)
  103. (omit-source? %omit-source?)
  104. (aot-include `',%aot-include)
  105. (aot-exclude `',%aot-exclude)
  106. doc-dirs ; no sensible default
  107. (doc-regex %doc-regex)
  108. (tests? %tests?)
  109. (test-include `',%test-include)
  110. (test-exclude `',%test-exclude)
  111. (phases '%standard-phases)
  112. (outputs '("out"))
  113. (search-paths '())
  114. (system (%current-system))
  115. (guile #f)
  116. (imported-modules %clojure-build-system-modules)
  117. (modules %default-modules))
  118. "Build SOURCE with INPUTS."
  119. (define builder
  120. (with-imported-modules imported-modules
  121. #~(begin
  122. (use-modules #$@(sexp->gexp modules))
  123. (clojure-build #:name #$name
  124. #:source #+source
  125. #:source-dirs #$source-dirs
  126. #:test-dirs #$test-dirs
  127. #:compile-dir #$compile-dir
  128. #:jar-names #$jar-names
  129. #:main-class #$main-class
  130. #:omit-source? #$omit-source?
  131. #:aot-include #$aot-include
  132. #:aot-exclude #$aot-exclude
  133. #:doc-dirs #$doc-dirs
  134. #:doc-regex #$doc-regex
  135. #:tests? #$tests?
  136. #:test-include #$test-include
  137. #:test-exclude #$test-exclude
  138. #:phases #$phases
  139. #:outputs #$(outputs->gexp outputs)
  140. #:search-paths '#$(sexp->gexp
  141. (map search-path-spec->sexp
  142. search-paths))
  143. #:system #$system
  144. #:inputs #$(input-tuples->gexp inputs)))))
  145. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  146. system #:graft? #f)))
  147. (gexp->derivation name builder
  148. #:system system
  149. #:guile-for-build guile)))
  150. (define clojure-build-system
  151. (build-system
  152. (name 'clojure)
  153. (description "Simple Clojure build system using plain old 'compile'")
  154. (lower lower)))
  155. ;;; clojure.scm ends here