dlang.scm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015, 2016 Roel Janssen <roel@gnu.org>
  3. ;;; Copyright © 2015, 2018 Pjotr Prins <pjotr.guix@thebird.nl>
  4. ;;; Copyright © 2017 Frederick Muriithi <fredmanglis@gmail.com>
  5. ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
  6. ;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
  7. ;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
  8. ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
  9. ;;;
  10. ;;; This file is part of GNU Guix.
  11. ;;;
  12. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  13. ;;; under the terms of the GNU General Public License as published by
  14. ;;; the Free Software Foundation; either version 3 of the License, or (at
  15. ;;; your option) any later version.
  16. ;;;
  17. ;;; GNU Guix is distributed in the hope that it will be useful, but
  18. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;;; GNU General Public License for more details.
  21. ;;;
  22. ;;; You should have received a copy of the GNU General Public License
  23. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  24. (define-module (gnu packages dlang)
  25. #:use-module ((guix licenses) #:prefix license:)
  26. #:use-module (guix packages)
  27. #:use-module (guix download)
  28. #:use-module (guix git-download)
  29. #:use-module (guix build-system gnu)
  30. #:use-module (guix build-system cmake)
  31. #:use-module (gnu packages)
  32. #:use-module (gnu packages base)
  33. #:use-module (gnu packages check)
  34. #:use-module (gnu packages compression)
  35. #:use-module (gnu packages curl)
  36. #:use-module (gnu packages gdb)
  37. #:use-module (gnu packages libedit)
  38. #:use-module (gnu packages llvm)
  39. #:use-module (gnu packages pkg-config)
  40. #:use-module (gnu packages python)
  41. #:use-module (gnu packages python-xyz)
  42. #:use-module (gnu packages textutils)
  43. #:use-module (gnu packages xorg))
  44. (define-public rdmd
  45. (package
  46. (name "rdmd")
  47. (version "2.077.1")
  48. (source (origin
  49. (method url-fetch)
  50. (uri (string-append "https://github.com/dlang/tools/archive/v" version ".tar.gz"))
  51. (file-name (string-append name "-" version ".tar.gz"))
  52. (sha256
  53. (base32
  54. "0c8w373rv6iz3xfid94w40ncv2lr2ncxi662qsr4lda4aghczmq7"))))
  55. (build-system gnu-build-system)
  56. (arguments
  57. '(#:phases
  58. (modify-phases %standard-phases
  59. (delete 'configure)
  60. (delete 'check) ; There is no Makefile, so there's no 'make check'.
  61. (replace
  62. 'build
  63. (lambda _
  64. (invoke "ldc2" "rdmd.d")))
  65. (replace
  66. 'install
  67. (lambda* (#:key outputs #:allow-other-keys)
  68. (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
  69. (install-file "rdmd" bin)))))))
  70. (native-inputs
  71. `(("ldc" ,ldc)))
  72. (home-page "https://github.com/D-Programming-Language/tools/")
  73. (synopsis "Specialized equivalent to 'make' for the D language")
  74. (description
  75. "rdmd is a companion to the dmd compiler that simplifies the typical
  76. edit-compile-link-run or edit-make-run cycle to a rapid edit-run cycle. Like
  77. make and other tools, rdmd uses the relative dates of the files involved to
  78. minimize the amount of work necessary. Unlike make, rdmd tracks dependencies
  79. and freshness without requiring additional information from the user.")
  80. (license license:boost1.0)))
  81. (define-public ldc-bootstrap
  82. (package
  83. (name "ldc")
  84. (version "0.17.6")
  85. (source
  86. (origin
  87. (method git-fetch)
  88. (uri (git-reference
  89. (url "https://github.com/ldc-developers/ldc")
  90. (commit (string-append "v" version))))
  91. (file-name (git-file-name name version))
  92. (sha256
  93. (base32 "1q6hm4fkrcwys83x0p4kfg9xrc1b9g2qicqif2zy5z4nsfsb5vgs"))))
  94. (build-system cmake-build-system)
  95. (supported-systems '("x86_64-linux" "i686-linux" "armhf-linux"))
  96. (properties
  97. ;; Some of the tests take a very long time on ARMv7. See
  98. ;; <https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00312.html>.
  99. `((max-silent-time . ,(* 3600 3))))
  100. (arguments
  101. `(#:phases
  102. (modify-phases %standard-phases
  103. (add-after 'unpack 'unpack-submodule-sources
  104. (lambda* (#:key inputs #:allow-other-keys)
  105. (let ((unpack (lambda (input target)
  106. (let ((source (assoc-ref inputs input)))
  107. ;; Git checkouts are directories as long as
  108. ;; there are no patches; tarballs otherwise.
  109. (if (file-is-directory? source)
  110. (copy-recursively source target)
  111. (with-directory-excursion target
  112. (invoke "tar" "xvf" source
  113. "--strip-components=1")))))))
  114. (unpack "phobos-src" "runtime/phobos")
  115. (unpack "druntime-src" "runtime/druntime")
  116. (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuite")
  117. #t)))
  118. (add-after 'unpack-submodule-sources 'patch-phobos
  119. (lambda* (#:key inputs #:allow-other-keys)
  120. (substitute* "runtime/phobos/std/process.d"
  121. (("/bin/sh") (which "sh"))
  122. (("echo") (which "echo")))
  123. (substitute* "runtime/phobos/std/datetime.d"
  124. (("/usr/share/zoneinfo/")
  125. (search-input-directory inputs "share/zoneinfo"))
  126. (("tzName == \"[+]VERSION\"")
  127. "(tzName == \"+VERSION\" || std.algorithm.endsWith(tzName, \"/leapseconds\"))"))
  128. (substitute* "tests/d2/dmd-testsuite/Makefile"
  129. (("/bin/bash") (which "bash")))
  130. ;; the following two tests fail on i686
  131. (for-each delete-file '("tests/ir/attributes.d" "tests/ir/align.d")))))))
  132. (inputs
  133. `(("libconfig" ,libconfig)
  134. ("libedit" ,libedit)
  135. ("tzdata" ,tzdata)
  136. ("zlib" ,zlib)))
  137. (native-inputs
  138. `(("llvm" ,llvm-6)
  139. ("clang" ,clang-6)
  140. ("python-lit" ,python-lit)
  141. ("python-wrapper" ,python-wrapper)
  142. ("unzip" ,unzip)
  143. ("phobos-src"
  144. ,(origin
  145. (method git-fetch)
  146. (uri (git-reference
  147. (url "https://github.com/ldc-developers/phobos")
  148. (commit (string-append "ldc-v" version))))
  149. (file-name (git-file-name "phobos" version))
  150. (sha256
  151. (base32 "15jzs38wanks2jfp2izzl7zqrp4c8ai54ppsgm8ws86p3sbbkmj8"))
  152. (patches (search-patches "ldc-bootstrap-disable-tests.patch"))))
  153. ("druntime-src"
  154. ,(origin
  155. (method git-fetch)
  156. (uri (git-reference
  157. (url "https://github.com/ldc-developers/druntime")
  158. (commit (string-append "ldc-v" version))))
  159. (file-name (git-file-name "druntime" version))
  160. (sha256
  161. (base32 "00wr2kiggwnd8h7by51fhj1xc65hv1ysip5gbgdbkfar58p2d0bb"))))
  162. ("dmd-testsuite-src"
  163. ,(origin
  164. (method git-fetch)
  165. (uri (git-reference
  166. (url "https://github.com/ldc-developers/dmd-testsuite")
  167. (commit (string-append "ldc-v" version))))
  168. (file-name (git-file-name "dmd-testsuite" version))
  169. (sha256
  170. (base32 "1d1c0979wbippldrkjf7szyj4n87hxz8dwqg1r5b3aai37g9kcky"))))))
  171. (home-page "http://wiki.dlang.org/LDC")
  172. (synopsis "LLVM-based compiler for the D programming language")
  173. (description
  174. "LDC is an LLVM compiler for the D programming language. It is based on
  175. the latest DMD compiler that was written in C and is used for
  176. bootstrapping more recent compilers written in D.")
  177. ;; Most of the code is released under BSD-3, except for code originally
  178. ;; written for GDC, which is released under GPLv2+, and the DMD frontend,
  179. ;; which is released under the "Boost Software License version 1.0".
  180. (license (list license:bsd-3
  181. license:gpl2+
  182. license:boost1.0))))
  183. (define-public ldc
  184. ;; Phobos, druntime and dmd-testsuite library dependencies do
  185. ;; not always have a newer release than the compiler, hence we
  186. ;; retain this variable.
  187. (let ((older-version "1.10.0")) ;; retain this because sometimes the libs are older
  188. (package
  189. (inherit ldc-bootstrap)
  190. (name "ldc")
  191. (version "1.10.0")
  192. (source
  193. (origin
  194. (method git-fetch)
  195. (uri (git-reference
  196. (url "https://github.com/ldc-developers/ldc")
  197. (commit (string-append "v" version))))
  198. (file-name (git-file-name name version))
  199. (sha256
  200. (base32 "0qcb2rn01wql7y8qp31blbv3hwmnh3zjgzi2n7k168cxr6rrdhlp"))))
  201. (arguments
  202. `(#:phases
  203. (modify-phases %standard-phases
  204. (add-after 'unpack 'unpack-submodule-sources
  205. (lambda* (#:key inputs #:allow-other-keys)
  206. (let ((unpack (lambda (input target)
  207. (let ((source (assoc-ref inputs input)))
  208. ;; Git checkouts are directories as long as
  209. ;; there are no patches; tarballs otherwise.
  210. (if (file-is-directory? source)
  211. (copy-recursively source target)
  212. (with-directory-excursion target
  213. (invoke "tar" "xvf" source
  214. "--strip-components=1")))))))
  215. (unpack "phobos-src" "runtime/phobos")
  216. (unpack "druntime-src" "runtime/druntime")
  217. (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuite")
  218. #t)))
  219. (add-after 'unpack-submodule-sources 'patch-phobos
  220. (lambda* (#:key inputs #:allow-other-keys)
  221. (substitute* '("runtime/phobos/std/process.d"
  222. "tests/linking/linker_switches.d")
  223. (("/bin/sh") (which "sh"))
  224. (("echo") (which "echo")))
  225. (substitute* "tests/d2/dmd-testsuite/Makefile"
  226. (("/bin/bash") (which "bash")))
  227. ;; disable unittests in the following files. We are discussing with
  228. ;; upstream
  229. (substitute* '("runtime/phobos/std/net/curl.d"
  230. "runtime/phobos/std/datetime/systime.d"
  231. "runtime/phobos/std/datetime/timezone.d"
  232. )
  233. (("version(unittest)") "version(skipunittest)")
  234. ((" unittest") " version(skipunittest) unittest"))
  235. ;; the following tests require a more recent LLVM
  236. (delete-file "tests/compilable/ctfe_math.d")
  237. (delete-file "tests/debuginfo/nested_gdb.d")
  238. (delete-file "tests/debuginfo/classtypes_gdb.d")
  239. ;; for the following tests ptrace fails with EPERM
  240. ;; (see <https://issues.guix.gnu.org/48541>):
  241. (delete-file "tests/d2/dmd-testsuite/runnable/b18504.d")
  242. (delete-file "tests/d2/dmd-testsuite/runnable/gdb14225.d")
  243. (delete-file "tests/d2/dmd-testsuite/runnable/gdb14276.d")
  244. (delete-file "tests/d2/dmd-testsuite/runnable/gdb14313.d")
  245. (delete-file "tests/d2/dmd-testsuite/runnable/gdb14330.d")
  246. (delete-file "tests/d2/dmd-testsuite/runnable/gdb1.d")
  247. (delete-file "tests/d2/dmd-testsuite/runnable/gdb4149.d")
  248. (delete-file "tests/d2/dmd-testsuite/runnable/gdb4181.d")
  249. (delete-file "tests/d2/dmd-testsuite/runnable/gdb15729.sh")
  250. ;; the following tests plugins we don't have.
  251. (delete-file "tests/plugins/addFuncEntryCall/testPlugin.d")
  252. ;; the following tests requires AVX instruction set in the CPU.
  253. (substitute* "tests/d2/dmd-testsuite/runnable/test_cdvecfill.d"
  254. (("^// DISABLED: ") "^// DISABLED: linux64 "))
  255. #t))
  256. (replace 'check
  257. (lambda* (#:key inputs outputs #:allow-other-keys)
  258. ;; some tests call into gdb binary which needs SHELL and CC set
  259. (setenv "SHELL" (which "sh"))
  260. (setenv "CC" (search-input-file inputs "/bin/gcc"))
  261. (invoke "make" "test" "-j" (number->string (parallel-job-count))))))))
  262. (native-inputs
  263. `(("llvm" ,llvm-6)
  264. ("clang" ,clang-6)
  265. ("ldc" ,ldc-bootstrap)
  266. ("python-lit" ,python-lit)
  267. ("python-wrapper" ,python-wrapper)
  268. ("unzip" ,unzip)
  269. ("gdb" ,gdb)
  270. ("phobos-src"
  271. ,(origin
  272. (method git-fetch)
  273. (uri (git-reference
  274. (url "https://github.com/ldc-developers/phobos")
  275. (commit (string-append "ldc-v" older-version))))
  276. (file-name (git-file-name "phobos" older-version))
  277. (sha256
  278. (base32 "1gmlwnjdcf6s5aahadxsif9l5nyaj0rrn379g6fmhcvdk64kf509"))
  279. ;; This patch deactivates some tests that depend on network access
  280. ;; to pass. It also deactivates some tests that have some reliance
  281. ;; on timezone.
  282. ;;
  283. ;; For the network tests, there's an effort to get a version flag
  284. ;; added to deactivate these tests for distribution packagers
  285. ;; that is being pursued at
  286. ;; <https://forum.dlang.org/post/zmdbdgnzrxyvtpqafvyg@forum.dlang.org>.
  287. ;; It also deactivates a test that requires /root
  288. (patches (search-patches "ldc-disable-phobos-tests.patch"))))
  289. ("druntime-src"
  290. ,(origin
  291. (method git-fetch)
  292. (uri (git-reference
  293. (url "https://github.com/ldc-developers/druntime")
  294. (commit (string-append "ldc-v" older-version))))
  295. (file-name (git-file-name "druntime" older-version))
  296. (sha256
  297. (base32 "0a3yyjcnpvm5fbdczf76fx08kl154w17w06hlxf0j3p1p4jc85aj"))))
  298. ("dmd-testsuite-src"
  299. ,(origin
  300. (method git-fetch)
  301. (uri (git-reference
  302. (url "https://github.com/ldc-developers/dmd-testsuite")
  303. (commit (string-append "ldc-v" older-version))))
  304. (file-name (git-file-name "dmd-testsuite" older-version))
  305. (sha256
  306. (base32 "0mm3rliki1nqiqfaha7ssvm156aa398vpvf4v6895m7nn1mz7rss")))))))))
  307. (define-public dub
  308. (package
  309. (name "dub")
  310. (version "1.7.2")
  311. (source
  312. (origin
  313. (method git-fetch)
  314. (uri (git-reference
  315. (url "https://github.com/dlang/dub")
  316. (commit (string-append "v" version))))
  317. (file-name (git-file-name name version))
  318. (sha256
  319. (base32 "073ibvgm1gphcqs1yjrav9ryp677nh3b194nxmvicwgvdc0sb6w9"))))
  320. (build-system gnu-build-system)
  321. (arguments
  322. `(#:tests? #f ; it would have tested itself by installing some packages (vibe etc)
  323. #:phases
  324. (modify-phases %standard-phases
  325. (delete 'configure) ; no configure script
  326. (replace 'build
  327. (lambda _
  328. (invoke "./build.sh")))
  329. (replace 'install
  330. (lambda* (#:key outputs #:allow-other-keys)
  331. (let* ((out (assoc-ref outputs "out"))
  332. (bin (string-append out "/bin")))
  333. (install-file "bin/dub" bin)
  334. #t))))))
  335. (inputs
  336. `(("curl" ,curl)))
  337. (native-inputs
  338. `(("ldc" ,ldc)))
  339. (home-page "https://code.dlang.org/getting_started")
  340. (synopsis "Package and build manager for D projects")
  341. (description
  342. "DUB is a package and build manager for applications and
  343. libraries written in the D programming language. It can
  344. automatically retrieve a project's dependencies and integrate
  345. them in the build process.
  346. The design emphasis is on maximum simplicity for simple projects,
  347. while providing the opportunity to customize things when
  348. needed.")
  349. (license license:expat)))
  350. (define-public gtkd
  351. (package
  352. (name "gtkd")
  353. (version "3.9.0")
  354. (source
  355. (origin
  356. (method url-fetch/zipbomb)
  357. (uri (string-append "https://gtkd.org/Downloads/sources/GtkD-"
  358. version ".zip"))
  359. (sha256
  360. (base32 "0qv8qlpwwb1d078pnrf0a59vpbkziyf53cf9p6m8ms542wbcxllp"))))
  361. (build-system gnu-build-system)
  362. (native-inputs
  363. `(("unzip" ,unzip)
  364. ("ldc" ,ldc)
  365. ("pkg-config" ,pkg-config)
  366. ("xorg-server-for-tests" ,xorg-server-for-tests)))
  367. (arguments
  368. `(#:test-target "test"
  369. #:make-flags
  370. `("DC=ldc2"
  371. ,(string-append "prefix=" (assoc-ref %outputs "out"))
  372. ,(string-append "libdir=" (assoc-ref %outputs "out")
  373. "/lib"))
  374. #:phases
  375. (modify-phases %standard-phases
  376. (delete 'configure)
  377. (add-before 'build 'patch-makefile
  378. (lambda* (#:key outputs #:allow-other-keys)
  379. (substitute* "GNUmakefile"
  380. ;; We do the tests ourselves.
  381. (("default-goal: libs test") "default-goal: libs")
  382. (("all: libs shared-libs test") "all: libs shared-libs")
  383. ;; Work around upstream bug.
  384. (("\\$\\(prefix\\)\\/\\$\\(libdir\\)") "$(libdir)"))
  385. #t))
  386. (add-before 'check 'prepare-x
  387. (lambda _
  388. (system "Xvfb :1 &")
  389. (setenv "DISPLAY" ":1")
  390. #t)))))
  391. (home-page "https://gtkd.org/")
  392. (synopsis "D binding and OO wrapper of GTK+")
  393. (description "This package provides bindings to GTK+ for D.")
  394. (license license:lgpl2.1)))