gnu: emacs-svg-icon: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / dlang.scm
CommitLineData
a7ec569c 1;;; GNU Guix --- Functional package management for GNU
c1fc7a67 2;;; Copyright © 2015, 2016 Roel Janssen <roel@gnu.org>
633e8aab 3;;; Copyright © 2015, 2018 Pjotr Prins <pjotr.guix@thebird.nl>
2429dde5 4;;; Copyright © 2017 Frederick Muriithi <fredmanglis@gmail.com>
538bce24 5;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
d57748e3 6;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
141262f2 7;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
13ff47c0 8;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
a7ec569c
RJ
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
98d6543f 25(define-module (gnu packages dlang)
a7ec569c
RJ
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix packages)
28 #:use-module (guix download)
c1fc7a67
RJ
29 #:use-module (guix git-download)
30 #:use-module (guix build-system gnu)
a7ec569c
RJ
31 #:use-module (guix build-system cmake)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages base)
ac257f12 34 #:use-module (gnu packages check)
812b3c1f 35 #:use-module (gnu packages compression)
4fdcc502 36 #:use-module (gnu packages curl)
2429dde5 37 #:use-module (gnu packages gdb)
a7ec569c
RJ
38 #:use-module (gnu packages libedit)
39 #:use-module (gnu packages llvm)
141262f2 40 #:use-module (gnu packages pkg-config)
0959478c 41 #:use-module (gnu packages python)
44d10b1f 42 #:use-module (gnu packages python-xyz)
141262f2 43 #:use-module (gnu packages textutils)
44 #:use-module (gnu packages xorg))
a7ec569c 45
c1fc7a67 46(define-public rdmd
55330714
DM
47 (package
48 (name "rdmd")
1b541c3e 49 (version "2.077.1")
55330714
DM
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
1b541c3e 56 "0c8w373rv6iz3xfid94w40ncv2lr2ncxi662qsr4lda4aghczmq7"))))
55330714
DM
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 _
12479d58 66 (invoke "ldc2" "rdmd.d")))
55330714
DM
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
c1fc7a67
RJ
78edit-compile-link-run or edit-make-run cycle to a rapid edit-run cycle. Like
79make and other tools, rdmd uses the relative dates of the files involved to
80minimize the amount of work necessary. Unlike make, rdmd tracks dependencies
81and freshness without requiring additional information from the user.")
55330714 82 (license license:boost1.0)))
c1fc7a67 83
beffaf9a 84(define-public ldc-bootstrap
5144c044
DM
85 (package
86 (name "ldc")
13ff47c0 87 (version "0.17.6")
d57748e3
TGR
88 (source
89 (origin
90 (method git-fetch)
91 (uri (git-reference
b0e7b699 92 (url "https://github.com/ldc-developers/ldc")
d57748e3
TGR
93 (commit (string-append "v" version))))
94 (file-name (git-file-name name version))
95 (sha256
13ff47c0 96 (base32 "1q6hm4fkrcwys83x0p4kfg9xrc1b9g2qicqif2zy5z4nsfsb5vgs"))))
5144c044
DM
97 (build-system cmake-build-system)
98 (supported-systems '("x86_64-linux" "i686-linux" "armhf-linux"))
1b541c3e
PP
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))))
5144c044
DM
103 (arguments
104 `(#:phases
105 (modify-phases %standard-phases
106 (add-after 'unpack 'unpack-submodule-sources
107 (lambda* (#:key inputs #:allow-other-keys)
d57748e3
TGR
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")))))))
4b81d5c4
RW
117 (unpack "phobos-src" "runtime/phobos")
118 (unpack "druntime-src" "runtime/druntime")
119 (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuite")
120 #t)))
5144c044
DM
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/")
1b541c3e
PP
128 (string-append (assoc-ref inputs "tzdata") "/share/zoneinfo"))
129 (("tzName == \"[+]VERSION\"")
130 "(tzName == \"+VERSION\" || std.algorithm.endsWith(tzName, \"/leapseconds\"))"))
5144c044
DM
131 (substitute* "tests/d2/dmd-testsuite/Makefile"
132 (("/bin/bash") (which "bash")))
1b541c3e
PP
133 ;; the following two tests fail on i686
134 (for-each delete-file '("tests/ir/attributes.d" "tests/ir/align.d")))))))
5144c044
DM
135 (inputs
136 `(("libconfig" ,libconfig)
137 ("libedit" ,libedit)
138 ("tzdata" ,tzdata)
139 ("zlib" ,zlib)))
140 (native-inputs
13ff47c0
EF
141 `(("llvm" ,llvm-6)
142 ("clang" ,clang-6)
5144c044
DM
143 ("python-lit" ,python-lit)
144 ("python-wrapper" ,python-wrapper)
145 ("unzip" ,unzip)
146 ("phobos-src"
147 ,(origin
d57748e3
TGR
148 (method git-fetch)
149 (uri (git-reference
b0e7b699 150 (url "https://github.com/ldc-developers/phobos")
d57748e3
TGR
151 (commit (string-append "ldc-v" version))))
152 (file-name (git-file-name "phobos" version))
5144c044 153 (sha256
13ff47c0 154 (base32 "15jzs38wanks2jfp2izzl7zqrp4c8ai54ppsgm8ws86p3sbbkmj8"))
1b541c3e 155 (patches (search-patches "ldc-bootstrap-disable-tests.patch"))))
5144c044
DM
156 ("druntime-src"
157 ,(origin
d57748e3
TGR
158 (method git-fetch)
159 (uri (git-reference
b0e7b699 160 (url "https://github.com/ldc-developers/druntime")
d57748e3
TGR
161 (commit (string-append "ldc-v" version))))
162 (file-name (git-file-name "druntime" version))
5144c044 163 (sha256
13ff47c0 164 (base32 "00wr2kiggwnd8h7by51fhj1xc65hv1ysip5gbgdbkfar58p2d0bb"))))
5144c044
DM
165 ("dmd-testsuite-src"
166 ,(origin
d57748e3
TGR
167 (method git-fetch)
168 (uri (git-reference
b0e7b699 169 (url "https://github.com/ldc-developers/dmd-testsuite")
d57748e3
TGR
170 (commit (string-append "ldc-v" version))))
171 (file-name (git-file-name "dmd-testsuite" version))
5144c044 172 (sha256
13ff47c0 173 (base32 "1d1c0979wbippldrkjf7szyj4n87hxz8dwqg1r5b3aai37g9kcky"))))))
5144c044 174 (home-page "http://wiki.dlang.org/LDC")
633e8aab 175 (synopsis "LLVM-based compiler for the D programming language")
5144c044 176 (description
633e8aab 177 "LDC is an LLVM compiler for the D programming language. It is based on
1b541c3e
PP
178the latest DMD compiler that was written in C and is used for
179bootstrapping more recent compilers written in D.")
5144c044
DM
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+
1b541c3e 185 license:boost1.0))))
2429dde5 186
836cbd9f 187(define-public ldc
1b541c3e
PP
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.
633e8aab 191 (let ((older-version "1.10.0")) ;; retain this because sometimes the libs are older
2429dde5 192 (package
beffaf9a 193 (inherit ldc-bootstrap)
2429dde5 194 (name "ldc")
633e8aab 195 (version "1.10.0")
36f7fbca
TGR
196 (source
197 (origin
198 (method git-fetch)
199 (uri (git-reference
b0e7b699 200 (url "https://github.com/ldc-developers/ldc")
36f7fbca
TGR
201 (commit (string-append "v" version))))
202 (file-name (git-file-name name version))
203 (sha256
204 (base32 "0qcb2rn01wql7y8qp31blbv3hwmnh3zjgzi2n7k168cxr6rrdhlp"))))
2429dde5
MFM
205 (arguments
206 `(#:phases
207 (modify-phases %standard-phases
208 (add-after 'unpack 'unpack-submodule-sources
209 (lambda* (#:key inputs #:allow-other-keys)
36f7fbca
TGR
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")))))))
68631e03
RW
219 (unpack "phobos-src" "runtime/phobos")
220 (unpack "druntime-src" "runtime/druntime")
36f7fbca
TGR
221 (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuite")
222 #t)))
2429dde5
MFM
223 (add-after 'unpack-submodule-sources 'patch-phobos
224 (lambda* (#:key inputs #:allow-other-keys)
1b541c3e
PP
225 (substitute* '("runtime/phobos/std/process.d"
226 "tests/linking/linker_switches.d")
2429dde5
MFM
227 (("/bin/sh") (which "sh"))
228 (("echo") (which "echo")))
2429dde5 229 (substitute* "tests/d2/dmd-testsuite/Makefile"
36f7fbca 230 (("/bin/bash") (which "bash")))
1b541c3e
PP
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")
633e8aab
PP
243 ;; the following tests plugins we don't have.
244 (delete-file "tests/plugins/addFuncEntryCall/testPlugin.d")
781d721a 245 ;; the following tests requires AVX instruction set in the CPU.
1b541c3e 246 (substitute* "tests/d2/dmd-testsuite/runnable/test_cdvecfill.d"
36f7fbca 247 (("^// DISABLED: ") "^// DISABLED: linux64 "))
1b541c3e
PP
248 #t))
249 (replace 'check
36f7fbca
TGR
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))))))))
2429dde5 255 (native-inputs
d199a4c7
MB
256 `(("llvm" ,llvm-6)
257 ("clang" ,clang-6)
beffaf9a 258 ("ldc" ,ldc-bootstrap)
2429dde5
MFM
259 ("python-lit" ,python-lit)
260 ("python-wrapper" ,python-wrapper)
261 ("unzip" ,unzip)
262 ("gdb" ,gdb)
263 ("phobos-src"
264 ,(origin
36f7fbca
TGR
265 (method git-fetch)
266 (uri (git-reference
b0e7b699 267 (url "https://github.com/ldc-developers/phobos")
36f7fbca
TGR
268 (commit (string-append "ldc-v" older-version))))
269 (file-name (git-file-name "phobos" older-version))
2429dde5 270 (sha256
36f7fbca 271 (base32 "1gmlwnjdcf6s5aahadxsif9l5nyaj0rrn379g6fmhcvdk64kf509"))
2429dde5
MFM
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
633e8aab 281 (patches (search-patches "ldc-disable-phobos-tests.patch"))))
2429dde5
MFM
282 ("druntime-src"
283 ,(origin
36f7fbca
TGR
284 (method git-fetch)
285 (uri (git-reference
b0e7b699 286 (url "https://github.com/ldc-developers/druntime")
36f7fbca
TGR
287 (commit (string-append "ldc-v" older-version))))
288 (file-name (git-file-name "druntime" older-version))
2429dde5 289 (sha256
36f7fbca 290 (base32 "0a3yyjcnpvm5fbdczf76fx08kl154w17w06hlxf0j3p1p4jc85aj"))))
2429dde5
MFM
291 ("dmd-testsuite-src"
292 ,(origin
36f7fbca
TGR
293 (method git-fetch)
294 (uri (git-reference
b0e7b699 295 (url "https://github.com/ldc-developers/dmd-testsuite")
36f7fbca
TGR
296 (commit (string-append "ldc-v" older-version))))
297 (file-name (git-file-name "dmd-testsuite" older-version))
2429dde5 298 (sha256
36f7fbca 299 (base32 "0mm3rliki1nqiqfaha7ssvm156aa398vpvf4v6895m7nn1mz7rss")))))))))
4fdcc502
DM
300
301(define-public dub
302 (package
303 (name "dub")
1b541c3e 304 (version "1.7.2")
454866c6
TGR
305 (source
306 (origin
307 (method git-fetch)
308 (uri (git-reference
b0e7b699 309 (url "https://github.com/dlang/dub")
454866c6
TGR
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)
4fdcc502
DM
315 (arguments
316 `(#:tests? #f ; it would have tested itself by installing some packages (vibe etc)
317 #:phases
318 (modify-phases %standard-phases
cd12f922 319 (delete 'configure) ; no configure script
4fdcc502
DM
320 (replace 'build
321 (lambda _
a4960a20 322 (invoke "./build.sh")))
4fdcc502
DM
323 (replace 'install
324 (lambda* (#:key outputs #:allow-other-keys)
325 (let* ((out (assoc-ref outputs "out"))
cd12f922
TGR
326 (bin (string-append out "/bin")))
327 (install-file "bin/dub" bin)
4fdcc502
DM
328 #t))))))
329 (inputs
330 `(("curl" ,curl)))
331 (native-inputs
332 `(("ldc" ,ldc)))
333 (home-page "https://code.dlang.org/getting_started")
27a5c604
TGR
334 (synopsis "Package and build manager for D projects")
335 (description
1b541c3e
PP
336 "DUB is a package and build manager for applications and
337libraries written in the D programming language. It can
338automatically retrieve a project's dependencies and integrate
339them in the build process.
27a5c604 340
1b541c3e
PP
341The design emphasis is on maximum simplicity for simple projects,
342while providing the opportunity to customize things when
343needed.")
4fdcc502 344 (license license:expat)))
141262f2 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)))