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