aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020 Jesse Gibbons <jgibbons2357+guix@gmail.com>
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2023 Zheng Junjie <873216071@qq.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages piet)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages gd)
  #:use-module (gnu packages groff)
  #:use-module (gnu packages image)
  #:use-module (gnu packages netpbm)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages tcl))

(define-public npiet
  (package
    (name "npiet")
    (version "1.3f")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://www.bertnase.de/npiet/npiet-"
                                  version ".tar.gz"))
              (sha256
               (base32
                "0nl59fhdqqr7nslxdirdn8nvlq5wws67c7jyx2ckbmxbc9h8bv9d"))))
    (build-system gnu-build-system)
    (arguments
     (list #:phases
           #~(modify-phases %standard-phases
               (add-after 'install 'wrap-binaries
                 (lambda* (#:key inputs outputs #:allow-other-keys)
                   (let ((out (assoc-ref outputs "out")))
                     (wrap-program (string-append out
                                                  "/bin/npietedit")
                       `("PATH" ":" prefix
                         (,(dirname
                            (search-input-file
                             inputs "bin/wish")))))))))))
    (inputs (list bash-minimal gd giflib libpng tk))
    (native-inputs (list groff))
    (synopsis "Piet interpreter")
    (description
     "Npiet is an interpreter for the Piet programming language.  Instead of
text, Piet programs are pictures.  Commands are determined based on changes in
color.

This package includes:
@enumerate
@item @command{npiet}, a Piet interpreter with debugging capabilities
@item @command{npiet-foogol}, a program that builds a Piet program from Foogol,
an Algol-like language
@item @command{npietedit}, an editor for Piet programs.
@end enumerate\n")
    (home-page "https://www.bertnase.de/npiet/")
    (license license:gpl2+)))

(define-public piet-toolchain
  (let ((commit "f002ff6a924a6bbace5eef94f3be06f425e7f590")
        (revision "0"))
    (package
      (name "piet-toolchain")
      (version (git-version "0.0.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/sl236/Piet")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32 "0xwbhwizfbn080fmrgavaz3b939brycmlar3m5px9avl2b68c816"))
         (modules '((guix build utils)))
         (snippet
          '(begin
             ;; Remove a bundled fork of Marc Majcher's Piet interpreter.
             (delete-file-recursively "interpreter")))))
      (build-system gnu-build-system)
      (arguments
       `(#:modules ((guix build gnu-build-system)
                    (guix build utils)
                    (srfi srfi-26))
         #:phases
         (modify-phases %standard-phases
           (delete 'configure)          ; no configure script
           (delete 'build)              ; nothing to build
           (delete 'check)              ; run our own tests below
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (bin (string-append out "/bin"))
                      (doc (string-append out "/share/doc/"
                                          ,name "-" ,version)))
                 (for-each (lambda (script)
                             (install-file script bin)
                             (wrap-program (string-append bin "/" script)
                               `("PERL5LIB" ":" = (,(getenv "PERL5LIB")))))
                           (list "piet-assembler"
                                 "piet-compiler"))

                 ;; Fix an odd mode.
                 (chmod "compiler-samples/test-binary-ops.script" #o644)
                 (for-each (lambda (file)    ; INSTALL-FILE is not recursive
                             (copy-recursively file
                                               (string-append doc "/" file)))
                           (list "assembler-samples"
                                 "compiler-samples"
                                 "README.md"))))) ;includes the licence grant
           (add-after 'install 'check
             (lambda* (#:key outputs tests? #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (bin (string-append out "/bin")))
                 (when tests?
                   (unsetenv "PERL5LIB") ; test the wrapping
                   ;; Compile all scripts assemble all Piets.
                   (for-each (lambda (file)
                               (system (string-append bin "/piet-compiler "
                                                      file ">"
                                                      file ".piet")))
                             (find-files "." "\\.script$"))
                   (for-each (lambda (file)
                               (system (string-append bin "/piet-assembler "
                                                      file "|pnmtopng>"
                                                      file ".png")))
                             (find-files "." "\\.piet$"))

                   ;; Don't run the interactive one.
                   (delete-file "assembler-samples/quest.piet.png")
                   (for-each (cut invoke "npiet" <>)
                             (find-files "." "\\.png$")))))))))
      (native-inputs (list netpbm npiet)) ;for tests
      (inputs (list bash-minimal perl perl-parse-recdescent))
      (home-page "https://www.toothycat.net/wiki/wiki.pl?MoonShadow/Piet")
      (synopsis "Piet compiler and assembler")
      (description
       "This package provides a compiler and assembler that target the Piet
graphical programming language.

@command{piet-assembler} converts Piet assembler instructions (e.g.,
@code{push}, @code{add}, @code{switch}, @code{outn}) and directives into an
executable @code{netpbm} image of the corresponding Piet program.

@command{piet-compiler} compiles a C-like high-level language into assembly
source understood by @command{piet-assembler}.  It supports common arithmetic
and boolean logic operators (though not bitwise manipulation), flow control
(@code{if}, @code{for}, @code{while}), recursive functions, in-line assembler,
and input/output intrinsics.  The only supported data type is the integer.

The language is documented only by the compiler's Perl source code and the
included samples.")
      (license license:cc-by-sa4.0))))
puts]: Likewise. * gnu/packages/music.scm (libgig)[inputs]: Likewise. * gnu/packages/nfs.scm (nfs-utils)[inputs]: Likewise. * gnu/packages/opencog.scm (opencog)[inputs]: Likewise. * gnu/packages/package-management.scm (msitools)[inputs]: Change to the "lib" output of UTIL-LINUX. * gnu/packages/password-utils.scm (pwsafe)[inputs]: Likewise. * gnu/packages/telephony.scm (pjproject)[propagated-inputs]: Likewise. * gnu/packages/rdf.scm (rasqal)[inputs]: Likewise. * gnu/packages/search.scm (xapian)[inputs]: Likewise. * gnu/packages/sssd.scm (sssd)[native-inputs]: Likewise. * gnu/packages/storage.scm (ceph)[inputs]: Add UTIL-LINUX:LIB. * gnu/packages/task-management.scm (taskwarrior)[inputs]: Change to the "lib" output of UTIL-LINUX. * gnu/packages/virtualization.scm (libvirt, xen)[inputs]: Likewise. * gnu/packages/xorg.scm (libsm)[inputs]: Likewise. Marius Bakke 2020-01-14gnu: chez-sheme: Move util-linux to inputs....* gnu/packages/chez.scm (chez-scheme)[native-inputs]: Move UTIL-LINUX ... [inputs]: ... here. Rename assoc key to "libuuid" for clarity. Marius Bakke 2020-01-12gnu: chez-scheme: Remove obsolete snippet....* gnu/packages/chez.scm (chez-scheme)[source](modules, snippet): Remove. Marius Bakke 2019-12-24gnu: chez-scheme: Update home-page....* gnu/packages/chez.scm (chez-scheme)[home-page]: Now uses Github project page. Brett Gilio 2019-12-24gnu: chez-scheme: Update to 9.5.2....* gnu/packages/chez.scm (chez-scheme): Update to 9.5.2. [native-inputs]: Add util-linux for UUID support. [arguments]: Remove patch-broken-documentation phase. [arguments]: Update configure mechanism to prevent CURLing of submodules. Brett Gilio 2019-03-31gnu: Fix descriptions to not use quotes....* gnu/packages/admin.scm (wpa-supplicant-minimal, mingetty, di), * gnu/packages/audio.scm (fil-plugins), * gnu/packages/base.scm (make-ld-wrapper, make-glibc-locales), * gnu/packages/bioinformatics.scm (r-samtools), * gnu/packages/chez.scm (chez-mit), * gnu/packages/commencement.scm (make-gcc-toolchain), * gnu/packages/compression.scm (fastjar), * gnu/packages/cran.scm (r-maps, r-rcpp), * gnu/packages/databases.scm (sparql-query), * gnu/packages/dunst.scm (dunst), * gnu/packages/ftp.scm (ncftp), * gnu/packages/gl.scm (freeglut), * gnu/packages/haskell-check.scm (ghc-tasty-golden), * gnu/packages/haskell.scm (ghc-case-insensitive, ghc-text, ghc-haskell-src, ghc-syb, ghc-deepseq-generics, ghc-network-uri, ghc-rerebase, ghc-zlib), * gnu/packages/image.scm (jbig2dec), * gnu/packages/kde-frameworks.scm (kinit, karchive), * gnu/packages/linux.scm (wireless-tools, perf, module-init-tools, kbd), * gnu/packages/lirc.scm (lirc), * gnu/packages/lisp.scm (uglify-js), * gnu/packages/mate.scm (mate-netbook), * gnu/packages/microcom.scm (microcom), * gnu/packages/music.scm (bristol), * gnu/packages/networking.scm (perl-geo-ip), * gnu/packages/patchutils.scm (patches), * gnu/packages/perl-check.scm (perl-test-more-utf8), * gnu/packages/perl.scm (perl-log-report-optional, perl-file-which, perl-io-tty, perl-log-any, perl-digest-sha1, perl-class-load, perl-regexp-common, perl-module-pluggable, perl-class-modifier), * gnu/packages/python-xyz.scm (python-backports-abc, python-natsort), * gnu/packages/samba.scm (iniparser), * gnu/packages/search.scm (mlocate), * gnu/packages/spice.scm (spice), * gnu/packages/statistics.scm (r-dt, r-lubridate, r-estimability, r-commonmark, r-digest, r-viridislite, r-stringr), * gnu/packages/tex.scm (texlive-latex-changebar), * gnu/packages/version-control.scm (subversion), * gnu/packages/w3m.scm (w3m), * gnu/packages/web.scm (perl-http-parser, perl-plack-middleware-reverseproxy), * gnu/packages/xorg.scm (xkeyboard-config, mkfontdir, xcursor-theme, mkfontscale, xinit, font-alias)[description]: Use @code instead of quotes. Efraim Flashner 2019-02-16gnu: chez-sockets: Use GIT- helpers....* gnu/packages/chez.scm (chez-sockets)[version]: Use GIT-VERSION. [source]: Use GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: chez-scmutils: Return #t from all phases....* gnu/packages/chez.scm (chez-scmutils)[arguments]: Always return #t from phases. Substitute INVOKE for SYSTEM*. Tobias Geerinckx-Rice 2019-02-16gnu: chez-scmutils: Don't use unstable tarball....* gnu/packages/chez.scm (chez-scmutils)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: chez-mit: Don't use unstable tarball....* gnu/packages/chez.scm (chez-mit)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: chez-scheme: Don't use unstable tarball....* gnu/packages/chez.scm (chez-scheme)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: stex: Don't use unstable tarball....* gnu/packages/chez.scm (stex)[source]: Use GIT-FETCH and GIT-FILE-NAME. (chez-scheme)[arguments]: Adjust expected source directory name. Tobias Geerinckx-Rice 2019-02-16gnu: nanopass: Don't use unstable tarball....* gnu/packages/chez.scm (nanopass)[source]: Use GIT-FETCH and GIT-FILE-NAME. (chez-scheme)[arguments]: Adjust expected source directory name. Tobias Geerinckx-Rice 2019-02-16gnu: chez-scheme: Return #t from all phases....* gnu/packages/chez.scm (chez-scheme)[arguments]: Always return #t from phases. Substitute INVOKE for SYSTEM*. Tobias Geerinckx-Rice 2019-02-16gnu: chez-scheme: Fix ‘install-doc’ phase....* gnu/packages/chez.scm (chez-cheme)[arguments]: Find ‘installsh’. Remove some unnecessary code. Tobias Geerinckx-Rice 2019-02-16gnu: chez-irregex: Don't use unstable tarball....* gnu/packages/chez.scm (chez-irregex)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: chez-matchable: Don't use unstable tarball....* gnu/packages/chez.scm (chez-matchable)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: chez-web: Use GIT- helpers....* gnu/packages/chez.scm (chez-web)[version]: Use GIT-VERSION. [source]: Use GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: chez-srfi: Don't use unstable tarball....* gnu/packages/chez.scm (chez-srfi)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice 2019-02-16gnu: chez-fmt: Return #t from all phases....* gnu/packages/chez.scm (chez-fmt)[arguments]: Always return #t from phases. Substitute INVOKE for SYSTEM*. Tobias Geerinckx-Rice 2019-02-16gnu: chez-web: Return #t from all phases....* gnu/packages/chez.scm (chez-web)[arguments]: Always return #t from phases. Tobias Geerinckx-Rice