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