This example creates Janet script or executable using Zig module located at https://github.com/greenfork/jzignet-module-template. This module is supposed to be used as a template for your modules as well.
Requires Zig version of at least 0.10.0, zig executable must be in PATH. You can download the latest Zig build from https://ziglang.org/download/. You will also need Janet and jpm installed on your system https://github.com/janet-lang/janet/releases.
-
Install our dependency at https://github.com/greenfork/jzignet-module-template:
$ jpm -l deps
-
Run the Janet source code
$ jpm -l janet src/main.janet 1 6
-
Or from the shell
$ jpm -l janet (use zig_module) (def st (init-struct)) #=> <zig-struct 0x55F68500AEC0> (get-counter st) #=> 1 (add st 5) #=> nil (get-counter st) #=> 6 # Ctrl-D to quit
-
Or compile into static binary
$ jpm -l build $ ./build/janet_exec 1 6