Create a new Rust plugin for qubics. Use when asked to create/scaffold a new plugin, package, or system.
Create a new qubics Rust plugin named $ARGUMENTS.
Create the directory at the project root under a location the user specifies (default: plugins/$ARGUMENTS/).
Create the following files:
Cargo.toml
[package]
name = "$ARGUMENTS"
version = "0.1.0"
edition = "2021"
[lib]
name = "$ARGUMENTS" # use underscores for the lib name (replace hyphens)
crate-type = ["cdylib"]
[dependencies]
qubics = { path = "../../bridges/rs/qubics" }
Adjust the relative path to bridges/rs/qubics based on actual directory depth.
manifest.toml (epk package manifest)
name = "$ARGUMENTS"
version = "0.1.0"
deps = []
Makefile
ifeq ($(origin O), command line)
BUILD_DIR := $(O)
else
BUILD_DIR := .
endif
$(BUILD_DIR)/$ARGUMENTS.dylib: src/lib.rs Cargo.toml
cargo build --release
cp target/release/lib<LIB_NAME>.dylib $(BUILD_DIR)
Replace <LIB_NAME> with the lib name from Cargo.toml (hyphens become underscores).
src/lib.rs — starter plugin with one component and one system:
use qubics::prelude::*;
#[derive(Component)]
struct ExampleComponent {
value: f32,
}
#[system(writes = [ExampleComponent])]
fn example_system(_world: *mut c_void) {
// TODO: implement
}
Add the plugin name to the deps array in the root manifest.toml.
Run: epk add <path-to-plugin-dir>
This registers the plugin source in the local registry so epk install can find it.
Run cargo build --release inside the plugin directory to confirm it compiles.
cdylib — the engine loads plugins as .dylib shared libraries via dlopeninventory crate — no manual wiring needed, just use #[system(...)]#[derive(Component)] which generates a static ComponentDescriptor#[system] attribute takes reads = [...] and writes = [...] listing component types the system accesses — the scheduler uses these to determine which systems can run in parallel(_world: *mut c_void) as their signaturequbics_plugin automatically through the qubics crate — do not define it manually