gnu: emacs-helm: Update to 3.8.7.
[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, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
8 ;;; Copyright © 2021, 2022 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
10 ;;; Copyright © 2022 ( <paren@disroot.org>
11 ;;; Copyright © 2022 Esther Flashner <esther@flashner.co.il>
12 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages dlang)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix gexp)
34 #:use-module (guix utils)
35 #:use-module ((guix build utils) #:hide (delete which))
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system cmake)
38 #:use-module (guix build-system copy)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages base)
41 #:use-module (gnu packages check)
42 #:use-module (gnu packages compression)
43 #:use-module (gnu packages curl)
44 #:use-module (gnu packages gcc)
45 #:use-module (gnu packages gdb)
46 #:use-module (gnu packages libedit)
47 #:use-module (gnu packages llvm)
48 #:use-module (gnu packages ninja)
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages python)
52 #:use-module (gnu packages python-xyz)
53 #:use-module (gnu packages textutils)
54 #:use-module (gnu packages xorg)
55 #:use-module (srfi srfi-1))
56
57 (define-public d-tools
58 (package
59 (name "d-tools")
60 (version "2.100.0")
61 (source
62 (origin
63 (method git-fetch)
64 (uri (git-reference
65 (url "https://github.com/dlang/tools")
66 (commit (string-append "v" version))))
67 (file-name (git-file-name name version))
68 (sha256
69 (base32 "1jbn0hyskv4ykcckw0iganpyrm0bq2lggswspw21r4hgnxkmjbyw"))))
70 (build-system gnu-build-system)
71 (arguments
72 (list #:phases
73 #~(modify-phases %standard-phases
74 (delete 'configure)
75 (replace 'build
76 (lambda _
77 (mkdir-p "bin")
78 (setenv "CC" #$(cc-for-target))
79 (setenv "LD" #$(ld-for-target))
80 (invoke "ldc2" "rdmd.d" "--of" "bin/rdmd")
81 (apply invoke "ldc2" "--of=bin/dustmite"
82 (find-files "DustMite" ".*\\.d"))))
83 (replace 'check
84 (lambda* (#:key tests? #:allow-other-keys)
85 (when tests?
86 (invoke "bin/rdmd" "rdmd_test.d" "bin/rdmd"
87 "--rdmd-default-compiler" "ldmd2"))))
88 (replace 'install
89 (lambda* (#:key outputs #:allow-other-keys)
90 (let* ((out (assoc-ref outputs "out"))
91 (bin (string-append out "/bin"))
92 (man (string-append out "/man")))
93 (for-each delete-file (find-files "bin" "\\.o$"))
94 (copy-recursively "bin" bin)
95 (copy-recursively "man" man)))))))
96 (native-inputs
97 (list ldc
98 (module-ref (resolve-interface
99 '(gnu packages commencement))
100 'ld-gold-wrapper)))
101 (home-page "https://github.com/dlang/tools")
102 (synopsis "Useful D-related tools")
103 (description
104 "@code{d-tools} provides two useful tools for the D language: @code{rdmd},
105 which runs D source files as scripts, and @code{dustmite}, which reduces D code
106 to a minimal test case.")
107 (license license:boost1.0)))
108
109 (define-public gdmd
110 (let ((commit "ff2c97a47408fb71c18a2d453294d18808a97cc5")
111 (revision "1"))
112 (package
113 (name "gdmd")
114 (version (git-version "0.1.0" revision commit))
115 (source
116 (origin
117 (method git-fetch)
118 (uri (git-reference
119 (url "https://github.com/D-Programming-GDC/gdmd")
120 (commit commit)))
121 (file-name (git-file-name name version))
122 (sha256
123 (base32 "0pd70clk70069xcjysaas7zszzmigrcw1zl2xxv8kzdg7y7xrzvm"))))
124 (build-system copy-build-system)
125 (arguments
126 (list
127 #:install-plan
128 #~'(("dmd-script" "bin/gdmd")
129 ("dmd-script.1" "share/man/man1/gdmd.1"))
130 #:phases
131 #~(modify-phases %standard-phases
132 (add-after 'unpack 'adjust-gdc-location
133 (lambda* (#:key inputs #:allow-other-keys)
134 (substitute* "dmd-script"
135 (("my \\$gdc_dir.*")
136 (string-append "my $gdc_dir = \""
137 (dirname (search-input-file inputs "/bin/gdc"))
138 "\";\n"))))))))
139 (inputs
140 (list gdc-10 perl))
141 (home-page "https://github.com/D-Programming-GDC/gdmd")
142 (synopsis "DMD-like wrapper for GDC")
143 (description "This package provides a DMD-like wrapper for the
144 @acronym{GNU D Compiler,GDC}.")
145 (license license:gpl3+))))
146
147 ;; We use GDC, the D frontend for GCC, to bootstrap ldc. We then use
148 ;; ldc to bootstrap itself so that no reference remains to GDC.
149 (define ldc-bootstrap
150 (package
151 (name "ldc")
152 (version "1.27.1")
153 (source
154 (origin
155 (method url-fetch)
156 (uri (string-append "https://github.com/ldc-developers/ldc/releases"
157 "/download/v" version "/ldc-" version "-src.tar.gz"))
158 (sha256
159 (base32 "1775001ba6n8w46ln530kb5r66vs935ingnppgddq8wqnc0gbj4k"))))
160 (build-system cmake-build-system)
161 (arguments
162 `(#:tests? #f ;skip in the bootstrap
163 #:build-type "Release"
164 #:configure-flags
165 (list "-GNinja")
166 #:make-flags ;used as build targets
167 (list "all")
168 #:phases
169 (modify-phases %standard-phases
170 (add-after 'unpack 'patch-paths
171 (lambda* (#:key inputs #:allow-other-keys)
172 (substitute* "runtime/phobos/std/process.d"
173 (("/bin/sh") (which "sh"))
174 (("echo") (which "echo")))))
175 (replace 'build
176 ;; Building with Make would result in "make: *** [Makefile:166:
177 ;; all] Error 2".
178 (lambda* (#:key make-flags parallel-tests? #:allow-other-keys)
179 (let ((job-count (number->string (or (and parallel-tests?
180 (parallel-job-count))
181 1))))
182 (apply invoke "cmake" "--build" "." "-j" job-count
183 "--target" make-flags))))
184 (replace 'install
185 (lambda _
186 (invoke "cmake" "--install" "."))))))
187 (inputs
188 `(("libconfig" ,libconfig)
189 ("libedit" ,libedit)
190 ("tzdata" ,tzdata)
191 ("zlib" ,zlib)))
192 (native-inputs
193 ;; Importing (gnu packages commencement) would introduce a cycle.
194 `(("ld-gold-wrapper" ,(module-ref (resolve-interface
195 '(gnu packages commencement))
196 'ld-gold-wrapper))
197 ("llvm" ,llvm-11)
198 ("ldc" ,gdmd)
199 ("ninja" ,ninja)
200 ("python-wrapper" ,python-wrapper)
201 ("unzip" ,unzip)))
202 (home-page "http://wiki.dlang.org/LDC")
203 (synopsis "LLVM-based compiler for the D programming language")
204 (description
205 "LDC is an LLVM compiler for the D programming language. It is based on
206 the latest DMD compiler that was written in C and is used for
207 bootstrapping more recent compilers written in D.")
208 (properties
209 ;; Some of the tests take a very long time on ARMv7. See
210 ;; <https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00312.html>.
211 `((max-silent-time . ,(* 3600 3))))
212 ;; Most of the code is released under BSD-3, except for code originally
213 ;; written for GDC, which is released under GPLv2+, and the DMD frontend,
214 ;; which is released under the "Boost Software License version 1.0".
215 (license (list license:bsd-3
216 license:gpl2+
217 license:boost1.0))))
218
219 (define-public ldc
220 (package
221 (inherit ldc-bootstrap)
222 (arguments
223 (substitute-keyword-arguments (package-arguments ldc-bootstrap)
224 ((#:make-flags _ #f)
225 '(list "all"
226 ;; Also build the test runner binaries.
227 "ldc2-unittest" "all-test-runners"))
228 ((#:configure-flags flags)
229 `(,@flags "-DBUILD_SHARED_LIBS=ON"
230 "-DLDC_LINK_MANUALLY=OFF"
231 "-DLDC_DYNAMIC_COMPILE=OFF"))
232 ((#:tests? _) #t)
233 ((#:phases phases)
234 `(modify-phases ,phases
235 (add-after 'unpack 'fix-compiler-rt-library-discovery
236 (lambda* (#:key inputs #:allow-other-keys)
237 (let ((clang-runtime (assoc-ref inputs "clang-runtime"))
238 (system ,(or (%current-target-system)
239 (%current-system))))
240 (define (gnu-triplet->clang-arch system)
241 (letrec-syntax
242 ((matches (syntax-rules (=>)
243 ((_ (system-prefix => target) rest ...)
244 (if (string-prefix? system-prefix system)
245 target
246 (matches rest ...)))
247 ((_)
248 (error "Clang target for system is unknown"
249 system)))))
250 (matches ("x86_64" => "x86_64")
251 ("i686" => "i386")
252 ("armhf" => "armhf")
253 ("aarch64" => "aarch64"))))
254 ;; Coax LLVM into agreeing with Clang about system target
255 ;; naming.
256 (substitute* "driver/linker-gcc.cpp"
257 (("triple.getArchName\\(\\)")
258 (format #f "~s" (gnu-triplet->clang-arch system))))
259 ;; Augment the configuration of the ldc2 binaries so they can
260 ;; find the compiler-rt libraries they need to be linked with
261 ;; for the tests.
262 (substitute* (find-files "." "^ldc2.*\\.conf\\.in$")
263 ((".*lib-dirs = \\[\n" all)
264 (string-append all
265 " \"" clang-runtime
266 "/lib/linux\",\n"))))))
267 (add-after 'unpack 'patch-paths-in-tests
268 (lambda _
269 (substitute* "tests/d2/dmd-testsuite/Makefile"
270 (("/bin/bash") (which "bash")))
271 (substitute* "tests/linking/linker_switches.d"
272 (("echo") (which "echo")))
273 (substitute* "tests/d2/dmd-testsuite/dshell/test6952.d"
274 (("/usr/bin/env bash")
275 (which "bash")))))
276 (add-after 'unpack 'disable-problematic-tests
277 (lambda* (#:key inputs #:allow-other-keys)
278 ;; Disable unittests in the following files.
279 (substitute* '("runtime/phobos/std/net/curl.d"
280 "runtime/phobos/std/datetime/systime.d"
281 "runtime/phobos/std/datetime/timezone.d")
282 (("version(unittest)") "version(skipunittest)")
283 ((" unittest") " version(skipunittest) unittest"))
284 ;; The following tests plugins we don't have.
285 (delete-file "tests/plugins/addFuncEntryCall/testPlugin.d")
286 ;; The following tests requires AVX instruction set in the CPU.
287 (substitute* "tests/d2/dmd-testsuite/runnable/cdvecfill.sh"
288 (("^// DISABLED: ") "^// DISABLED: linux64 "))
289 ;; This unit test requires networking, fails with
290 ;; "core.exception.RangeError@std/socket.d(778): Range
291 ;; violation".
292 (substitute* "runtime/phobos/std/socket.d"
293 (("assert\\(ih.addrList\\[0\\] == 0x7F_00_00_01\\);.*")
294 ""))
295 ;; The GDB tests suite fails; there are a few bug reports about
296 ;; it upstream.
297 (for-each delete-file (find-files "tests" "gdb.*\\.(d|sh)$"))
298 (delete-file "tests/d2/dmd-testsuite/runnable/debug_info.d")
299 (delete-file "tests/d2/dmd-testsuite/runnable/b18504.d")
300 (substitute* "runtime/druntime/test/exceptions/Makefile"
301 ((".*TESTS\\+=rt_trap_exceptions_drt_gdb.*")
302 ""))
303 ;; The following tests fail on some systems, not all of
304 ;; which are tested upstream.
305 (with-directory-excursion "tests"
306 (cond
307 (,(or (target-x86-32?)
308 (target-arm32?))
309 (for-each delete-file
310 '("PGO/profile_rt_calls.d"
311 "codegen/mangling.d"
312 "instrument/xray_check_pipeline.d"
313 "instrument/xray_link.d"
314 "instrument/xray_simple_execution.d"
315 "sanitizers/msan_noerror.d"
316 "sanitizers/msan_uninitialized.d"
317 "d2/dmd-testsuite/runnable_cxx/cppa.d")))
318 (,(target-aarch64?)
319 (for-each delete-file
320 '("d2/dmd-testsuite/runnable/ldc_cabi1.d"
321 "sanitizers/fuzz_basic.d"
322 "sanitizers/msan_noerror.d"
323 "sanitizers/msan_uninitialized.d")))
324 (#t '())))))
325 (add-before 'configure 'set-cc-and-cxx-to-use-clang
326 ;; The tests require to be built with Clang; build everything
327 ;; with it, for simplicity.
328 (lambda _
329 (setenv "CC" (which "clang"))
330 (setenv "CXX" (which "clang++"))))
331 (replace 'check
332 (lambda* (#:key tests? parallel-tests? #:allow-other-keys)
333 (when tests?
334 (let ((job-count (number->string
335 (or (and parallel-tests?
336 (parallel-job-count))
337 1))))
338 ;; The test targets are tested separately to provide
339 ;; finer-grained diagnostics (see:
340 ;; https://raw.githubusercontent.com/ldc-developers/
341 ;; ldc/master/.azure-pipelines/3-posix-test.yml)
342 (display "running the ldc2 unit tests...\n")
343 (invoke "ctest" "--output-on-failure" "-j" job-count
344 "-R" "ldc2-unittest")
345 (display "running the lit test suite...\n")
346 (invoke "ctest" "--output-on-failure" "-j" job-count
347 "-R" "lit-tests")
348 (display "running the dmd test suite...\n")
349 (invoke "ctest" "--output-on-failure" "-j" job-count
350 "-R" "dmd-testsuite")
351 (display "running the defaultlib unit tests and druntime \
352 integration tests...\n")
353 (invoke "ctest" "--output-on-failure" "-j" job-count
354 "-E" "dmd-testsuite|lit-tests|ldc2-unittest")))))))))
355 (native-inputs
356 (append (delete "llvm"
357 (alist-replace "ldc" (list ldc-bootstrap)
358 (package-native-inputs ldc-bootstrap)))
359 `(("clang" ,clang-11) ;propagates llvm and clang-runtime
360 ("python-lit" ,python-lit))))))
361
362 (define-public dub
363 (package
364 (name "dub")
365 (version "1.23.0")
366 (source
367 (origin
368 (method git-fetch)
369 (uri (git-reference
370 (url "https://github.com/dlang/dub")
371 (commit (string-append "v" version))))
372 (file-name (git-file-name name version))
373 (sha256
374 (base32 "06a4whsl1m600k096nwif83n7za3vr7pj1xwapncy5fcad1gmady"))))
375 (build-system gnu-build-system)
376 (arguments
377 (list #:tests? #f ; tests try to install packages
378 #:phases
379 #~(modify-phases %standard-phases
380 (delete 'configure) ; no configure script
381 (replace 'build
382 (lambda _
383 (setenv "CC" #$(cc-for-target))
384 (setenv "LD" #$(ld-for-target))
385 (invoke "./build.d")))
386 (replace 'install
387 (lambda* (#:key outputs #:allow-other-keys)
388 (let* ((out (assoc-ref outputs "out"))
389 (bin (string-append out "/bin")))
390 (install-file "bin/dub" bin)))))))
391 (inputs
392 (list curl))
393 (native-inputs
394 (list d-tools
395 ldc
396 (module-ref (resolve-interface
397 '(gnu packages commencement))
398 'ld-gold-wrapper)))
399 (home-page "https://code.dlang.org/getting_started")
400 (synopsis "Package and build manager for D projects")
401 (description
402 "DUB is a package and build manager for applications and
403 libraries written in the D programming language. It can
404 automatically retrieve a project's dependencies and integrate
405 them in the build process.
406
407 The design emphasis is on maximum simplicity for simple projects,
408 while providing the opportunity to customize things when
409 needed.")
410 (license license:expat)))
411
412 (define-public gtkd
413 (package
414 (name "gtkd")
415 (version "3.9.0")
416 (source
417 (origin
418 (method url-fetch/zipbomb)
419 (uri (string-append "https://gtkd.org/Downloads/sources/GtkD-"
420 version ".zip"))
421 (sha256
422 (base32 "0qv8qlpwwb1d078pnrf0a59vpbkziyf53cf9p6m8ms542wbcxllp"))))
423 (build-system gnu-build-system)
424 (native-inputs
425 `(("unzip" ,unzip)
426 ("ldc" ,ldc)
427 ("pkg-config" ,pkg-config)
428 ("xorg-server-for-tests" ,xorg-server-for-tests)))
429 (arguments
430 `(#:test-target "test"
431 #:make-flags
432 `("DC=ldc2"
433 ,(string-append "prefix=" (assoc-ref %outputs "out"))
434 ,(string-append "libdir=" (assoc-ref %outputs "out")
435 "/lib"))
436 #:phases
437 (modify-phases %standard-phases
438 (delete 'configure)
439 (add-before 'build 'patch-makefile
440 (lambda* (#:key outputs #:allow-other-keys)
441 (substitute* "GNUmakefile"
442 ;; We do the tests ourselves.
443 (("default-goal: libs test") "default-goal: libs")
444 (("all: libs shared-libs test") "all: libs shared-libs")
445 ;; Work around upstream bug.
446 (("\\$\\(prefix\\)\\/\\$\\(libdir\\)") "$(libdir)"))
447 #t))
448 (add-before 'check 'prepare-x
449 (lambda _
450 (system "Xvfb :1 &")
451 (setenv "DISPLAY" ":1")
452 #t)))))
453 (home-page "https://gtkd.org/")
454 (synopsis "D binding and OO wrapper of GTK+")
455 (description "This package provides bindings to GTK+ for D.")
456 (license license:lgpl2.1)))