julia.scm 4.9 KB

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