gnu: Add rtags.
[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 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2017 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 git-download)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system cmake)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages databases)
36 #:use-module (gnu packages emacs)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages pcre)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages perl)
41 #:use-module (gnu packages texinfo)
42 #:use-module (gnu packages autogen)
43 #:use-module (gnu packages ncurses)
44 #:use-module (gnu packages autotools)
45 #:use-module (gnu packages llvm)
46 #:use-module (gnu packages bash))
47
48 ;;; Tools to deal with source code: metrics, cross-references, etc.
49
50 (define-public cflow
51 (package
52 (name "cflow")
53 (version "1.5")
54 (source (origin
55 (method url-fetch)
56 (uri (string-append "mirror://gnu/cflow/cflow-"
57 version ".tar.bz2"))
58 (sha256
59 (base32
60 "0yq33k5ap1zpnja64n89iai4zh018ffr72wki5a6mzczd880mr3g"))))
61 (build-system gnu-build-system)
62
63 ;; Needed to have cflow-mode.el installed.
64 (native-inputs `(("emacs" ,emacs-minimal)))
65 (arguments
66 '(#:configure-flags (list (string-append "CPPFLAGS="
67 "-D" "CFLOW_PREPROC=\\\""
68 (assoc-ref %build-inputs "gcc")
69 "/bin/cpp\\\""))))
70 (home-page "https://www.gnu.org/software/cflow/")
71 (synopsis "Create a graph of control flow within a program")
72 (description
73 "GNU cflow analyzes C source files and produces a graph charting the
74 control flow of the program. It can output the graph in several styles and
75 in either the POSIX format or in an extended GNU format. cflow also includes
76 a major mode for Emacs for examining the flowcharts that it produces.")
77 (license license:gpl3+)))
78
79 (define-public complexity
80 (package
81 (name "complexity")
82 (version "1.10")
83 (source (origin
84 (method url-fetch)
85 (uri (string-append "mirror://gnu/complexity/complexity-"
86 version ".tar.xz"))
87 (sha256
88 (base32
89 "0lr0l9kj2w3jilz9h9y4np9pf9i9ccpy6331lanki2fnz4z8ldvd"))))
90 (build-system gnu-build-system)
91 (native-inputs
92 `(("texinfo" ,texinfo)
93 ("autogen" ,autogen)))
94 (home-page "https://www.gnu.org/software/complexity/")
95 (synopsis "Analyze complexity of C functions")
96 (description
97 "GNU complexity provides tools for finding procedures that are
98 convoluted, overly long or otherwise difficult to understand. This
99 may help in learning or reviewing unfamiliar code or perhaps
100 highlighting your own code that seemed comprehensible when you wrote it.")
101 (license license:gpl3+)))
102
103 (define-public global ; a global variable
104 (package
105 (name "global")
106 (version "6.6.1")
107 (source (origin
108 (method url-fetch)
109 (uri (string-append "mirror://gnu/global/global-"
110 version ".tar.gz"))
111 (sha256
112 (base32
113 "1r2r6z41lmgbszzwx7h3jqhwnqb9jj32pndzhr3lb0id710c8gcl"))))
114 (build-system gnu-build-system)
115 (inputs `(("ncurses" ,ncurses)
116 ("libltdl" ,libltdl)
117 ("sqlite" ,sqlite)))
118 (arguments
119 `(#:configure-flags
120 (list (string-append "--with-ncurses="
121 (assoc-ref %build-inputs "ncurses"))
122 (string-append "--with-sqlite3="
123 (assoc-ref %build-inputs "sqlite")))
124
125 #:phases
126 (modify-phases %standard-phases
127 (add-after 'install 'post-install
128 (lambda* (#:key outputs #:allow-other-keys)
129 ;; Install the Emacs Lisp file in the right place.
130 (let* ((out (assoc-ref outputs "out"))
131 (data (string-append out "/share/gtags"))
132 (lisp (string-append out "/share/emacs/site-lisp")))
133 (install-file (string-append data "/gtags.el") lisp)
134 (delete-file (string-append data "/gtags.el"))
135 #t))))))
136 (home-page "https://www.gnu.org/software/global/")
137 (synopsis "Cross-environment source code tag system")
138 (description
139 "GLOBAL is a source code tagging system that functions in the same way
140 across a wide array of environments, such as different text editors, shells
141 and web browsers. The resulting tags are useful for quickly moving around in
142 a large, deeply nested project.")
143 (license license:gpl3+)))
144
145 (define-public sloccount
146 (package
147 (name "sloccount")
148 (version "2.26")
149 (source (origin
150 (method url-fetch)
151 (uri (string-append "http://www.dwheeler.com/sloccount/sloccount-"
152 version ".tar.gz"))
153 (sha256
154 (base32
155 "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"))))
156 (build-system gnu-build-system)
157 (arguments
158 '(#:phases (modify-phases %standard-phases
159 (delete 'configure)
160 (add-before 'build 'make-dotl-files-older
161 (lambda _
162 ;; Make the '.l' files as old as the '.c'
163 ;; files to avoid triggering the rule that
164 ;; requires Flex.
165 (define ref
166 (stat "README"))
167
168 (for-each (lambda (file)
169 (set-file-time file ref))
170 (find-files "." "\\.[chl]$"))
171 #t))
172 (add-before 'install 'make-target-directories
173 (lambda* (#:key outputs #:allow-other-keys)
174 (let ((out (assoc-ref outputs "out")))
175 (mkdir-p (string-append out "/bin"))
176 (mkdir-p (string-append out
177 "/share/man/man1"))
178 (mkdir-p (string-append out
179 "/share/doc")))))
180 (replace 'check
181 (lambda _
182 (setenv "HOME" (getcwd))
183 (setenv "PATH"
184 (string-append (getcwd) ":"
185 (getenv "PATH")))
186 (zero? (system* "make" "test")))))
187
188 #:make-flags (list (string-append "PREFIX="
189 (assoc-ref %outputs "out")))))
190 (inputs `(("perl" ,perl)))
191 (home-page "http://www.dwheeler.com/sloccount/")
192 (synopsis "Count physical source lines of code (SLOC)")
193 (description
194 "SLOCCount is a set of the programs for counting source lines of
195 code (SLOC) in large software systems. It can automatically identify and
196 measure a wide range of programming languages. It automatically estimates the
197 effort, time, and money it would take to develop the software, using the
198 COCOMO model or user-provided parameters.")
199 (license license:gpl2+)))
200
201 (define-public cloc
202 (package
203 (name "cloc")
204 (version "1.74")
205 (source
206 (origin
207 (method url-fetch)
208 (uri (string-append
209 "https://github.com/AlDanial/cloc/releases/download/" version
210 "/cloc-" version ".tar.gz"))
211 (sha256
212 (base32
213 "0rq5xfiln1wlv3yr9mg18ax4gskbss786iqaf0v45iv6awyl5b2m"))))
214 (build-system gnu-build-system)
215 (inputs
216 `(("coreutils" ,coreutils)
217 ("perl" ,perl)
218 ("perl-algorithm-diff" ,perl-algorithm-diff)
219 ("perl-regexp-common" ,perl-regexp-common)
220 ("perl-digest-md5" ,perl-digest-md5)))
221 (arguments
222 `(#:phases (modify-phases %standard-phases
223 (delete 'configure)
224 (delete 'build)
225 (replace 'install
226 (lambda* (#:key inputs outputs #:allow-other-keys)
227 (let* ((out (assoc-ref outputs "out")))
228 (zero?
229 (system* "make" "-C" "Unix"
230 (string-append "prefix=" out)
231 (string-append "INSTALL="
232 (assoc-ref inputs "coreutils")
233 "/bin/install")
234 "install")))))
235 (add-after 'install 'wrap-program
236 (lambda* (#:key inputs outputs #:allow-other-keys)
237 (let ((out (assoc-ref outputs "out")))
238 (wrap-program (string-append out "/bin/cloc")
239 `("PERL5LIB" ":" =
240 ,(string-split (getenv "PERL5LIB") #\:)))
241 #t))))
242 #:out-of-source? #t
243 ;; Tests require some other packages.
244 #:tests? #f))
245 (home-page "https://github.com/AlDanial/cloc")
246 (synopsis "Count source lines of code (SLOC) and other source code metrics")
247 (description "cloc counts blank lines, comment lines, and physical lines
248 of source code in many programming languages. Given two versions of a code
249 base, cloc can compute differences in blank, comment, and source lines.
250
251 cloc contains code from David Wheeler's SLOCCount. Compared to SLOCCount,
252 cloc can handle a greater variety of programming languages.")
253 (license license:gpl2+)))
254
255 (define-public the-silver-searcher
256 (package
257 (name "the-silver-searcher")
258 (version "2.0.0")
259 (source (origin
260 (method url-fetch)
261 (uri (string-append
262 "http://geoff.greer.fm/ag/releases/the_silver_searcher-"
263 version ".tar.gz"))
264 (sha256
265 (base32
266 "04wm3r5p2mgv8mdkvysak0d5199h5y0yzl032624brfxpzmqfcq0"))))
267 (build-system gnu-build-system)
268 (native-inputs
269 `(("pkg-config" ,pkg-config)))
270 (inputs
271 `(("pcre" ,pcre)
272 ("xz" ,xz)
273 ("zlib" ,zlib)))
274 (home-page "http://geoff.greer.fm/ag/")
275 (synopsis "Fast code searching tool")
276 (description
277 "The Silver Searcher (@command{ag}) is a tool for quickly searching large
278 numbers of files. It's intended primarily for source code repositories, and
279 respects files like @file{.gitignore} and @file{.hgignore}. It's also an order
280 of magnitude faster than its inspiration, @command{ack}, and less specialised
281 tools such as @command{grep}.")
282 (license license:asl2.0)))
283
284 (define-public trio
285 (package
286 (name "trio")
287 (version "1.16")
288 (source (origin
289 (method url-fetch)
290 (uri (string-append "mirror://sourceforge/ctrio/trio/trio-"
291 version ".tar.gz"))
292 (sha256
293 (base32
294 "02pwd5m5vq7hbrffgm2na1dfc249z50yyr5jv73vdw15bd7ygl44"))))
295 (build-system gnu-build-system)
296 (home-page "http://daniel.haxx.se/projects/trio/")
297 (synopsis "Portable and extendable printf and string functions")
298 (description
299 "Trio is a set of @code{printf} and string functions designed be used by
300 applications with a focus on portability or with the need for additional
301 features that are not supported by the standard @code{stdio} implementation.")
302 ;; This license is very similar to the ISC license, but the wording is
303 ;; slightly different.
304 (license (license:non-copyleft
305 "http://sourceforge.net/p/ctrio/git/ci/master/tree/README"))))
306
307 (define-public withershins
308 (package
309 (name "withershins")
310 (version "0.1")
311 (source (origin
312 (method url-fetch)
313 (uri (string-append
314 "https://github.com/cameronwhite/withershins/archive/v"
315 version ".tar.gz"))
316 (file-name (string-append name "-" version ".tar.gz"))
317 (sha256
318 (base32
319 "08z3lyvswx7sad10637vfpwglbcbgzzcpfihw0x8lzr74f3b70bh"))))
320 (build-system cmake-build-system)
321 (arguments
322 `(#:out-of-source? #f
323 #:phases
324 (modify-phases %standard-phases
325 (add-after
326 'unpack 'find-libiberty
327 (lambda _
328 (let ((libiberty (assoc-ref %build-inputs "libiberty")))
329 (substitute* "cmake/FindIberty.cmake"
330 (("/usr/include") (string-append libiberty "/include"))
331 (("libiberty.a iberty")
332 (string-append "NAMES libiberty.a iberty\nPATHS \""
333 libiberty "/lib" "\"")))
334 #t)))
335 (replace
336 'install
337 (lambda* (#:key outputs #:allow-other-keys)
338 (let* ((out (assoc-ref outputs "out"))
339 (include (string-append out "/include"))
340 (lib (string-append out "/lib")))
341 (mkdir-p include)
342 (install-file "src/withershins.hpp" include)
343 (mkdir-p lib)
344 (install-file "src/libwithershins.a" lib))
345 #t)))))
346 (home-page "https://github.com/cameronwhite/withershins")
347 (inputs
348 `(("libiberty" ,libiberty)
349 ("binutils" ,binutils) ;for libbfd
350 ("zlib" ,zlib)))
351 (synopsis "C++11 library for generating stack traces")
352 (description
353 "Withershins is a simple cross-platform C++11 library for generating
354 stack traces.")
355 ;; Sources are released under Expat license, but since BFD is licensed
356 ;; under the GPLv3+ the combined work is GPLv3+ as well.
357 (license license:gpl3+)))
358
359 (define-public lcov
360 (package
361 (name "lcov")
362 (version "1.12")
363 (source (origin
364 (method url-fetch)
365 (uri (string-append "mirror://sourceforge/ltp/Coverage%20Analysis"
366 "/LCOV-" version "/lcov-" version ".tar.gz"))
367 (sha256
368 (base32
369 "19wfifdpxxivhq9adbphanjfga9bg9spms9v7c3589wndjff8x5l"))))
370 (build-system gnu-build-system)
371 (arguments
372 '(#:make-flags (let ((out (assoc-ref %outputs "out")))
373 (list (string-append "PREFIX=" out)
374 (string-append "BIN_DIR=" out "/bin")
375 (string-append "MAN_DIR=" out "/share/man")))
376 #:phases (modify-phases %standard-phases
377 (delete 'configure))
378 #:tests? #f)) ;no 'check' target
379 (inputs `(("perl" ,perl)))
380 (home-page "http://ltp.sourceforge.net/coverage/lcov.php")
381 (synopsis "Code coverage tool that enhances GNU gcov")
382 (description
383 "LCOV is an extension of @command{gcov}, a tool part of the
384 GNU@tie{}Binutils, which provides information about what parts of a program
385 are actually executed (i.e., \"covered\") while running a particular test
386 case. The extension consists of a set of Perl scripts which build on the
387 textual @command{gcov} output to implement the following enhanced
388 functionality such as HTML output.")
389 (license license:gpl2+)))
390
391 (define-public rtags
392 (package
393 (name "rtags")
394 (version "2.16")
395 (home-page "https://github.com/Andersbakken/rtags")
396 (source (origin
397 (method git-fetch)
398 (uri (git-reference
399 (url home-page)
400 (commit "8ef7554852541eced514c56d5e39d6073f7a2ef9")
401
402 ;; FIXME: This fetches bundled copies of Lua, RCT, and
403 ;; Selene.
404 (recursive? #t)))
405 (sha256
406 (base32
407 "12r7lsqdmcbs9864a6dpblvifqvmfxhvxippyhfnnm2ai5ra80nc"))
408 (file-name (git-file-name name version))))
409 (build-system cmake-build-system)
410 (arguments
411 '(#:configure-flags '("-DBUILD_TESTING=FALSE"
412 "-DRTAGS_NO_ELISP_FILES=1")
413 #:tests? #f))
414 (inputs
415 `(("clang" ,clang)
416 ("llvm" ,llvm)
417 ("bash-completion" ,bash-completion)))
418 (synopsis "Indexer for the C language family with Emacs integration")
419 (description
420 "RTags is a client/server application that indexes C/C++ code and keeps a
421 persistent file-based database of references, declarations, definitions,
422 symbolnames etc. There’s also limited support for ObjC/ObjC++. It allows you
423 to find symbols by name (including nested class and namespace scope). Most
424 importantly we give you proper follow-symbol and find-references support.")
425 (license license:gpl3+)))