gnu: facter: Update to 4.0.33.
[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 ;;;
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
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
45 (define-public rdmd
46 (package
47 (name "rdmd")
48 (version "2.077.1")
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
55 "0c8w373rv6iz3xfid94w40ncv2lr2ncxi662qsr4lda4aghczmq7"))))
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 _
65 (invoke "ldc2" "rdmd.d")))
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
77 edit-compile-link-run or edit-make-run cycle to a rapid edit-run cycle. Like
78 make and other tools, rdmd uses the relative dates of the files involved to
79 minimize the amount of work necessary. Unlike make, rdmd tracks dependencies
80 and freshness without requiring additional information from the user.")
81 (license license:boost1.0)))
82
83 (define-public ldc-bootstrap
84 (package
85 (name "ldc")
86 (version "0.17.4")
87 (source
88 (origin
89 (method git-fetch)
90 (uri (git-reference
91 (url "https://github.com/ldc-developers/ldc")
92 (commit (string-append "v" version))))
93 (file-name (git-file-name name version))
94 (sha256
95 (base32 "0nnrjavfmpfp7bib04isqlxvyzh6mlvsdan0gxysdz96hlg4hcq8"))))
96 (build-system cmake-build-system)
97 (supported-systems '("x86_64-linux" "i686-linux" "armhf-linux"))
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))))
102 (arguments
103 `(#:phases
104 (modify-phases %standard-phases
105 (add-after 'unpack 'unpack-submodule-sources
106 (lambda* (#:key inputs #:allow-other-keys)
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")))))))
116 (unpack "phobos-src" "runtime/phobos")
117 (unpack "druntime-src" "runtime/druntime")
118 (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuite")
119 #t)))
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/")
135 (string-append (assoc-ref inputs "tzdata") "/share/zoneinfo"))
136 (("tzName == \"[+]VERSION\"")
137 "(tzName == \"+VERSION\" || std.algorithm.endsWith(tzName, \"/leapseconds\"))"))
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")
142 ;; the following two tests fail on i686
143 (for-each delete-file '("tests/ir/attributes.d" "tests/ir/align.d")))))))
144 (inputs
145 `(("libconfig" ,libconfig)
146 ("libedit" ,libedit)
147 ("tzdata" ,tzdata)
148 ("zlib" ,zlib)))
149 (native-inputs
150 `(("llvm" ,llvm-3.8)
151 ("clang" ,clang-3.8)
152 ("python-lit" ,python-lit)
153 ("python-wrapper" ,python-wrapper)
154 ("unzip" ,unzip)
155 ("phobos-src"
156 ,(origin
157 (method git-fetch)
158 (uri (git-reference
159 (url "https://github.com/ldc-developers/phobos")
160 (commit (string-append "ldc-v" version))))
161 (file-name (git-file-name "phobos" version))
162 (sha256
163 (base32 "0i7gh99w4mi0hdv16261jcdiqyv1nkjdcwy9prw32s0lvplx8fdy"))
164 (patches (search-patches "ldc-bootstrap-disable-tests.patch"))))
165 ("druntime-src"
166 ,(origin
167 (method git-fetch)
168 (uri (git-reference
169 (url "https://github.com/ldc-developers/druntime")
170 (commit (string-append "ldc-v" version))))
171 (file-name (git-file-name "druntime" version))
172 (sha256
173 (base32 "0alabm3bbvs94msvxz5psiwk4f51cw9h82z1p5hhsnf8ja6d0am7"))))
174 ("dmd-testsuite-src"
175 ,(origin
176 (method git-fetch)
177 (uri (git-reference
178 (url "https://github.com/ldc-developers/dmd-testsuite")
179 (commit (string-append "ldc-v" version))))
180 (file-name (git-file-name "dmd-testsuite" version))
181 (sha256
182 (base32 "05qr4cgb4scfqzbw1l5pk72kil074mvj9d55b165ljyr51sgwgbl"))))))
183 (home-page "http://wiki.dlang.org/LDC")
184 (synopsis "LLVM-based compiler for the D programming language")
185 (description
186 "LDC is an LLVM compiler for the D programming language. It is based on
187 the latest DMD compiler that was written in C and is used for
188 bootstrapping more recent compilers written in D.")
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+
194 license:boost1.0))))
195
196 (define-public ldc
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.
200 (let ((older-version "1.10.0")) ;; retain this because sometimes the libs are older
201 (package
202 (inherit ldc-bootstrap)
203 (name "ldc")
204 (version "1.10.0")
205 (source
206 (origin
207 (method git-fetch)
208 (uri (git-reference
209 (url "https://github.com/ldc-developers/ldc")
210 (commit (string-append "v" version))))
211 (file-name (git-file-name name version))
212 (sha256
213 (base32 "0qcb2rn01wql7y8qp31blbv3hwmnh3zjgzi2n7k168cxr6rrdhlp"))))
214 (arguments
215 `(#:phases
216 (modify-phases %standard-phases
217 (add-after 'unpack 'unpack-submodule-sources
218 (lambda* (#:key inputs #:allow-other-keys)
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")))))))
228 (unpack "phobos-src" "runtime/phobos")
229 (unpack "druntime-src" "runtime/druntime")
230 (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuite")
231 #t)))
232 (add-after 'unpack-submodule-sources 'patch-phobos
233 (lambda* (#:key inputs #:allow-other-keys)
234 (substitute* '("runtime/phobos/std/process.d"
235 "tests/linking/linker_switches.d")
236 (("/bin/sh") (which "sh"))
237 (("echo") (which "echo")))
238 (substitute* "tests/d2/dmd-testsuite/Makefile"
239 (("/bin/bash") (which "bash")))
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")
252 ;; the following tests plugins we don't have.
253 (delete-file "tests/plugins/addFuncEntryCall/testPlugin.d")
254 ;; the following tests requires AVX instruction set in the CPU.
255 (substitute* "tests/d2/dmd-testsuite/runnable/test_cdvecfill.d"
256 (("^// DISABLED: ") "^// DISABLED: linux64 "))
257 #t))
258 (replace 'check
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))))))))
264 (native-inputs
265 `(("llvm" ,llvm-6)
266 ("clang" ,clang-6)
267 ("ldc" ,ldc-bootstrap)
268 ("python-lit" ,python-lit)
269 ("python-wrapper" ,python-wrapper)
270 ("unzip" ,unzip)
271 ("gdb" ,gdb)
272 ("phobos-src"
273 ,(origin
274 (method git-fetch)
275 (uri (git-reference
276 (url "https://github.com/ldc-developers/phobos")
277 (commit (string-append "ldc-v" older-version))))
278 (file-name (git-file-name "phobos" older-version))
279 (sha256
280 (base32 "1gmlwnjdcf6s5aahadxsif9l5nyaj0rrn379g6fmhcvdk64kf509"))
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
290 (patches (search-patches "ldc-disable-phobos-tests.patch"))))
291 ("druntime-src"
292 ,(origin
293 (method git-fetch)
294 (uri (git-reference
295 (url "https://github.com/ldc-developers/druntime")
296 (commit (string-append "ldc-v" older-version))))
297 (file-name (git-file-name "druntime" older-version))
298 (sha256
299 (base32 "0a3yyjcnpvm5fbdczf76fx08kl154w17w06hlxf0j3p1p4jc85aj"))))
300 ("dmd-testsuite-src"
301 ,(origin
302 (method git-fetch)
303 (uri (git-reference
304 (url "https://github.com/ldc-developers/dmd-testsuite")
305 (commit (string-append "ldc-v" older-version))))
306 (file-name (git-file-name "dmd-testsuite" older-version))
307 (sha256
308 (base32 "0mm3rliki1nqiqfaha7ssvm156aa398vpvf4v6895m7nn1mz7rss")))))))))
309
310 (define-public dub
311 (package
312 (name "dub")
313 (version "1.7.2")
314 (source
315 (origin
316 (method git-fetch)
317 (uri (git-reference
318 (url "https://github.com/dlang/dub")
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)
324 (arguments
325 `(#:tests? #f ; it would have tested itself by installing some packages (vibe etc)
326 #:phases
327 (modify-phases %standard-phases
328 (delete 'configure) ; no configure script
329 (replace 'build
330 (lambda _
331 (invoke "./build.sh")))
332 (replace 'install
333 (lambda* (#:key outputs #:allow-other-keys)
334 (let* ((out (assoc-ref outputs "out"))
335 (bin (string-append out "/bin")))
336 (install-file "bin/dub" bin)
337 #t))))))
338 (inputs
339 `(("curl" ,curl)))
340 (native-inputs
341 `(("ldc" ,ldc)))
342 (home-page "https://code.dlang.org/getting_started")
343 (synopsis "Package and build manager for D projects")
344 (description
345 "DUB is a package and build manager for applications and
346 libraries written in the D programming language. It can
347 automatically retrieve a project's dependencies and integrate
348 them in the build process.
349
350 The design emphasis is on maximum simplicity for simple projects,
351 while providing the opportunity to customize things when
352 needed.")
353 (license license:expat)))
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)))