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