julia.scm 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. ;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
  5. ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (guix build-system julia)
  22. #:use-module (guix store)
  23. #:use-module (guix utils)
  24. #:use-module (guix packages)
  25. #:use-module (guix gexp)
  26. #:use-module (guix monads)
  27. #:use-module (guix search-paths)
  28. #:use-module (guix build-system)
  29. #:use-module (guix build-system gnu)
  30. #:use-module (ice-9 match)
  31. #:use-module (srfi srfi-26)
  32. #:export (%julia-build-system-modules
  33. julia-build
  34. julia-build-system))
  35. ;; Commentary:
  36. ;;
  37. ;; Standard build procedure for Julia packages.
  38. ;;
  39. ;; Code:
  40. (define %julia-build-system-modules
  41. ;; Build-side modules imported by default.
  42. `((guix build julia-build-system)
  43. ,@%gnu-build-system-modules))
  44. (define (default-julia)
  45. "Return the default Julia package."
  46. ;; Lazily resolve the binding to avoid a circular dependency.
  47. (let ((julia-mod (resolve-interface '(gnu packages julia))))
  48. (module-ref julia-mod 'julia)))
  49. (define* (lower name
  50. #:key source inputs native-inputs outputs system target
  51. (julia (default-julia))
  52. #:allow-other-keys
  53. #:rest arguments)
  54. "Return a bag for NAME."
  55. (define private-keywords
  56. '(#:target #:julia #:inputs #:native-inputs))
  57. (and (not target) ;XXX: no cross-compilation
  58. (bag
  59. (name name)
  60. (system system)
  61. (host-inputs `(,@(if source
  62. `(("source" ,source))
  63. '())
  64. ,@inputs
  65. ;; Keep the standard inputs of 'gnu-build-system'.
  66. ,@(standard-packages)))
  67. (build-inputs `(("julia" ,julia)
  68. ,@native-inputs))
  69. (outputs outputs)
  70. (build julia-build)
  71. (arguments (strip-keyword-arguments private-keywords arguments)))))
  72. (define* (julia-build name inputs
  73. #:key source
  74. (tests? #t)
  75. (parallel-tests? #t)
  76. (phases '%standard-phases)
  77. (outputs '("out"))
  78. (search-paths '())
  79. (system (%current-system))
  80. (guile #f)
  81. (julia-package-name #f)
  82. (julia-package-uuid #f)
  83. (imported-modules %julia-build-system-modules)
  84. (modules '((guix build julia-build-system)
  85. (guix build utils))))
  86. "Build SOURCE using Julia, and with INPUTS."
  87. (define builder
  88. (with-imported-modules imported-modules
  89. #~(begin
  90. (use-modules #$@(sexp->gexp modules))
  91. (julia-build #:name #$name
  92. #:source #+source
  93. #:system #$system
  94. #:tests? #$tests?
  95. #:parallel-tests? #$parallel-tests?
  96. #:phases #$phases
  97. #:outputs #$(outputs->gexp outputs)
  98. #:search-paths '#$(sexp->gexp
  99. (map search-path-specification->sexp
  100. search-paths))
  101. #:inputs #$(input-tuples->gexp inputs)
  102. #:julia-package-name #$julia-package-name
  103. #:julia-package-uuid #$julia-package-uuid))))
  104. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  105. system #:graft? #f)))
  106. (gexp->derivation name builder
  107. #:system system
  108. #:guile-for-build guile)))
  109. (define julia-build-system
  110. (build-system
  111. (name 'julia)
  112. (description "The build system for Julia packages")
  113. (lower lower)))
  114. ;;; julia.scm ends here