gnu: sssd: Update to 2.7.4.
[jackhill/guix/guix.git] / gnu / packages / piet.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Jesse Gibbons <jgibbons2357+guix@gmail.com>
3 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
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 piet)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix git-download)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages gd)
27 #:use-module (gnu packages groff)
28 #:use-module (gnu packages image)
29 #:use-module (gnu packages netpbm)
30 #:use-module (gnu packages perl)
31 #:use-module (gnu packages tcl))
32
33 (define-public npiet
34 (package
35 (name "npiet")
36 (version "1.3f")
37 (source (origin
38 (method url-fetch)
39 (uri (string-append "https://www.bertnase.de/npiet/npiet-"
40 version ".tar.gz"))
41 (sha256
42 (base32
43 "0nl59fhdqqr7nslxdirdn8nvlq5wws67c7jyx2ckbmxbc9h8bv9d"))))
44 (build-system gnu-build-system)
45 (arguments
46 `(#:phases
47 (modify-phases %standard-phases
48 (add-after 'install 'wrap-binaries
49 (lambda* (#:key outputs #:allow-other-keys)
50 (let ((out (assoc-ref outputs "out")))
51 (wrap-program (string-append out "/bin/npietedit")
52 `("PATH" ":" prefix (,(dirname (which "wish")))))
53 #t))))))
54 (inputs
55 (list gd giflib libpng tk))
56 (native-inputs (list groff))
57 (synopsis "Piet interpreter")
58 (description
59 "Npiet is an interpreter for the Piet programming language. Instead of
60 text, Piet programs are pictures. Commands are determined based on changes in
61 color.
62
63 This package includes:
64 @enumerate
65 @item @command{npiet}, a Piet interpreter with debugging capabilities
66 @item @command{npiet-foogol}, a program that builds a Piet program from Foogol,
67 an Algol-like language
68 @item @command{npietedit}, an editor for Piet programs.
69 @end enumerate\n")
70 (home-page "https://www.bertnase.de/npiet/")
71 (license license:gpl2+)))
72
73 (define-public piet-toolchain
74 (let ((commit "f002ff6a924a6bbace5eef94f3be06f425e7f590")
75 (revision "0"))
76 (package
77 (name "piet-toolchain")
78 (version (git-version "0.0.0" revision commit))
79 (source
80 (origin
81 (method git-fetch)
82 (uri (git-reference
83 (url "https://github.com/sl236/Piet")
84 (commit commit)))
85 (file-name (git-file-name name version))
86 (sha256
87 (base32 "0xwbhwizfbn080fmrgavaz3b939brycmlar3m5px9avl2b68c816"))
88 (modules '((guix build utils)))
89 (snippet
90 '(begin
91 ;; Remove a bundled fork of Marc Majcher's Piet interpreter.
92 (delete-file-recursively "interpreter")
93 #t))))
94 (build-system gnu-build-system)
95 (arguments
96 `(#:modules ((guix build gnu-build-system)
97 (guix build utils)
98 (srfi srfi-26))
99 #:phases
100 (modify-phases %standard-phases
101 (delete 'configure) ; no configure script
102 (delete 'build) ; nothing to build
103 (delete 'check) ; run our own tests below
104 (replace 'install
105 (lambda* (#:key outputs #:allow-other-keys)
106 (let* ((out (assoc-ref outputs "out"))
107 (bin (string-append out "/bin"))
108 (doc (string-append out "/share/doc/"
109 ,name "-" ,version)))
110 (for-each (lambda (script)
111 (install-file script bin)
112 (wrap-program (string-append bin "/" script)
113 `("PERL5LIB" ":" = (,(getenv "PERL5LIB")))))
114 (list "piet-assembler"
115 "piet-compiler"))
116
117 ;; Fix an odd mode.
118 (chmod "compiler-samples/test-binary-ops.script" #o644)
119 (for-each (lambda (file) ; INSTALL-FILE is not recursive
120 (copy-recursively file
121 (string-append doc "/" file)))
122 (list "assembler-samples"
123 "compiler-samples"
124 "README.md")) ; includes the licence grant
125 #t)))
126 (add-after 'install 'check
127 (lambda* (#:key outputs tests? #:allow-other-keys)
128 (let* ((out (assoc-ref outputs "out"))
129 (bin (string-append out "/bin")))
130 (when tests?
131 (unsetenv "PERL5LIB") ; test the wrapping
132 ;; Compile all scripts assemble all Piets.
133 (for-each (lambda (file)
134 (system (string-append bin "/piet-compiler "
135 file ">"
136 file ".piet")))
137 (find-files "." "\\.script$"))
138 (for-each (lambda (file)
139 (system (string-append bin "/piet-assembler "
140 file "|pnmtopng>"
141 file ".png")))
142 (find-files "." "\\.piet$"))
143
144 ;; Don't run the interactive one.
145 (delete-file "assembler-samples/quest.piet.png")
146 (for-each (cut invoke "npiet" <>)
147 (find-files "." "\\.png$"))
148 #t)))))))
149 (native-inputs
150 ;; For our tests.
151 (list netpbm npiet))
152 (inputs
153 (list perl perl-parse-recdescent))
154 (home-page "https://www.toothycat.net/wiki/wiki.pl?MoonShadow/Piet")
155 (synopsis "Piet compiler and assembler")
156 (description
157 "This package provides a compiler and assembler that target the Piet
158 graphical programming language.
159
160 @command{piet-assembler} converts Piet assembler instructions (e.g.,
161 @code{push}, @code{add}, @code{switch}, @code{outn}) and directives into an
162 executable @code{netpbm} image of the corresponding Piet program.
163
164 @command{piet-compiler} compiles a C-like high-level language into assembly
165 source understood by @command{piet-assembler}. It supports common arithmetic
166 and boolean logic operators (though not bitwise manipulation), flow control
167 (@code{if}, @code{for}, @code{while}), recursive functions, in-line assembler,
168 and input/output intrinsics. The only supported data type is the integer.
169
170 The language is documented only by the compiler's Perl source code and the
171 included samples.")
172 (license license:cc-by-sa4.0))))