clojure.scm 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. #:export (%clojure-build-system-modules
  35. clojure-build
  36. clojure-build-system))
  37. ;; Commentary:
  38. ;;
  39. ;; Standard build procedure for Clojure packages.
  40. ;;
  41. ;; Code:
  42. (define-with-docs %clojure-build-system-modules
  43. "Build-side modules imported by default."
  44. `((guix build clojure-build-system)
  45. (guix build clojure-utils)
  46. (guix build guile-build-system)
  47. ,@%ant-build-system-modules))
  48. (define %default-modules
  49. ;; Modules in scope in the build-side environment.
  50. '((guix build clojure-build-system)
  51. (guix build clojure-utils)
  52. (guix build utils)))
  53. (define-with-docs %default-clojure
  54. "The default Clojure package."
  55. (delay (@* (gnu packages clojure) clojure)))
  56. (define-with-docs %default-jdk
  57. "The default JDK package."
  58. (delay (@* (gnu packages java) icedtea)))
  59. (define-with-docs %default-zip
  60. "The default ZIP package."
  61. (delay (@* (gnu packages compression) zip)))
  62. (define* (lower name
  63. #:key
  64. source target
  65. inputs native-inputs
  66. (clojure (force %default-clojure))
  67. (jdk (force %default-jdk))
  68. (zip (force %default-zip))
  69. outputs system
  70. #:allow-other-keys
  71. #:rest arguments)
  72. "Return a bag for NAME."
  73. (let ((private-keywords '(#:target #:inputs #:native-inputs
  74. #:clojure #:jdk #:zip)))
  75. (if target
  76. (error "No cross-compilation for clojure-build-system yet: LOWER"
  77. target) ; FIXME
  78. (bag (name name)
  79. (system system)
  80. (host-inputs `(,@(if source
  81. `(("source" ,source))
  82. '())
  83. ,@inputs
  84. ,@(gnu:standard-packages)))
  85. (build-inputs `(("clojure" ,clojure)
  86. ("jdk" ,jdk "jdk")
  87. ("zip" ,zip)
  88. ,@native-inputs))
  89. (outputs outputs)
  90. (build clojure-build)
  91. (arguments (strip-keyword-arguments private-keywords
  92. arguments))))))
  93. (define* (clojure-build name inputs
  94. #:key
  95. source
  96. (source-dirs `',%source-dirs)
  97. (java-source-dirs `',%java-source-dirs)
  98. (test-dirs `',%test-dirs)
  99. (compile-dir %compile-dir)
  100. (java-compile-dir %java-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. #:java-source-dirs #$java-source-dirs
  127. #:test-dirs #$test-dirs
  128. #:compile-dir #$compile-dir
  129. #:java-compile-dir #$java-compile-dir
  130. #:jar-names #$jar-names
  131. #:main-class #$main-class
  132. #:omit-source? #$omit-source?
  133. #:aot-include #$aot-include
  134. #:aot-exclude #$aot-exclude
  135. #:doc-dirs #$doc-dirs
  136. #:doc-regex #$doc-regex
  137. #:tests? #$tests?
  138. #:test-include #$test-include
  139. #:test-exclude #$test-exclude
  140. #:phases #$phases
  141. #:outputs #$(outputs->gexp outputs)
  142. #:search-paths '#$(sexp->gexp
  143. (map search-path-spec->sexp
  144. search-paths))
  145. #:system #$system
  146. #:inputs #$(input-tuples->gexp inputs)))))
  147. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  148. system #:graft? #f)))
  149. (gexp->derivation name builder
  150. #:system system
  151. #:guile-for-build guile)))
  152. (define clojure-build-system
  153. (build-system
  154. (name 'clojure)
  155. (description "Simple Clojure build system using plain old 'compile'")
  156. (lower lower)))
  157. ;;; clojure.scm ends here