A Roc platform for creating simple graphics applications.
- 2D drawing primitives (rectangles, circles, lines, text)
- Mouse input handling (position, buttons, wheel)
- Cross-platform support (macOS, Linux, Windows, Web/WASM)
- Native rendering via raylib, web rendering via Canvas 2D
First, build the platform and cross-compile the pre-built host libraries for all supported targets:
zig buildThen run an example:
roc examples/hello_world.rocFor web/WASM, build with the wasm32 target and serve the files:
roc build --target=wasm32 examples/hello_world.rocHelper scripts are available to build and serve WASM:
# Linux/macOS
./build_wasm.sh examples/hello_world.roc
# Windows (PowerShell)
.\build_wasm.ps1 examples\hello_world.rocRun Zig unit tests and WASM integration tests:
zig build testRun all Roc example tests (check, format, test, build, simulation):
python3 ci/all_tests.pyEnable the pre-commit hook (run once after cloning):
git config core.hooksPath .githooksRocRay includes a simulation recording and replay system for deterministic testing of graphical applications. This enables regression testing without requiring a display—useful for CI environments.
- Record a session while running the app normally—inputs (mouse position, buttons, frame count) and outputs (draw commands) are captured to a
.rrsimfile - Replay the session visually to debug or inspect what was recorded
- Test headlessly by re-running the app with recorded inputs and verifying outputs match
| Variable | Description |
|---|---|
SIM_RECORD=path.rrsim |
Record session to file |
SIM_REPLAY=path.rrsim |
Replay visually |
SIM_TEST=path.rrsim |
Headless test mode (verify Roc app behaviour) |
SIM_LOG=path.log |
Write all mismatches to file (no limit) |
# Build and run the app with recording enabled
roc build examples/hello_world.roc
SIM_RECORD=examples/hello_world_1.rrsim ./examples/hello_world
# Interact with the app, then close the window
# The .rrsim file is written on exit# Headless verification—exits 0 if outputs match, 1 if mismatch
SIM_TEST=examples/hello_world_1.rrsim ./examples/hello_world
# With full mismatch log for debugging
SIM_TEST=examples/hello_world_1.rrsim SIM_LOG=mismatches.log ./examples/hello_worldIn CI, simulation tests run automatically for any .rrsim files found in examples/. The naming convention <app>_<n>.rrsim maps to <app>.roc.
./bundle.shThis creates a .tar.zst bundle containing all .roc files and prebuilt host libraries. To use a Roc package bundle it should be hosted online with a https: url.
| Target | Description |
|---|---|
| x64mac | macOS Intel |
| arm64mac | macOS Apple Silicon |
| x64glibc | Linux x64 |
| x64win | Windows x64 |
| wasm32 | Web/WASM |
- We vendor the pre-compiled libraries from raylib v5.5
- ARM Linux is not available (raylib doesn't provide pre-built libraries)
- Extend simulation recording/replay/testing to WASM target for browser-based deterministic testing