This is a template for getting started with a roc platform using Zig.
If you have any ideas to improve this template, please let me know. 😀
Dependencies:
nix develop
Note we can upgrade to zig 0.13.0 when
https://github.com/roc-lang/roc/pull/6921 lands. You can do this now if you
would prefer to use 0.13.0 just be sure to copy the builtins *.zig
from that
branch. In future we should have a roc_std
zig package that is more suitable
for platform development, but the builtins are ok for now.
$ roc build.roc
Build the platform with roc build.roc
to produce the prebuilt-binaries in platform/
.
Note we use -Doptimize=ReleaseFast
when building the zig host, to disable the stack probe which causes issues on Intel Macs. You may wish to remove this if you want debug symbols.
After the platform is build, you can run an example using roc
.
$ roc examples/hello.roc
Roc loves Zig
$ ROC=roc EXAMPLES_DIR=examples/ ./ci/all_tests.sh
Bundle the platform first using roc build.roc
, and then create a bundle with:
$ roc build --bundle .tar.br platform/main.roc
This will package up all the *.roc
files a prebuilt host files *.a
*.rh
etc from platform/
and give you a file like platform/GusyN64cWI5ri8GtTv90sgKKjEtj2i8GXKaWhI0-Tk8.tar.br
which you can distribute to other users by hosting online and sharing the URL.
Generate the documentation with roc docs platform/main.roc
and then serve the files in generated-docs/
using a webserver.
You can generate the LLVM IR for the app with roc build --no-link --emit-llvm-ir examples/hello.roc
which is an authoritative reference for what roc will generate in the application object.