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>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
39 (uri (string-append "https://www.bertnase.de/npiet/npiet-"
43 "0nl59fhdqqr7nslxdirdn8nvlq5wws67c7jyx2ckbmxbc9h8bv9d"))))
44 (build-system gnu-build-system)
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")))))
59 (native-inputs `(("groff" ,groff)))
60 (synopsis "Piet interpreter")
62 "Npiet is an interpreter for the Piet programming language. Instead of
63 text, Piet programs are pictures. Commands are determined based on changes in
66 This package includes:
68 @item @command{npiet}, a Piet interpreter with debugging capabilities
69 @item @command{npiet-foogol}, a program that builds a Piet program from Foogol,
70 an Algol-like language
71 @item @command{npietedit}, an editor for Piet programs.
73 (home-page "https://www.bertnase.de/npiet/")
74 (license license:gpl2+)))
76 (define-public piet-toolchain
77 (let ((commit "f002ff6a924a6bbace5eef94f3be06f425e7f590")
80 (name "piet-toolchain")
81 (version (git-version "0.0.0" revision commit))
86 (url "https://github.com/sl236/Piet")
88 (file-name (git-file-name name version))
90 (base32 "0xwbhwizfbn080fmrgavaz3b939brycmlar3m5px9avl2b68c816"))
91 (modules '((guix build utils)))
94 ;; Remove a bundled fork of Marc Majcher's Piet interpreter.
95 (delete-file-recursively "interpreter")
97 (build-system gnu-build-system)
99 `(#:modules ((guix build gnu-build-system)
103 (modify-phases %standard-phases
104 (delete 'configure) ; no configure script
105 (delete 'build) ; nothing to build
106 (delete 'check) ; run our own tests below
108 (lambda* (#:key outputs #:allow-other-keys)
109 (let* ((out (assoc-ref outputs "out"))
110 (bin (string-append out "/bin"))
111 (doc (string-append out "/share/doc/"
112 ,name "-" ,version)))
113 (for-each (lambda (script)
114 (install-file script bin)
115 (wrap-program (string-append bin "/" script)
116 `("PERL5LIB" ":" = (,(getenv "PERL5LIB")))))
117 (list "piet-assembler"
121 (chmod "compiler-samples/test-binary-ops.script" #o644)
122 (for-each (lambda (file) ; INSTALL-FILE is not recursive
123 (copy-recursively file
124 (string-append doc "/" file)))
125 (list "assembler-samples"
127 "README.md")) ; includes the licence grant
129 (add-after 'install 'check
130 (lambda* (#:key outputs tests? #:allow-other-keys)
131 (let* ((out (assoc-ref outputs "out"))
132 (bin (string-append out "/bin")))
134 (unsetenv "PERL5LIB") ; test the wrapping
135 ;; Compile all scripts assemble all Piets.
136 (for-each (lambda (file)
137 (system (string-append bin "/piet-compiler "
140 (find-files "." "\\.script$"))
141 (for-each (lambda (file)
142 (system (string-append bin "/piet-assembler "
145 (find-files "." "\\.piet$"))
147 ;; Don't run the interactive one.
148 (delete-file "assembler-samples/quest.piet.png")
149 (for-each (cut invoke "npiet" <>)
150 (find-files "." "\\.png$"))
158 ("perl-parse-recdescent" ,perl-parse-recdescent)))
159 (home-page "https://www.toothycat.net/wiki/wiki.pl?MoonShadow/Piet")
160 (synopsis "Piet compiler and assembler")
162 "This package provides a compiler and assembler that target the Piet
163 graphical programming language.
165 @command{piet-assembler} converts Piet assembler instructions (e.g.,
166 @code{push}, @code{add}, @code{switch}, @code{outn}) and directives into an
167 executable @code{netpbm} image of the corresponding Piet program.
169 @command{piet-compiler} compiles a C-like high-level language into assembly
170 source understood by @command{piet-assembler}. It supports common arithmetic
171 and boolean logic operators (though not bitwise manipulation), flow control
172 (@code{if}, @code{for}, @code{while}), recursive functions, in-line assembler,
173 and input/output intrinsics. The only supported data type is the integer.
175 The language is documented only by the compiler's Perl source code and the
177 (license license:cc-by-sa4.0))))