Commit | Line | Data |
---|---|---|
89b091a6 JG |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2020 Jesse Gibbons <jgibbons2357+guix@gmail.com> | |
30be8963 | 3 | ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
89b091a6 JG |
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) | |
30be8963 | 23 | #:use-module (guix git-download) |
89b091a6 JG |
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) | |
30be8963 TGR |
29 | #:use-module (gnu packages netpbm) |
30 | #:use-module (gnu packages perl) | |
89b091a6 JG |
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 | `(("gd" ,gd) | |
56 | ("giflib" ,giflib) | |
57 | ("libpng" ,libpng) | |
58 | ("tk" ,tk))) | |
59 | (native-inputs `(("groff" ,groff))) | |
60 | (synopsis "Piet interpreter") | |
61 | (description | |
2f6b0adb TGR |
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 | |
89b091a6 JG |
64 | color. |
65 | ||
66 | This package includes: | |
67 | @enumerate | |
2f6b0adb TGR |
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. | |
72 | @end enumerate\n") | |
89b091a6 JG |
73 | (home-page "https://www.bertnase.de/npiet/") |
74 | (license license:gpl2+))) | |
30be8963 TGR |
75 | |
76 | (define-public piet-toolchain | |
77 | (let ((commit "f002ff6a924a6bbace5eef94f3be06f425e7f590") | |
78 | (revision "0")) | |
79 | (package | |
80 | (name "piet-toolchain") | |
81 | (version (git-version "0.0.0" revision commit)) | |
82 | (source | |
83 | (origin | |
84 | (method git-fetch) | |
85 | (uri (git-reference | |
86 | (url "https://github.com/sl236/Piet") | |
87 | (commit commit))) | |
88 | (file-name (git-file-name name version)) | |
89 | (sha256 | |
90 | (base32 "0xwbhwizfbn080fmrgavaz3b939brycmlar3m5px9avl2b68c816")) | |
91 | (modules '((guix build utils))) | |
92 | (snippet | |
93 | '(begin | |
94 | ;; Remove a bundled fork of Marc Majcher's Piet interpreter. | |
95 | (delete-file-recursively "interpreter") | |
96 | #t)))) | |
97 | (build-system gnu-build-system) | |
98 | (arguments | |
99 | `(#:modules ((guix build gnu-build-system) | |
100 | (guix build utils) | |
101 | (srfi srfi-26)) | |
102 | #:phases | |
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 | |
107 | (replace 'install | |
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" | |
118 | "piet-compiler")) | |
119 | ||
120 | ;; Fix an odd mode. | |
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" | |
126 | "compiler-samples" | |
127 | "README.md")) ; includes the licence grant | |
128 | #t))) | |
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"))) | |
133 | (when tests? | |
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 " | |
138 | file ">" | |
139 | file ".piet"))) | |
140 | (find-files "." "\\.script$")) | |
141 | (for-each (lambda (file) | |
142 | (system (string-append bin "/piet-assembler " | |
143 | file "|pnmtopng>" | |
144 | file ".png"))) | |
145 | (find-files "." "\\.piet$")) | |
146 | ||
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$")) | |
151 | #t))))))) | |
152 | (native-inputs | |
153 | ;; For our tests. | |
154 | `(("netpbm" ,netpbm) | |
155 | ("npiet" ,npiet))) | |
156 | (inputs | |
157 | `(("perl" ,perl) | |
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") | |
161 | (description | |
162 | "This package provides a compiler and assembler that target the Piet | |
163 | graphical programming language. | |
164 | ||
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. | |
168 | ||
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. | |
174 | ||
175 | The language is documented only by the compiler's Perl source code and the | |
176 | included samples.") | |
177 | (license license:cc-by-sa4.0)))) |