mirror of
https://github.com/BeamMW/rust-shaders.git
synced 2026-10-03 23:02:03 +00:00
No description
- Rust 92.1%
- Shell 5%
- Makefile 2.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| common | ||
| Shaders | ||
| .gitignore | ||
| build.sh | ||
| Cargo.toml | ||
| Makefile | ||
| README.md | ||
Beam Shader in Rust language (in development)
Beam shader with C++ bvm bindings for Rust
Project Structure
root/
├── common/ # Common files that contracts need
├── Shaders/ # Individual contracts
│ └── HelloWorld/ # Example HelloWorld contract
│ ├── app/ # Manager/interface part
│ └── contract/ # Contract implementation
└── Cargo.toml # Workspace configuration
Usage
- Install
rustupon your system. See rust installation instructions here. - Install rust toolchain:
$ rustup toolchain install stable - Add wasm32-wasi target
$ rustup target add wasm32-wasi
Building Contracts
Option 1: Using Make (Recommended)
# Build all contracts
$ make
# Build a specific contract
$ make build-contract CONTRACT=HelloWorld
# List available contracts
$ make list-contracts
# Clean build artifacts
$ make clean
Option 2: Using Build Script
# Build all contracts
$ ./build.sh
# Build a specific contract
$ ./build.sh HelloWorld
Option 3: Using Cargo Directly
# Build all contracts (files will be mixed in target/wasm32-wasi/release/)
$ cargo build --target wasm32-wasi -r
# Build a specific contract
$ cargo build --target wasm32-wasi -r -p app -p contract
Output Structure
When using the build scripts or Make, compiled wasm files are organized by contract:
target/wasm32-wasi/release/wasm/
├── HelloWorld/
│ ├── app.wasm
│ └── contract.wasm
└── [OtherContract]/
├── app.wasm
└── contract.wasm
After that you can use app.wasm and contract.wasm files in the same way you use it in Beam's contracts (see https://github.com/BeamMW/shader-sdk/wiki/Running-Beam-Shaders-using-CLI-Wallet).
Adding New Contracts
To add a new contract:
- Create a new directory under
Shaders/(e.g.,Shaders/MyContract/) - Add
app/andcontract/subdirectories with their respectiveCargo.tomlandsrc/lib.rsfiles - Update the root
Cargo.tomlworkspace members to include your new contract paths - Ensure both
appandcontractdepend on thecommoncrate
Originally developed by https://github.com/iKapitonau/beam_shader_rust