julia.scm 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019 Nicolò Balzarotti <nicolo@nixo.xyz>
  3. ;;; Copyright © 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 julia)
  20. #:use-module (guix store)
  21. #:use-module (guix utils)
  22. #:use-module (guix packages)
  23. #:use-module (guix gexp)
  24. #:use-module (guix monads)
  25. #:use-module (guix search-paths)
  26. #:use-module (guix build-system)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (ice-9 match)
  29. #:use-module (srfi srfi-26)
  30. #:export (%julia-build-system-modules
  31. julia-build
  32. julia-build-system))
  33. ;; Commentary:
  34. ;;
  35. ;; Standard build procedure for Julia packages.
  36. ;;
  37. ;; Code:
  38. (define %julia-build-system-modules
  39. ;; Build-side modules imported by default.
  40. `((guix build julia-build-system)
  41. ,@%gnu-build-system-modules))
  42. (define (default-julia)
  43. "Return the default Julia package."
  44. ;; Lazily resolve the binding to avoid a circular dependency.
  45. (let ((julia-mod (resolve-interface '(gnu packages julia))))
  46. (module-ref julia-mod 'julia)))
  47. (define* (lower name
  48. #:key source inputs native-inputs outputs system target
  49. (julia (default-julia))
  50. #:allow-other-keys
  51. #:rest arguments)
  52. "Return a bag for NAME."
  53. (define private-keywords
  54. '(#:target #:julia #:inputs #:native-inputs))
  55. (and (not target) ;XXX: no cross-compilation
  56. (bag
  57. (name name)
  58. (system system)
  59. (host-inputs `(,@(if source
  60. `(("source" ,source))
  61. '())
  62. ,@inputs
  63. ;; Keep the standard inputs of 'gnu-build-system'.
  64. ,@(standard-packages)))
  65. (build-inputs `(("julia" ,julia)
  66. ,@native-inputs))
  67. (outputs outputs)
  68. (build julia-build)
  69. (arguments (strip-keyword-arguments private-keywords arguments)))))
  70. (define* (julia-build name inputs
  71. #:key source
  72. (tests? #t)
  73. (phases '%standard-phases)
  74. (outputs '("out"))
  75. (search-paths '())
  76. (system (%current-system))
  77. (guile #f)
  78. (julia-package-name #f)
  79. (imported-modules %julia-build-system-modules)
  80. (modules '((guix build julia-build-system)
  81. (guix build utils))))
  82. "Build SOURCE using Julia, and with INPUTS."
  83. (define builder
  84. (with-imported-modules imported-modules
  85. #~(begin
  86. (use-modules #$@(sexp->gexp modules))
  87. (julia-build #:name #$name
  88. #:source #+source
  89. #:system #$system
  90. #:tests? #$tests?
  91. #:phases #$phases
  92. #:outputs #$(outputs->gexp outputs)
  93. #:search-paths '#$(sexp->gexp
  94. (map search-path-specification->sexp
  95. search-paths))
  96. #:inputs #$(input-tuples->gexp inputs)
  97. #:julia-package-name #$julia-package-name))))
  98. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  99. system #:graft? #f)))
  100. (gexp->derivation name builder
  101. #:system system
  102. #:guile-for-build guile)))
  103. (define julia-build-system
  104. (build-system
  105. (name 'julia)
  106. (description "The build system for Julia packages")
  107. (lower lower)))
  108. ;;; julia.scm ends here