lukewilliamboswell/roc-platform-template-rust
lukewilliamboswell/roc-platform-template-rust
Rust platform template
- Stars: 10
- Forks: 3
- Watchers: 10
- Open issues: 0
- License: Universal Permissive License v1.0
- Homepage: https://lukewilliamboswell.github.io/roc-platform-template-rust/
- Default branch: main
- Created: 2024-05-18T12:30:06Z
Languages
- Roc
- Rust
- Shell
Topics
- roc-lang
Top Contributors
- lukewilliamboswell (59 contributions)
- kili-ilo (1 contributions)
README
Roc platform template for Rust
A template for building Roc platforms using Rust.
Requirements
Examples
The examples in this repo use the latest release bundle:
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-rust/releases/download/1.0.0/Bu7FVf57VbTwUrUSumuTmQNMJLLmGBmer6L5AarS4qnV.tar.zst" }Run examples with interpreter: roc examples/.roc
Build standalone executable: roc build examples/.roc
Documentation
Platform API docs are published at.
Generate docs locally:
roc docs platform/main.roc --output=generated-docs --no-cacheBuilding
# Build for native platform only
./build.sh
# Build for all supported targets (cross-compilation)
./build.sh --allRegenerating glue
When the platform API changes (e.g. adding or modifying hosted functions in platform/main.roc), regenerate the Rust ABI bindings:
roc glue <path-to>/RustGlue.roc ./src/ platform/main.rocThis overwrites src/roc_platform_abi.rs with updated type definitions and hosted symbol signatures.
Bundling
./bundle.shThis creates a .tar.zst bundle containing all .roc files and prebuilt host libraries.
Running Tests
bash ci/all_tests.shThis builds the platform and runs all examples using roc from your local PATH. For the local-platform pass, the script copies the examples to a temp directory and rewrites their release bundle dependency to this checkout’s platform/main.roc.
The script also creates a native-target platform bundle, serves it over localhost, rewrites temporary copies of the examples to use that package URL, and runs the examples again against the bundled package.
Useful focused runs:
# Skip the package URL pass
RUN_BUNDLE_TEST=0 bash ci/all_tests.sh
# Test only a package URL
RUN_LOCAL_TESTS=0 PACKAGE_URL="https://github.com/lukewilliamboswell/roc-platform-template-rust/releases/download/0.4/3q9Kou2yUcPovfn1NhRrsvtcdfHUWmzyCaGwiupYFXUk.tar.zst" bash ci/all_tests.shSupported Targets
| Target | Library |
|---|---|
| x64mac | platform/targets/x64mac/libhost.a |
| arm64mac | platform/targets/arm64mac/libhost.a |
| x64musl | platform/targets/x64musl/libhost.a |
| arm64musl | platform/targets/arm64musl/libhost.a |
Linux musl targets include statically linked runtime files (crt1.o, libc.a, libunwind.a) for standalone executables.
Platform API
This platform exposes:
Stdout.line!- Print a line to stdoutStderr.line!- Print a line to stderrStdin.line!- Read a line from stdin
The main function receives command-line arguments as List(Str) and returns Try({}, [Exit(I32), ..]).