[bug#61243] Add WASM-4 fantasy console and prerequisites
Commit Message
Hello all,
This set of 4 patches adds WASM-4 (https://wasm4.org/), a fantasy
console that runs game "cartridges" compiled to WebAssembly. It's a
fun way to learn about WebAssembly using a relatively simple system.
I've seen a WASM-4 game that was assembled using Racket, which I
thought was pretty neat. It would be even cooler if someone did
something like that with Guile!
Packaging this thing was not exactly straightforward due to dependency
bundling via git submodules, but I was able to unbundle everything.
- Dave
Comments
"Thompson, David" <dthompson2@worcester.edu> writes:
> Hello all,
>
> This set of 4 patches adds WASM-4 (https://wasm4.org/), a fantasy
> console that runs game "cartridges" compiled to WebAssembly. It's a
> fun way to learn about WebAssembly using a relatively simple system.
> I've seen a WASM-4 game that was assembled using Racket, which I
> thought was pretty neat. It would be even cooler if someone did
> something like that with Guile!
Wouldn't it be cool indeed? I wonder if we can see progress on this in
Guile-land? Maybe someone should take up the torch for the Guile and
WASM story.
> Packaging this thing was not exactly straightforward due to dependency
> bundling via git submodules, but I was able to unbundle everything.
Impressive! This doesn't look like it was easy to figure out.
I reviewed all four patches. Despite some custom stuff on most of
these, they all look well commented and sensible. I say push it!
- Christine
Hi Christine,
On Fri, Feb 3, 2023 at 7:53 AM Christine Lemmer-Webber
<cwebber@dustycloud.org> wrote:
>
> "Thompson, David" <dthompson2@worcester.edu> writes:
>
> > Hello all,
> >
> > This set of 4 patches adds WASM-4 (https://wasm4.org/), a fantasy
> > console that runs game "cartridges" compiled to WebAssembly. It's a
> > fun way to learn about WebAssembly using a relatively simple system.
> > I've seen a WASM-4 game that was assembled using Racket, which I
> > thought was pretty neat. It would be even cooler if someone did
> > something like that with Guile!
>
> Wouldn't it be cool indeed? I wonder if we can see progress on this in
> Guile-land? Maybe someone should take up the torch for the Guile and
> WASM story.
That sure would be cool!
Small correction: The thing I saw that used Racket to create
WebAssembly output doesn't actually run on WASM-4, it just kinda
looked like it did. Oops! It's still very cool!
https://github.com/euhmeuh/wasm-adventure
> > Packaging this thing was not exactly straightforward due to dependency
> > bundling via git submodules, but I was able to unbundle everything.
>
> Impressive! This doesn't look like it was easy to figure out.
>
> I reviewed all four patches. Despite some custom stuff on most of
> these, they all look well commented and sensible. I say push it!
Thanks for the review! I found a typo in the description field of
cubeb that I've fixed, and I added some additional comments explaining
the minifb build customizations. I pushed the patches with those
changes!
- Dave
just saw this news:
https://spritely.institute/news/guile-on-web-assembly-project-underway.html
From e227587b4e50313fdbda4acf7992b7a4ded23260 Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Thu, 2 Feb 2023 14:04:48 -0500
Subject: [PATCH 1/4] gnu: Add wasm3.
* gnu/packages/web.scm (wasm3): New variable.
---
gnu/packages/web.scm | 48 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
@@ -61,6 +61,7 @@
;;; Copyright © 2022 jgart <jgart@dismail.de>
;;; Copyright © 2023 Paul A. Patience <paul@apatience.com>
;;; Copyright © 2022 Bruno Victal <mirai@makinata.eu>
+;;; Copyright © 2023 David Thompson <dthompson2@worcester.edu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1557,6 +1558,53 @@ (define-public wabt
other systems that want to manipulate WebAssembly files.")
(license license:asl2.0)))
+(define-public wasm3
+ (package
+ (name "wasm3")
+ (version "0.5.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/wasm3/wasm3")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "07zzmk776j8ydyxhrnnjiscbhhmz182a62r6aix6kfk5kq2cwia2"))))
+ (build-system cmake-build-system)
+ (arguments
+ ;; The default WASI option "uvwasi" causes CMake to initiate a 'git
+ ;; clone' which cannot happen within the build container.
+ '(#:configure-flags '("-DBUILD_WASI=simple")
+ ;; No check target. There are tests but they require a network
+ ;; connection to download the WebAssembly core test suite.
+ #:tests? #f
+ ;; There is no install target. Instead, we have to manually copy the
+ ;; wasm3 build artifacts to the output directory.
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (bindir (string-append out "/bin"))
+ (includedir (string-append out "/include"))
+ (libdir (string-append out "/lib")))
+ (mkdir-p bindir)
+ (mkdir-p includedir)
+ (mkdir-p libdir)
+ (copy-file "wasm3" (string-append bindir "/wasm3"))
+ (for-each (lambda (header)
+ (copy-file header
+ (string-append includedir "/"
+ (basename header))))
+ (find-files "../source/source" "\\.h$"))
+ (copy-file "source/libm3.a"
+ (string-append libdir "/libm3.a"))))))))
+ (home-page "https://github.com/wasm3/wasm3")
+ (synopsis "WebAssembly interpreter")
+ (description "WASM3 is a fast WebAssembly interpreter.")
+ (license license:expat)))
+
(define-public websocketpp
(package
(name "websocketpp")
--
2.39.1