This is a command line tool that acts as a companion to my w4 module for Zig ⚡
w4-init is used to create a directory containing code that
allows you to promptly get started coding on a cart for the
lovely little fantasy console WASM-4.
The Zig build .target is declared as .{ .cpu_arch = .wasm32, .os_tag = .wasi }
and .optimize defaults to .small
Important
No need to specify -Doptimize=small
Requires you to have Go installed.
go install github.com/peterhellberg/w4-init@latestRequires Zig 0.17.1 or newer to build the generated cart.
(As well as npx, which is part of Node.js these days)
w4-init mycart
cd mycart
zig build runThe deployment defaults can also be set with environment variables:
| Flag | Environment variable | Default |
|---|---|---|
-hostname |
W4_INIT_HOSTNAME |
play.c7.se |
-server-path |
W4_INIT_SERVER_PATH |
/var/www/play.c7.se |
-backup-path |
W4_INIT_BACKUP_PATH |
/run/user/1000/gvfs/smb-share:server=diskstation.local,share=backups/Code/Fantasy/WASM-4 |
An explicit flag wins over its environment variable, which wins over the built-in default. Empty environment variables are ignored.
Tip
There is also a zig build --watch command that can
be used to trigger automatic reload of the WASM-4
cart running in the browser when a file is changed.
Note
Arguments after -- are forwarded to WASM-4, for example
zig build run -- --port 5555.
🌱