projects/guix·blob python-team · refs

233 lines · 9.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2026 Cayetano Santos <[email protected]>
3;;; Copyright © 2022-2023 Efraim Flashner <[email protected]>
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu packages computer-architecture)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix build-system qt)
23 #:use-module (guix build-system scons)
24 #:use-module (guix gexp)
25 #:use-module (guix git-download)
26 #:use-module (guix packages)
27 #:use-module (guix utils)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages boost)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages cpp)
32 #:use-module (gnu packages electronics)
33 #:use-module (gnu packages engineering)
34 #:use-module (gnu packages graphviz)
35 #:use-module (gnu packages image)
36 #:use-module (gnu packages m4)
37 #:use-module (gnu packages maths)
38 #:use-module (gnu packages perl)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages protobuf)
41 #:use-module (gnu packages python)
42 #:use-module (gnu packages python-xyz)
43 #:use-module (gnu packages qt)
44 #:use-module (gnu packages shells))
45
46;;; Strongly based on package gem5 in channel
47;; https://git.genenetwork.org/guix-bioinformatics
48(define-public gem5
49 (package
50 (name "gem5")
51 (version "25.1.0.1")
52 (source
53 (origin
54 (method git-fetch)
55 (uri (git-reference
56 (url "https://github.com/gem5/gem5")
57 (commit (string-append "v" version))))
58 (file-name (git-file-name name version))
59 (sha256
60 (base32 "0pbckqv08f6yiirr9f6gxivgrk422z31p04fifdhvzyc5magh8ls"))
61 (snippet
62 #~(begin
63 (use-modules (guix build utils))
64 ;; For reproducibility.
65 (substitute* "src/base/date.cc"
66 (("__DATE__") "\"1970-01-01\"")
67 (("__TIME__") "\"00:00:00\""))
68 ;; TODO: Unbundle systemc, libelf and googletest
69 (delete-file-recursively "ext/ply") ;unbundling of python-ply
70 ;; Unbundling of pybind11
71 (delete-file-recursively "ext/pybind11")
72 (substitute* "ext/sst/Makefile.linux"
73 (("-I../../ext/pybind11/include/")
74 "${shell pybind11-config --includes}"))
75 (substitute* "SConstruct"
76 ((".*pybind11.*") ""))))))
77 (build-system scons-build-system)
78 (arguments
79 (list
80 #:scons-flags #~(list "--verbose")
81 #:build-targets #~(list "build/ALL/gem5.opt")
82 #:phases
83 #~(modify-phases %standard-phases
84 (add-after 'unpack 'patch-source
85 (lambda* (#:key inputs #:allow-other-keys)
86 (substitute* "SConstruct"
87 ;; Force adding missing includes into the environment.
88 (("main\\.Append\\(CPPPATH=\\[Dir\\('" all)
89 (string-append
90 all (assoc-ref inputs "capstone") "/include')])\n"
91 all (assoc-ref inputs "hdf5") "/include')])\n"
92 all (assoc-ref inputs "kernel-headers") "/include')])\n"
93 all (assoc-ref inputs "libpng") "/include')])\n"
94 all (assoc-ref inputs "protobuf") "/include')])\n"
95 all (assoc-ref inputs "pybind11") "/include')])\n"
96 all (assoc-ref inputs "zlib") "/include')])\n"
97 all)))
98 (substitute* "ext/libelf/SConscript"
99 (("m4env\\.Tool" all)
100 (string-append
101 "m4env.Append(CPPPATH=[Dir('"
102 (assoc-ref inputs "kernel-headers")
103 "/include')])\n"
104 all)))
105 (substitute* "ext/libelf/native-elf-format"
106 (("cc") #$(cc-for-target)))))
107 ;; This uses the cached results from the previous 'build phase.
108 ;; Move to after 'install and delete build dir first?
109 (replace 'check
110 (lambda* (#:key tests? #:allow-other-keys #:rest args)
111 (when tests?
112 (apply (assoc-ref %standard-phases 'build)
113 #:build-targets '("build/ALL/unittests.opt")
114 args))))
115 (replace 'install
116 (lambda _
117 (let* ((bin (string-append #$output "/bin/")))
118 (mkdir-p bin)
119 (install-file "build/ALL/gem5.opt" bin)
120 (install-file "build/ALL/gem5py" bin)
121 (install-file "build/ALL/gem5py_m5" bin)
122 (copy-recursively
123 "configs"
124 (string-append #$output"/share/gem5/configs")))))
125 (add-after 'install 'wrap-binaries
126 (lambda _
127 (for-each
128 (lambda (file)
129 (wrap-program file
130 `("GUIX_PYTHONPATH" ":" prefix
131 (,(getenv "GUIX_PYTHONPATH")))))
132 (find-files (string-append #$output "/bin"))))))))
133 (inputs
134 (list capstone
135 gperftools
136 hdf5
137 libpng
138 protobuf-6
139 pybind11
140 python
141 python-ply
142 python-pydot
143 zlib))
144 (native-inputs
145 (list boost
146 m4
147 tcsh
148 perl
149 python-minimal-wrapper
150 pkg-config))
151 (home-page "http://gem5.org/")
152 (synopsis "Modular platform for computer-system architecture research")
153 (description "The gem5 simulator is a modular platform for computer-system
154architecture research, encompassing system-level architecture as well as
155processor microarchitecture.")
156 (license license:bsd-3)))
157
158(define-public ripes
159 ;; Includes Qt6 support.
160 (let ((commit "720066f8d1c9f8d62fad058f44471763a0312084")
161 (revision "0"))
162 (package
163 (name "ripes")
164 (version (git-version "2.2.6" revision commit))
165 (source
166 (origin
167 (method git-fetch)
168 (uri (git-reference
169 (url "https://github.com/mortbopet/Ripes/")
170 (commit commit)
171 ;; TODO: Unbundle. Ripes recursively requires tones of non
172 ;; packaged dependencies in "external" directories.
173 (recursive? #t)))
174 (file-name (git-file-name name version))
175 (sha256
176 (base32 "1kkdc3y18h985zvgmhbdbms3zynygrg5f64w1lm948hffj58x7gy"))))
177 (build-system qt-build-system)
178 (arguments
179 (list
180 #:qtbase qtbase ;for Qt6
181 #:phases
182 #~(modify-phases %standard-phases
183 (add-after 'unpack 'disable-tests
184 (lambda _
185 (substitute* "test/CMakeLists.txt"
186 ;; Fails with "Compared values are not the same"
187 (("create_qtest\\(tst_riscv\\)") "")
188 ;; Fails with "Internal test error"
189 (("create_qtest\\(tst_reverse\\)") ""))))
190 (add-after 'unpack 'patch-bugs
191 (lambda* (#:key inputs #:allow-other-keys)
192 ;; TODO: Remove when fixed upstream.
193 ;; See https://github.com/mortbopet/Ripes/issues/388 and 62
194 (substitute*
195 (string-append "external/VSRTL/external/cereal/include"
196 "/cereal/external/rapidjson/document.h")
197 (("GenericStringRef& operator=.*")
198 (string-append
199 "GenericStringRef& operator=(const GenericStringRef& rhs)"
200 " { s = rhs.s; return *this; }")))
201 ;; As suggested by error message itself.
202 (substitute* '("external/VSRTL/interface/vsrtl_vcdfile.cpp")
203 (("#include <sstream>")
204 "#include <sstream>\n#include <cstdint>"))
205 ;; As suggested by error message itself.
206 (substitute* '("external/VSRTL/interface/vsrtl_vcdfile.h")
207 (("#include <map>")
208 "#include <map>\n#include <cstdint>"))))
209 (add-before 'configure 'set-envs
210 (lambda* (#:key inputs #:allow-other-keys)
211 (setenv "VERILATOR_ROOT"
212 (dirname
213 (dirname
214 (search-input-file inputs "/bin/verilator"))))))
215 (replace 'check ;as for .github/workflows/test.yml
216 (lambda* (#:key tests? #:allow-other-keys)
217 (when tests?
218 (for-each
219 (lambda (f) (invoke f))
220 (filter executable-file? (find-files "test" "tst_")))))))
221 #:configure-flags
222 #~(list "-DRIPES_BUILD_VERILATOR_PROCESSORS=ON"
223 "-DRIPES_BUILD_TESTS=ON")))
224 (native-inputs
225 (list python-minimal-wrapper verilator))
226 (inputs
227 (list qtsvg qtcharts))
228 (home-page "https://github.com/mortbopet/Ripes/")
229 (synopsis "Visual computer architecture editor for RISCV")
230 (description
231 "Ripes is a visual computer architecture simulator and assembly code
232editor built for the RISCV instruction set architecture.")
233 (license license:expat))))