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>
13 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
57 (define-public d-tools
65 (url "https://github.com/dlang/tools")
66 (commit (string-append "v" version))))
67 (file-name (git-file-name name version))
69 (base32 "1jbn0hyskv4ykcckw0iganpyrm0bq2lggswspw21r4hgnxkmjbyw"))))
70 (build-system gnu-build-system)
73 #~(modify-phases %standard-phases
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"))))
84 (lambda* (#:key tests? #:allow-other-keys)
86 (invoke "bin/rdmd" "rdmd_test.d" "bin/rdmd"
87 "--rdmd-default-compiler" "ldmd2"))))
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)))))))
98 (module-ref (resolve-interface
99 '(gnu packages commencement))
101 (home-page "https://github.com/dlang/tools")
102 (synopsis "Useful D-related tools")
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)))
110 (let ((commit "ff2c97a47408fb71c18a2d453294d18808a97cc5")
114 (version (git-version "0.1.0" revision commit))
119 (url "https://github.com/D-Programming-GDC/gdmd")
121 (file-name (git-file-name name version))
123 (base32 "0pd70clk70069xcjysaas7zszzmigrcw1zl2xxv8kzdg7y7xrzvm"))))
124 (build-system copy-build-system)
128 #~'(("dmd-script" "bin/gdmd")
129 ("dmd-script.1" "share/man/man1/gdmd.1"))
131 #~(modify-phases %standard-phases
132 (add-after 'unpack 'adjust-gdc-location
133 (lambda* (#:key inputs #:allow-other-keys)
134 (substitute* "dmd-script"
136 (string-append "my $gdc_dir = \""
137 (dirname (search-input-file inputs "/bin/gdc"))
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+))))
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
156 (uri (string-append "https://github.com/ldc-developers/ldc/releases"
157 "/download/v" version "/ldc-" version "-src.tar.gz"))
159 (base32 "1775001ba6n8w46ln530kb5r66vs935ingnppgddq8wqnc0gbj4k"))))
160 (build-system cmake-build-system)
162 `(#:tests? #f ;skip in the bootstrap
163 #:build-type "Release"
166 #:make-flags ;used as build targets
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")))))
176 ;; Building with Make would result in "make: *** [Makefile:166:
178 (lambda* (#:key make-flags parallel-tests? #:allow-other-keys)
179 (let ((job-count (number->string (or (and parallel-tests?
180 (parallel-job-count))
182 (apply invoke "cmake" "--build" "." "-j" job-count
183 "--target" make-flags))))
186 (invoke "cmake" "--install" "."))))))
188 `(("libconfig" ,libconfig)
193 ;; Importing (gnu packages commencement) would introduce a cycle.
194 `(("ld-gold-wrapper" ,(module-ref (resolve-interface
195 '(gnu packages commencement))
200 ("python-wrapper" ,python-wrapper)
202 (home-page "http://wiki.dlang.org/LDC")
203 (synopsis "LLVM-based compiler for the D programming language")
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.")
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
221 (inherit ldc-bootstrap)
223 (substitute-keyword-arguments (package-arguments ldc-bootstrap)
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"))
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)
240 (define (gnu-triplet->clang-arch system)
242 ((matches (syntax-rules (=>)
243 ((_ (system-prefix => target) rest ...)
244 (if (string-prefix? system-prefix system)
248 (error "Clang target for system is unknown"
250 (matches ("x86_64" => "x86_64")
253 ("aarch64" => "aarch64"))))
254 ;; Coax LLVM into agreeing with Clang about system target
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
262 (substitute* (find-files "." "^ldc2.*\\.conf\\.in$")
263 ((".*lib-dirs = \\[\n" all)
266 "/lib/linux\",\n"))))))
267 (add-after 'unpack 'patch-paths-in-tests
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")
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
292 (substitute* "runtime/phobos/std/socket.d"
293 (("assert\\(ih.addrList\\[0\\] == 0x7F_00_00_01\\);.*")
295 ;; The GDB tests suite fails; there are a few bug reports about
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.*")
303 ;; The following tests fail on some systems, not all of
304 ;; which are tested upstream.
305 (with-directory-excursion "tests"
307 (,(or (target-x86-32?)
309 (for-each delete-file
310 '("PGO/profile_rt_calls.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")))
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")))
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.
329 (setenv "CC" (which "clang"))
330 (setenv "CXX" (which "clang++"))))
332 (lambda* (#:key tests? parallel-tests? #:allow-other-keys)
334 (let ((job-count (number->string
335 (or (and parallel-tests?
336 (parallel-job-count))
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
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")))))))))
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))))))
370 (url "https://github.com/dlang/dub")
371 (commit (string-append "v" version))))
372 (file-name (git-file-name name version))
374 (base32 "06a4whsl1m600k096nwif83n7za3vr7pj1xwapncy5fcad1gmady"))))
375 (build-system gnu-build-system)
377 (list #:tests? #f ; tests try to install packages
379 #~(modify-phases %standard-phases
380 (delete 'configure) ; no configure script
383 (setenv "CC" #$(cc-for-target))
384 (setenv "LD" #$(ld-for-target))
385 (invoke "./build.d")))
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)))))))
396 (module-ref (resolve-interface
397 '(gnu packages commencement))
399 (home-page "https://code.dlang.org/getting_started")
400 (synopsis "Package and build manager for D projects")
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.
407 The design emphasis is on maximum simplicity for simple projects,
408 while providing the opportunity to customize things when
410 (license license:expat)))
418 (method url-fetch/zipbomb)
419 (uri (string-append "https://gtkd.org/Downloads/sources/GtkD-"
422 (base32 "0qv8qlpwwb1d078pnrf0a59vpbkziyf53cf9p6m8ms542wbcxllp"))))
423 (build-system gnu-build-system)
427 ("pkg-config" ,pkg-config)
428 ("xorg-server-for-tests" ,xorg-server-for-tests)))
430 `(#:test-target "test"
433 ,(string-append "prefix=" (assoc-ref %outputs "out"))
434 ,(string-append "libdir=" (assoc-ref %outputs "out")
437 (modify-phases %standard-phases
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)"))
448 (add-before 'check 'prepare-x
451 (setenv "DISPLAY" ":1")
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)))