;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2015, 2018, 2020, 2021, 2023 Ludovic Courtès ;;; Copyright © 2013, 2015 Andreas Enge ;;; Copyright © 2015, 2018 Ricardo Wurmus ;;; Copyright © 2016, 2017, 2019-2024 Efraim Flashner ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2017, 2018 Clément Lassieur ;;; Copyright © 2017 Andy Wingo ;;; Copyright © 2018 Fis Trivial ;;; Copyright © 2018 Pierre Neidhardt ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2014 Mark H Weaver ;;; Copyright © 2019 Hartmut Goebel ;;; Copyright © 2020, 2022 Maxim Cournoyer ;;; Copyright © 2020, 2021, 2023 Marius Bakke ;;; Copyright © 2020 Julien Lepiller ;;; Copyright © 2021 lu hui ;;; Copyright © 2021, 2022 Foo Chuan Wei ;;; Copyright © 2022 Michael Rohleder ;;; Copyright © 2023 Fries ;;; Copyright © 2023 Zheng Junjie <873216071@qq.com> ;;; Copyright © 2024 Sharlatan Hellseher ;;; Copyright © 2024 Artyom V. Poptsov ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages code) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix utils) #:use-module (guix download) #:use-module (guix git-download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix build-system gnu) #:use-module (guix build-system cmake) #:use-module (guix build-system python) #:use-module (guix build-system trivial) #:use-module (guix build-system go) #:use-module (gnu packages) #:use-module (gnu packages autogen) #:use-module (gnu packages autotools) 2023-09-09. '(with-directory-excursion "src" (delete-file-recursively "rct") ;remove bundled copy (let ((files (find-files "." ".*\\.cpp|.*\\.h"))) (substitute* files (("#include ?\"rct/(.*.h)\"" all header) (string-append "#include "))) #t))) (sha256 (base32 "0raqjbkl1ykga4ahgl9xw49cgh3cyqcf42z36z7d6fz1fw192kg0")))) (build-system cmake-build-system) (arguments '(#:build-type "RelWithDebInfo" #:configure-flags '("-DRTAGS_NO_ELISP_FILES=1" "-DBUILD_TESTING=FALSE") #:tests? #f)) (native-inputs (list pkg-config)) (inputs (list bash-completion clang llvm lua rct selene)) (home-page "https://github.com/Andersbakken/rtags") (synopsis "Indexer for the C language family with Emacs integration") (description "RTags is a client/server application that indexes C/C++ code and keeps a persistent file-based database of references, declarations, definitions, symbolnames etc. There’s also limited support for ObjC/ObjC++. It allows you to find symbols by name (including nested class and namespace scope). Most importantly we give you proper follow-symbol and find-references support.") (license license:gpl3+))) (define-public colormake (package (name "colormake") (version "0.9.20140503") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/pagekite/Colormake") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1f9v5s0viq4yc9iv6701h3pv7j21zz1ckl37lpp9hsnliiizv03p")))) (build-system trivial-build-system) (native-inputs (list bash perl)) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (copy-recursively (assoc-ref %build-inputs "source") "source") (chdir "source") (patch-shebang "colormake.pl" (list (string-append (assoc-ref %build-inputs "perl") "/bin"))) (let* ((out (assoc-ref %outputs "out")) (bin (string-append out "/bin")) (doc (string-append out "/share/doc")) (install-files (lambda (files directory) (for-each (lambda (file) (install-file file directory)) files)))) (substitute* "colormake" (("colormake\\.pl") (string-append bin "/colormake.pl")) (("/bin/bash") (search-input-file %build-inputs "/bin/sh"))) (install-file "colormake.1" (string-append doc "/man/man1")) (install-files '("AUTHORS" "BUGS" "ChangeLog" "README") doc) (install-files '("colormake" "colormake-short" "clmake" "clmake-short" "colormake.pl") bin) #t)))) (home-page "https://bre.klaki.net/programs/colormake/") (synopsis "Wrapper around @command{make} to produce colored output") (description "This package provides a wrapper around @command{make} to produce colored output.") (license license:gpl2+))) (define-public makefile2graph (package (name "makefile2graph") (version "1.5.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/lindenb/makefile2graph") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1gjfk3d8qg3cla7qd2y7r9s03whlfwy83q8k76xfcnqrjjfavdgk")))) (build-system gnu-build-system) (arguments (list #:test-target "test" #:make-flags #~(list (string-append "CC=" #$(cc-for-target)) (string-append "prefix=" #$output)) #:phases #~(modify-phases %standard-phases (delete 'configure)))) (native-inputs (list graphviz)) (home-page "https://github.com/lindenb/makefile2graph") (synopsis "Creates a graph of dependencies from GNU Make") (description "@code{make2graph} creates a graph of dependencies from GNU Make. The output is a graphviz-dot file, a Gexf-XML file or a list of the deepest independent targets.") (license license:expat))) (define-public uncrustify (package (name "uncrustify") (version "0.77.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/uncrustify/uncrustify/") (commit (string-append name "-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "17x9p5pqgzjchi9xhskp4kq7ag4chmsgbkvwym5m2b9zwm6qykpm")))) (build-system cmake-build-system) (native-inputs (list python-wrapper)) (arguments (list #:phases #~(modify-phases %standard-phases (add-after 'unpack 'unpack-etc (lambda* (#:key inputs outputs #:allow-other-keys) ;; Configuration samples are not installed by default. (let* ((output (assoc-ref outputs "out")) (etcdir (string-append output "/etc"))) (for-each (lambda (l) (install-file l etcdir)) (find-files "etc" "\\.cfg$")))))))) (home-page "https://uncrustify.sourceforge.net/") (synopsis "Code formatter for C and other related languages") (description "Beautify source code in many languages of the C family (C, C++, C#, Objective@tie{}C, D, Java, Pawn, and Vala). Features: @itemize @item Indent and align code. @item Reformat comments (a little bit). @item Fix inter-character spacing. @item Add or remove parens / braces. @item Supports embedded SQL @code{EXEC SQL} stuff. @item Highly configurable - More than 600 configurable options. @end itemize\n") (license license:gpl2+))) (define-public astyle (package (name "astyle") (version "3.5") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/astyle/astyle/astyle%20" version "/astyle-" version ".tar.bz2")) (sha256 (base32 "0g4jyp47iz97ld9ac4wb5k59j4cs8dbw4dp8f32bwqx8pyvirz6y")))) (build-system gnu-build-system) (arguments (list #:tests? #f ;no tests #:make-flags #~(list (string-append "prefix=" #$output) "INSTALL=install" "release" "shared") #:phases #~(modify-phases %standard-phases (add-after 'unpack 'patch-makefile (lambda _ (substitute* "build/gcc/Makefile" (("CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions -std=c\\+\\+11") "CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions -std=c++17")))) (replace 'configure (lambda _ (chdir "build/gcc"))) (add-after 'install 'install-more (lambda* (#:key outputs #:allow-other-keys) ;; Libraries and headers aren't installed by default. (let ((include (string-append #$output "/include")) (lib (string-append #$output "/lib"))) (mkdir-p include) (copy-file "../../src/astyle.h" (string-append include "/astyle.h")) (mkdir-p lib) (for-each (lambda (l) (copy-file l (string-append lib "/" (basename l)))) (find-files "bin" "^lib.*\\.so")))))))) (home-page "https://astyle.sourceforge.net/") (synopsis "Source code indenter, formatter, and beautifier") (description "Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C++/CLI, Objective‑C, C#, and Java programming languages.") (license license:lgpl3+))) (define-public indent (package (name "indent") (version "2.2.13") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/indent/indent-" version ".tar.gz")) (sha256 (base32 "15c0ayp9rib7hzvrcxm5ijs0mpagw5y8kf5w0jr9fryfqi7n6r4y")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-after 'unpack 'fix-docdir (lambda _ ;; Although indent uses a modern autoconf in which docdir ;; defaults to PREFIX/share/doc, the doc/Makefile.am ;; overrides this to be in PREFIX/doc. Fix this. (substitute* "doc/Makefile.in" (("^docdir = .*$") "docdir = @docdir@\n")) #t)) (add-after 'unpack 'fix-configure (lambda* (#:key inputs native-inputs #:allow-other-keys) ;; Replace outdated config.sub and config.guess: (with-directory-excursion "config" (for-each (lambda (file) (install-file (string-append (assoc-ref (or native-inputs inputs) "automake") "/share/automake-" ,(version-major+minor (package-version automake)) "/" file) ".")) '("config.sub" "config.guess"))) #t))))) (native-inputs (list texinfo automake)) ; For up to date 'config.guess' and 'config.sub'. (synopsis "Code reformatter") (description "Indent is a program that makes source code easier to read by reformatting it in a consistent style. It can change the style to one of several different styles such as GNU, BSD or K&R. It has some flexibility to deal with incomplete or malformed syntax. GNU indent offers several extensions over the standard utility.") (license license:gpl3+) (home-page "https://www.gnu.org/software/indent/"))) (define-public amalgamate (let* ((commit "c91f07eea1133aa184f652b8f1398eaf03586208") (revision "0") (version (git-version "1.1.1" revision commit))) (package (name "amalgamate") (version version) (home-page "https://github.com/edlund/amalgamate") (source (origin (method git-fetch) (uri (git-reference (url home-page) (commit commit))) (sha256 (base32 "0cllaraw8mxs8q2nr28nhgzkb417gj2wcklqg59w84f4lc78k3yb")) (file-name (git-file-name name version)) (modules '((guix build utils))) (snippet '(substitute* "test.sh" (("test_command \"cc -Wall -Wextra -o source.out source.c\"" all) "test_command \"gcc -Wall -Wextra -o source.out source.c\""))))) (build-system gnu-build-system) (inputs (list python-wrapper)) (arguments `(#:phases (modify-phases %standard-phases (delete 'configure) (delete 'build) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin"))) (install-file "amalgamate.py" bin)))) (replace 'check (lambda _ (invoke "./test.sh")))))) (synopsis "Tool for amalgamating C source and header files") ;; The package is indeed a script file, and the term "amalgamate.py" is ;; used by upstream. (description "amalgamate.py aims to make it easy to use SQLite-style C source and header amalgamation in projects.") (license license:bsd-3)))) (define-public cdecl (package (name "cdecl") (version "2.5") (source (origin (method url-fetch) (uri (string-append "https://www.ibiblio.org/pub/linux/devel/lang/c/cdecl-" version ".tar.gz")) (sha256 (base32 "0dm98bp186r4cihli6fmcwzjaadgwl1z3b0zdxfik8h7hkqawk5p")))) (build-system gnu-build-system) (arguments `(#:make-flags ,#~(list "LIBS=-lreadline" (string-append "BINDIR=" #$output "/bin") (string-append "MANDIR=" #$output "/share/man/man1")) #:phases (modify-phases %standard-phases (delete 'configure) ; No configure script. (add-after 'unpack 'fix-build (lambda _ (substitute* "Makefile" (("lex cdlex.l") "flex cdlex.l")) (substitute* "cdecl.c" ;; Fix "error: conflicting types for ‘getline’". (("char \\* getline\\(\\)") "char * our_getline(void)") (("char \\* getline \\(\\)") "char * our_getline(void)") (("line = getline\\(\\)") "line = our_getline()") ;; Fix "error: conflicting types for ‘getopt’". (("int getopt\\(int,char \\*\\*,char \\*\\);") "") ;; Fix invalid use of "restrict" as a variable name. (("i, j, restrict") "i, j, restriction") (("restrict =") "restriction =") ;; Fix "warning: implicit declaration of function ‘add_history’". (("# include " all) (string-append all "\n# include ")) ;; Fix "warning: implicit declaration of function ‘dotmpfile_from_string’". (("void setprogname\\(char \\*\\);" all) (string-append all "\nint dotmpfile_from_string(char *);")) ;; Fix "warning: implicit declaration of function ‘completion_matches’". (("matches = completion_matches\\(text, command_completion\\);") "matches = rl_completion_matches(text, command_completion);") (("char \\* command_completion\\(char \\*, int\\);") "char * command_completion(const char *, int);") (("char \\* command_completion\\(char \\*text, int flag\\)") "char * command_completion(const char *text, int flag)") ;; Fix "warning: ‘CPPFunction’ is deprecated". (("rl_attempted_completion_function = \\(CPPFunction \\*\\)attempt_completion;") "rl_attempted_completion_function = (rl_completion_func_t *)attempt_completion;") ;; Fix "warning: ‘Function’ is deprecated". (("rl_completion_entry_function = \\(Function \\*\\)keyword_completion;") "rl_completion_entry_function = (rl_compentry_func_t *)keyword_completion;")) ;; Fix typo in man page. (substitute* "cdecl.1" (("\t::= auto \\| extern \\| register \\| auto") "\t::= auto | extern | register | static")))) (add-before 'install 'create-directories (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin")) (man (string-append out "/share/man/man1"))) (mkdir-p bin) (mkdir-p man))))) #:tests? #f)) ; No "check" target. (native-inputs (list bison flex)) (inputs (list readline)) (home-page "https://www.ibiblio.org/pub/linux/devel/lang/c/") (synopsis "Turn English phrases into C or C++ declarations and vice versa") (description "@code{cdecl} is a program that turns English-like phrases into C declarations. It can also translate C into pseudo-English. It also handles type casts and C++. It has command-line editing and history with the GNU Readline library.") (license license:public-domain))) (define-public cscope (package (name "cscope") (version "15.9") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/cscope/cscope/" "v" version "/cscope-" version ".tar.gz")) (sha256 (base32 "0ngiv4aj3rr35k3q3wjx0y19gh7i1ydqa0cqip6sjwd8fph5ll65")))) (build-system gnu-build-system) (inputs (list ncurses)) (arguments `(#:configure-flags ;; Specify the correct ncurses directory to prevent incorrect fallback ;; on SysV curses. (list (string-append "--with-ncurses=" (assoc-ref %build-inputs "ncurses"))))) (home-page "https://cscope.sourceforge.net") (synopsis "Tool for browsing source code") (description "Cscope is a text screen based source browsing tool. Although it is primarily designed to search C code (including lex and yacc files), it can also be used for C++ code. Using cscope, you can easily search for where symbols are used and defined.") (license license:bsd-3))) (define-public xenon (package (name "xenon") (version "0.9.0") (source (origin (method url-fetch) (uri (pypi-uri "xenon" version)) (sha256 (base32 "1f4gynjzfckm3rjfywwgz1c7icfx3zjqirf16aj73xv0c9ncpffj")))) (build-system python-build-system) (arguments (list #:tests? #f)) ;test suite not shipped with the PyPI archive (inputs (list python-pyyaml python-radon python-requests)) (home-page "https://xenon.readthedocs.org/") (synopsis "Monitor code metrics for Python on your CI server") (description "Xenon is a monitoring tool based on Radon. It monitors code complexity. Ideally, @code{xenon} is run every time code is committed. Through command line options, various thresholds can be set for the complexity of code. It will fail (i.e., it will exit with a non-zero exit code) when any of these requirements is not met.") (license license:expat))) (define-public python-xenon (deprecated-package "python-xenon" xenon))