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")))))
55 (list gd giflib libpng tk))
56 (native-inputs (list groff))
57 (synopsis "Piet interpreter")
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
63 This package includes:
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.
70 (home-page "https://www.bertnase.de/npiet/")
71 (license license:gpl2+)))
73 (define-public piet-toolchain
74 (let ((commit "f002ff6a924a6bbace5eef94f3be06f425e7f590")
77 (name "piet-toolchain")
78 (version (git-version "0.0.0" revision commit))
83 (url "https://github.com/sl236/Piet")
85 (file-name (git-file-name name version))
87 (base32 "0xwbhwizfbn080fmrgavaz3b939brycmlar3m5px9avl2b68c816"))
88 (modules '((guix build utils)))
91 ;; Remove a bundled fork of Marc Majcher's Piet interpreter.
92 (delete-file-recursively "interpreter")
94 (build-system gnu-build-system)
96 `(#:modules ((guix build gnu-build-system)
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
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"
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"
124 "README.md")) ; includes the licence grant
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")))
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 "
137 (find-files "." "\\.script$"))
138 (for-each (lambda (file)
139 (system (string-append bin "/piet-assembler "
142 (find-files "." "\\.piet$"))
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$"))
153 (list perl perl-parse-recdescent))
154 (home-page "https://www.toothycat.net/wiki/wiki.pl?MoonShadow/Piet")
155 (synopsis "Piet compiler and assembler")
157 "This package provides a compiler and assembler that target the Piet
158 graphical programming language.
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.
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.
170 The language is documented only by the compiler's Perl source code and the
172 (license license:cc-by-sa4.0))))