1;; SPDX-FileCopyrightText: 2025 Sören Tempel <soeren+git@soeren-tempel.net>2;;3;; SPDX-License-Identifier: GPL-3.0-only45(define-module (qute-packages)6 #:use-module ((ice-9 popen) #:select (open-pipe*))7 #:use-module ((ice-9 rdelim) #:select (read-string))8 #:use-module (guix transformations) ; XXX: needed for 'simple-cc'9 #:use-module ((guix licenses) #:prefix license:)10 #:use-module ((gnu packages c) #:prefix c:)11 #:use-module (gnu packages check)12 #:use-module (gnu packages haskell)13 #:use-module (gnu packages haskell-apps)14 #:use-module (gnu packages haskell-check)15 #:use-module (gnu packages haskell-xyz)16 #:use-module (gnu packages maths)17 #:use-module (gnu packages python)18 #:use-module (guix build-system copy)19 #:use-module (guix build-system haskell)20 #:use-module (guix download)21 #:use-module (guix gexp)22 #:use-module (guix utils)23 #:use-module (guix git-download)24 #:use-module (guix packages))2526(define (pipe-command command)27 (let* ((port (apply open-pipe* OPEN_READ command))28 (output (string-trim-right (read-string port))))29 (close-port port)30 output))3132(define %srcdir33 (pipe-command '("git" "rev-parse" "--show-toplevel")))3435;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3637(define-public simple-cc38 (let ((commit "dc2467847308d6c9e1e19d139938ff5c4aba1343")39 (revision "3"))40 (package/inherit c:simple-cc41 (name "simple-cc")42 (version (git-version (package-version c:simple-cc) revision commit))43 (source44 (origin45 (method git-fetch)46 (uri (git-reference47 (url "https://git.8pit.net/scc.git")48 (commit commit)))49 (file-name (git-file-name name version))50 (sha25651 (base32 "1ls3csagx321fxbqiay9ygbjrras3bq5f7cfdw6h64x14s4npfmq"))))52 (arguments53 (substitute-keyword-arguments (package-arguments c:simple-cc)54 ((#:tests? _ #f) #f) ;; TODO: Figure out why tests fail on Git HEAD.55 ((#:phases phases #~%standard-phases)56 #~(modify-phases #$phases57 ;; gcc-scc.sh has been removed in Git HEAD, create an empty file to58 ;; allow using the existing 'fix-paths phase without it erroring.59 (add-before 'fix-paths 'touch-dummy60 (lambda _61 (call-with-output-file "src/libc/gcc-scc.sh" (const #t)))))))))))6263;; ktest-tool python script from KLEE for inspecting .ktest file64;; generated by qute-symex(1) from the qute-cli package.65(define-public ktest-tool66 (package/inherit klee67 (name "ktest-tool")68 (build-system copy-build-system)69 (inputs (list python-minimal))70 (native-inputs '())71 (arguments72 (list73 #:phases74 #~(modify-phases %standard-phases75 (add-after 'unpack 'fix-shebang76 (lambda* (#:key inputs #:allow-other-keys)77 (substitute* "tools/ktest-tool/ktest-tool"78 (("#!/usr/bin/env python3")79 (string-append80 "#!"81 (search-input-file inputs "/bin/python3")))))))82 #:install-plan83 #~'(("tools/ktest-tool/ktest-tool" "bin/ktest-tool"))))84 (home-page "https://klee-se.org")85 (synopsis "Tool for KLEE's ktest test input format")))8687;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8889(define-public qute-syntax90 (package91 (name "qute-syntax")92 (version "0.1.0.0")93 (source (local-file (string-append %srcdir "/qute-syntax")94 "git-checkout"95 #:recursive? #t))96 (build-system haskell-build-system)97 (native-inputs98 (list99 c:qbe100 ghc-tasty101 ghc-tasty-hunit102 ghc-tasty-golden))103 (synopsis "Parser library for the QBE intermediate language")104 (description "")105 (home-page "https://git.8pit.net/qute")106 (license (list license:expat license:bsd-2 license:gpl3))))107108(define-public qute109 (package110 (name "qute")111 (version "0.1.0.0")112 (source (local-file (string-append %srcdir "/qute")113 "git-checkout"114 #:recursive? #t))115 (build-system haskell-build-system)116 (native-inputs117 (list118 qute-syntax119 ghc-tasty120 ghc-tasty-hunit))121 (synopsis "Analysis library for the QBE intermediate language")122 (description "")123 (home-page "https://git.8pit.net/qute")124 (license (list license:expat license:gpl3))))125126(define-public qute-symex127 (package128 (name "qute-symex")129 (version "0.1.0.0")130 (source (local-file (string-append %srcdir "/qute-symex")131 "git-checkout"132 #:recursive? #t))133 (build-system haskell-build-system)134 (inputs (list bitwuzla)) ;needed for 'check.135 (native-inputs136 (list137 qute138 qute-syntax139 ghc-tasty140 ghc-tasty-hunit141 ghc-tasty-golden142 ghc-tasty-quickcheck143 ghc-simple-smt))144 (synopsis "Symbolic executor for the QBE intermediate language")145 (description "")146 (home-page "https://git.8pit.net/qute")147 (license (list license:expat license:gpl3))))148149(define-public qute-cli150 (package151 (name "qute-cli")152 (version "0.1.0.0")153 (source (local-file (string-append %srcdir "/qute-cli")154 "git-checkout"155 #:recursive? #t))156 (build-system haskell-build-system)157 (native-inputs158 (list159 qute160 qute-syntax161 qute-symex162 ghc-optparse-applicative163 ghc-tasty-hunit))164 (synopsis "Command line utilities for qute")165 (description "")166 (home-page "https://git.8pit.net/qute")167 (license (list license:gpl3))))