gnu: All snippets report errors using exceptions, else return #t.
[jackhill/guix/guix.git] / gnu / packages / code.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
8 ;;; Copyright © 2017 Andy Wingo <wingo@igalia.com>
9 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages code)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system cmake)
32 #:use-module (guix build-system trivial)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages cpp)
37 #:use-module (gnu packages databases)
38 #:use-module (gnu packages emacs)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages graphviz)
41 #:use-module (gnu packages pcre)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages texinfo)
45 #:use-module (gnu packages autogen)
46 #:use-module (gnu packages ncurses)
47 #:use-module (gnu packages autotools)
48 #:use-module (gnu packages llvm)
49 #:use-module (gnu packages lua)
50 #:use-module (gnu packages bash))
51
52 ;;; Tools to deal with source code: metrics, cross-references, etc.
53
54 (define-public cflow
55 (package
56 (name "cflow")
57 (version "1.5")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "mirror://gnu/cflow/cflow-"
61 version ".tar.bz2"))
62 (sha256
63 (base32
64 "0yq33k5ap1zpnja64n89iai4zh018ffr72wki5a6mzczd880mr3g"))))
65 (build-system gnu-build-system)
66
67 ;; Needed to have cflow-mode.el installed.
68 (native-inputs `(("emacs" ,emacs-minimal)))
69 (arguments
70 '(#:configure-flags (list (string-append "CPPFLAGS="
71 "-D" "CFLOW_PREPROC=\\\""
72 (assoc-ref %build-inputs "gcc")
73 "/bin/cpp\\\""))))
74 (home-page "https://www.gnu.org/software/cflow/")
75 (synopsis "Create a graph of control flow within a program")
76 (description
77 "GNU cflow analyzes C source files and produces a graph charting the
78 control flow of the program. It can output the graph in several styles and
79 in either the POSIX format or in an extended GNU format. cflow also includes
80 a major mode for Emacs for examining the flowcharts that it produces.")
81 (license license:gpl3+)))
82
83 (define-public complexity
84 (package
85 (name "complexity")
86 (version "1.10")
87 (source (origin
88 (method url-fetch)
89 (uri (string-append "mirror://gnu/complexity/complexity-"
90 version ".tar.xz"))
91 (sha256
92 (base32
93 "0lr0l9kj2w3jilz9h9y4np9pf9i9ccpy6331lanki2fnz4z8ldvd"))))
94 (build-system gnu-build-system)
95 (native-inputs
96 `(("texinfo" ,texinfo)
97 ("autogen" ,autogen)))
98 (home-page "https://www.gnu.org/software/complexity/")
99 (synopsis "Analyze complexity of C functions")
100 (description
101 "GNU complexity provides tools for finding procedures that are
102 convoluted, overly long or otherwise difficult to understand. This
103 may help in learning or reviewing unfamiliar code or perhaps
104 highlighting your own code that seemed comprehensible when you wrote it.")
105 (license license:gpl3+)))
106
107 (define-public global ; a global variable
108 (package
109 (name "global")
110 (version "6.6.2")
111 (source (origin
112 (method url-fetch)
113 (uri (string-append "mirror://gnu/global/global-"
114 version ".tar.gz"))
115 (sha256
116 (base32
117 "0zvi5vxwiq0dy8mq2cgs64m8harxs0fvkmsnvi0ayb0w608lgij3"))))
118 (build-system gnu-build-system)
119 (inputs `(("ncurses" ,ncurses)
120 ("libltdl" ,libltdl)
121 ("sqlite" ,sqlite)))
122 (arguments
123 `(#:configure-flags
124 (list (string-append "--with-ncurses="
125 (assoc-ref %build-inputs "ncurses"))
126 (string-append "--with-sqlite3="
127 (assoc-ref %build-inputs "sqlite")))
128
129 #:phases
130 (modify-phases %standard-phases
131 (add-after 'install 'post-install
132 (lambda* (#:key outputs #:allow-other-keys)
133 ;; Install the Emacs Lisp file in the right place.
134 (let* ((out (assoc-ref outputs "out"))
135 (data (string-append out "/share/gtags"))
136 (lisp (string-append out "/share/emacs/site-lisp")))
137 (install-file (string-append data "/gtags.el") lisp)
138 (delete-file (string-append data "/gtags.el"))
139 #t))))))
140 (home-page "https://www.gnu.org/software/global/")
141 (synopsis "Cross-environment source code tag system")
142 (description
143 "GNU GLOBAL is a source code tagging system that functions in the same
144 way across a wide array of environments, such as different text editors,
145 shells and web browsers. The resulting tags are useful for quickly moving
146 around in a large, deeply nested project.")
147 (license license:gpl3+)))
148
149 (define-public sloccount
150 (package
151 (name "sloccount")
152 (version "2.26")
153 (source (origin
154 (method url-fetch)
155 (uri (string-append "http://www.dwheeler.com/sloccount/sloccount-"
156 version ".tar.gz"))
157 (sha256
158 (base32
159 "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"))))
160 (build-system gnu-build-system)
161 (arguments
162 '(#:phases (modify-phases %standard-phases
163 (delete 'configure)
164 (add-before 'build 'make-dotl-files-older
165 (lambda _
166 ;; Make the '.l' files as old as the '.c'
167 ;; files to avoid triggering the rule that
168 ;; requires Flex.
169 (define ref
170 (stat "README"))
171
172 (for-each (lambda (file)
173 (set-file-time file ref))
174 (find-files "." "\\.[chl]$"))
175 #t))
176 (add-before 'install 'make-target-directories
177 (lambda* (#:key outputs #:allow-other-keys)
178 (let ((out (assoc-ref outputs "out")))
179 (mkdir-p (string-append out "/bin"))
180 (mkdir-p (string-append out
181 "/share/man/man1"))
182 (mkdir-p (string-append out
183 "/share/doc")))))
184 (replace 'check
185 (lambda _
186 (setenv "HOME" (getcwd))
187 (setenv "PATH"
188 (string-append (getcwd) ":"
189 (getenv "PATH")))
190 (zero? (system* "make" "test")))))
191
192 #:make-flags (list (string-append "PREFIX="
193 (assoc-ref %outputs "out")))))
194 (inputs `(("perl" ,perl)))
195 (home-page "http://www.dwheeler.com/sloccount/")
196 (synopsis "Count physical source lines of code (SLOC)")
197 (description
198 "SLOCCount is a set of the programs for counting source lines of
199 code (SLOC) in large software systems. It can automatically identify and
200 measure a wide range of programming languages. It automatically estimates the
201 effort, time, and money it would take to develop the software, using the
202 COCOMO model or user-provided parameters.")
203 (license license:gpl2+)))
204
205 (define-public cloc
206 (package
207 (name "cloc")
208 (version "1.76")
209 (source
210 (origin
211 (method url-fetch)
212 (uri (string-append
213 "https://github.com/AlDanial/cloc/releases/download/v" version
214 "/cloc-" version ".tar.gz"))
215 (sha256
216 (base32
217 "05srlvzwisr7y7ymvzb5yfdsrspja27ysqdmkwhiiivy84mq2gnl"))))
218 (build-system gnu-build-system)
219 (inputs
220 `(("coreutils" ,coreutils)
221 ("perl" ,perl)
222 ("perl-algorithm-diff" ,perl-algorithm-diff)
223 ("perl-digest-md5" ,perl-digest-md5)
224 ("perl-parallel-forkmanager" ,perl-parallel-forkmanager)
225 ("perl-regexp-common" ,perl-regexp-common)))
226 (arguments
227 `(#:phases (modify-phases %standard-phases
228 (delete 'configure)
229 (delete 'build)
230 (replace 'install
231 (lambda* (#:key inputs outputs #:allow-other-keys)
232 (let* ((out (assoc-ref outputs "out")))
233 (invoke "make" "-C" "Unix"
234 (string-append "prefix=" out)
235 (string-append "INSTALL="
236 (assoc-ref inputs "coreutils")
237 "/bin/install")
238 "install")
239 #t)))
240 (add-after 'install 'wrap-program
241 (lambda* (#:key inputs outputs #:allow-other-keys)
242 (let ((out (assoc-ref outputs "out")))
243 (wrap-program (string-append out "/bin/cloc")
244 `("PERL5LIB" ":" =
245 ,(string-split (getenv "PERL5LIB") #\:)))
246 #t))))
247 #:out-of-source? #t
248 ;; Tests require some other packages.
249 #:tests? #f))
250 (home-page "https://github.com/AlDanial/cloc")
251 (synopsis "Count source lines of code (SLOC) and other source code metrics")
252 (description "cloc counts blank lines, comment lines, and physical lines
253 of source code in many programming languages. Given two versions of a code
254 base, cloc can compute differences in blank, comment, and source lines.
255
256 cloc contains code from David Wheeler's SLOCCount. Compared to SLOCCount,
257 cloc can handle a greater variety of programming languages.")
258 (license license:gpl2+)))
259
260 (define-public the-silver-searcher
261 (package
262 (name "the-silver-searcher")
263 (version "2.1.0")
264 (source (origin
265 (method url-fetch)
266 (uri (string-append
267 "http://geoff.greer.fm/ag/releases/the_silver_searcher-"
268 version ".tar.gz"))
269 (sha256
270 (base32
271 "1m0mih1x4jpswc8ganhqh0gmwbmd2hzmz7402mxfh19s3kcjnrfl"))))
272 (build-system gnu-build-system)
273 (native-inputs
274 `(("pkg-config" ,pkg-config)))
275 (inputs
276 `(("pcre" ,pcre)
277 ("xz" ,xz)
278 ("zlib" ,zlib)))
279 (home-page "http://geoff.greer.fm/ag/")
280 (synopsis "Fast code searching tool")
281 (description
282 "The Silver Searcher (@command{ag}) is a tool for quickly searching large
283 numbers of files. It's intended primarily for source code repositories, and
284 respects files like @file{.gitignore} and @file{.hgignore}. It's also an order
285 of magnitude faster than its inspiration, @command{ack}, and less specialised
286 tools such as @command{grep}.")
287 (license license:asl2.0)))
288
289 (define-public trio
290 (package
291 (name "trio")
292 (version "1.16")
293 (source (origin
294 (method url-fetch)
295 (uri (string-append "mirror://sourceforge/ctrio/trio/trio-"
296 version ".tar.gz"))
297 (sha256
298 (base32
299 "02pwd5m5vq7hbrffgm2na1dfc249z50yyr5jv73vdw15bd7ygl44"))))
300 (build-system gnu-build-system)
301 (home-page "http://daniel.haxx.se/projects/trio/")
302 (synopsis "Portable and extendable printf and string functions")
303 (description
304 "Trio is a set of @code{printf} and string functions designed be used by
305 applications with a focus on portability or with the need for additional
306 features that are not supported by the standard @code{stdio} implementation.")
307 ;; This license is very similar to the ISC license, but the wording is
308 ;; slightly different.
309 (license (license:non-copyleft
310 "http://sourceforge.net/p/ctrio/git/ci/master/tree/README"))))
311
312 (define-public withershins
313 (package
314 (name "withershins")
315 (version "0.1")
316 (source (origin
317 (method url-fetch)
318 (uri (string-append
319 "https://github.com/cameronwhite/withershins/archive/v"
320 version ".tar.gz"))
321 (file-name (string-append name "-" version ".tar.gz"))
322 (sha256
323 (base32
324 "08z3lyvswx7sad10637vfpwglbcbgzzcpfihw0x8lzr74f3b70bh"))))
325 (build-system cmake-build-system)
326 (arguments
327 `(#:out-of-source? #f
328 #:phases
329 (modify-phases %standard-phases
330 (add-after
331 'unpack 'find-libiberty
332 (lambda _
333 (let ((libiberty (assoc-ref %build-inputs "libiberty")))
334 (substitute* "cmake/FindIberty.cmake"
335 (("/usr/include") (string-append libiberty "/include"))
336 (("libiberty.a iberty")
337 (string-append "NAMES libiberty.a iberty\nPATHS \""
338 libiberty "/lib" "\"")))
339 #t)))
340 (replace
341 'install
342 (lambda* (#:key outputs #:allow-other-keys)
343 (let* ((out (assoc-ref outputs "out"))
344 (include (string-append out "/include"))
345 (lib (string-append out "/lib")))
346 (mkdir-p include)
347 (install-file "src/withershins.hpp" include)
348 (mkdir-p lib)
349 (install-file "src/libwithershins.a" lib))
350 #t)))))
351 (home-page "https://github.com/cameronwhite/withershins")
352 (inputs
353 `(("libiberty" ,libiberty)
354 ("binutils" ,binutils) ;for libbfd
355 ("zlib" ,zlib)))
356 (synopsis "C++11 library for generating stack traces")
357 (description
358 "Withershins is a simple cross-platform C++11 library for generating
359 stack traces.")
360 ;; Sources are released under Expat license, but since BFD is licensed
361 ;; under the GPLv3+ the combined work is GPLv3+ as well.
362 (license license:gpl3+)))
363
364 (define-public lcov
365 (package
366 (name "lcov")
367 (version "1.13")
368 (source (origin
369 (method url-fetch)
370 (uri (string-append "mirror://sourceforge/ltp/Coverage%20Analysis"
371 "/LCOV-" version "/lcov-" version ".tar.gz"))
372 (sha256
373 (base32
374 "08wabnb0gcjqk0qc65a6cgbbmz6b8lvam3p7byh0dk42hj3jr5s4"))))
375 (build-system gnu-build-system)
376 (arguments
377 '(#:make-flags
378 (let ((out (assoc-ref %outputs "out")))
379 (list (string-append "PREFIX=" out)))
380 #:phases
381 (modify-phases %standard-phases
382 (delete 'configure)) ; no configure script
383 #:tests? #f)) ; no 'check' target
384 (inputs `(("perl" ,perl)))
385 (home-page "http://ltp.sourceforge.net/coverage/lcov.php")
386 (synopsis "Code coverage tool that enhances GNU gcov")
387 (description
388 "LCOV is an extension of @command{gcov}, a tool part of the
389 GNU@tie{}Binutils, which provides information about what parts of a program
390 are actually executed (i.e., \"covered\") while running a particular test
391 case. The extension consists of a set of Perl scripts which build on the
392 textual @command{gcov} output to implement the following enhanced
393 functionality such as HTML output.")
394 (license license:gpl2+)))
395
396 (define-public rtags
397 (package
398 (name "rtags")
399 (version "2.18")
400 (home-page "https://github.com/Andersbakken/rtags")
401 (source
402 (origin
403 (method url-fetch)
404 (uri
405 (string-append home-page "/archive/v" version ".tar.gz"))
406 (file-name (string-append name "-" version ".tar.gz"))
407 (patches (search-patches "rtags-separate-rct.patch"))
408 (modules '((guix build utils)))
409 (snippet
410 ;; Part of spliting rct with rtags.
411 ;; Substitute #include "rct/header.h" with #include <rct/header.h>.
412 '(with-directory-excursion "src"
413 (delete-file-recursively "rct") ;remove bundled copy
414 (let ((files (find-files "." ".*\\.cpp|.*\\.h")))
415 (substitute* files
416 (("#include ?\"rct/(.*.h)\"" all header)
417 (string-append "#include <rct/" header ">")))
418 #t)))
419 (sha256
420 (base32
421 "0scjbp1z201q8njvrxqz7lk2m9b6k2rxd5q1shrng6532r7ndif2"))))
422 (build-system cmake-build-system)
423 (arguments
424 '(#:configure-flags
425 '("-DRTAGS_NO_ELISP_FILES=1"
426 "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
427 "-DCMAKE_CXX_FLAGS=-std=c++11"
428 "-DBUILD_TESTING=FALSE")
429 #:tests? #f))
430 (native-inputs
431 `(("pkg-config" ,pkg-config)))
432 (inputs
433 `(("bash-completion" ,bash-completion)
434 ("clang" ,clang)
435 ("llvm" ,llvm)
436 ("lua" ,lua)
437 ("rct" ,rct)
438 ("selene" ,selene)))
439 (synopsis "Indexer for the C language family with Emacs integration")
440 (description
441 "RTags is a client/server application that indexes C/C++ code and keeps a
442 persistent file-based database of references, declarations, definitions,
443 symbolnames etc. There’s also limited support for ObjC/ObjC++. It allows you
444 to find symbols by name (including nested class and namespace scope). Most
445 importantly we give you proper follow-symbol and find-references support.")
446 (license license:gpl3+)))
447
448 (define-public colormake
449 (package
450 (name "colormake")
451 (version "0.9.20140503")
452 (source
453 (origin
454 (method url-fetch)
455 (uri (string-append "https://github.com/pagekite/Colormake/archive/"
456 version ".tar.gz"))
457 (file-name (string-append name "-" version ".tar.gz"))
458 (sha256
459 (base32
460 "08ldss9zd8ls6bjahvxhffpsjcysifr720yf3jz9db2mlklzmyd3"))))
461 (build-system trivial-build-system)
462 (native-inputs
463 `(("bash" ,bash)
464 ("gzip" ,gzip)
465 ("perl" ,perl)
466 ("tar" ,tar)))
467 (arguments
468 `(#:modules ((guix build utils))
469 #:builder
470 (begin
471 (use-modules (guix build utils))
472 ;; bootstrap
473 (setenv "PATH" (string-append
474 (assoc-ref %build-inputs "tar") "/bin" ":"
475 (assoc-ref %build-inputs "gzip") "/bin"))
476 (invoke "tar" "xvf" (assoc-ref %build-inputs "source"))
477 (chdir (string-append (string-capitalize ,name) "-" ,version))
478 (patch-shebang "colormake.pl"
479 (list (string-append (assoc-ref %build-inputs "perl")
480 "/bin")))
481 (let* ((out (assoc-ref %outputs "out"))
482 (bin (string-append out "/bin"))
483 (doc (string-append out "/share/doc"))
484 (install-files (lambda (files directory)
485 (for-each (lambda (file)
486 (install-file file directory))
487 files))))
488 (substitute* "colormake"
489 (("colormake\\.pl") (string-append bin "/colormake.pl"))
490 (("/bin/bash")
491 (string-append (assoc-ref %build-inputs "bash") "/bin/sh")))
492 (install-file "colormake.1" (string-append doc "/man/man1"))
493 (install-files '("AUTHORS" "BUGS" "ChangeLog" "README") doc)
494 (install-files '("colormake" "colormake-short" "clmake"
495 "clmake-short" "colormake.pl")
496 bin)))))
497 (home-page "http://bre.klaki.net/programs/colormake/")
498 (synopsis "Wrapper around @command{make} to produce colored output")
499 (description "This package provides a wrapper around @command{make} to
500 produce colored output.")
501 (license license:gpl2+)))
502
503 (define-public makefile2graph
504 (package
505 (name "makefile2graph")
506 (version "1.5.0")
507 (source (origin
508 (method url-fetch)
509 (uri (string-append "https://github.com/lindenb/" name
510 "/archive/v" version ".tar.gz"))
511 (sha256
512 (base32
513 "0h1vchkpmm9h6s87p5nf0ksjxcmsxpx8k62a508w428n570wcr4l"))
514 (file-name (string-append name "-" version ".tar.gz"))))
515 (build-system gnu-build-system)
516 (arguments
517 '(#:test-target "test"
518 #:make-flags (list "CC=gcc" (string-append "prefix=" %output))
519 #:phases
520 (modify-phases %standard-phases
521 (delete 'configure))))
522 (native-inputs
523 `(("graphviz" ,graphviz)))
524 (home-page "https://github.com/lindenb/makefile2graph")
525 (synopsis "Creates a graph of dependencies from GNU Make")
526 (description
527 "@code{make2graph} creates a graph of dependencies from GNU Make. The
528 output is a graphviz-dot file, a Gexf-XML file or a list of the deepest
529 independent targets.")
530 (license license:expat)))