Summary
Introduce graphic! and font! procedural macros via a new ply-macros sub-crate to make asset embedding the ergonomic default.
Motivation
Users frequently report runtime issues because their assets are missing from the execution path. Embedding assets directly into the binary is much safer, but currently requires verbose boilerplate and brittle, module-relative paths (e.g., ../assets/...). Moving string-splitting and path-resolution logic into a compile-time procedural macro allows us to enforce embedding seamlessly without ruining ergonomics.
Proposed API
static LOGO: GraphicAsset = graphic!("assets/images/logo.png");
static FONT: FontAsset = font!("assets/fonts/lexend.ttf");
Currently, developers have to do this:
static LOGO: GraphicAsset = GraphicAsset::Bytes {
file_name: "logo.png",
data: include_bytes!("../assets/images/logo.png"),
};
Behavior
- Introduce a new
ply-macros procedural macro crate inside the root directory.
- Re-export the
graphic! and font! macros cleanly inside ply_engine::prelude.
- Parse the input string literal at compile time to automatically extract the file name.
- Resolve asset paths relative to the workspace root using
CARGO_MANIFEST_DIR so that macros function reliably regardless of which deeply nested source module invokes them.
- Verify file existence inside the macro and emit a clear compile-time error if an asset path is missing.
GraphicAsset::Path and FontAsset::Path should be marked as #[deprecated]
Summary
Introduce
graphic!andfont!procedural macros via a newply-macrossub-crate to make asset embedding the ergonomic default.Motivation
Users frequently report runtime issues because their assets are missing from the execution path. Embedding assets directly into the binary is much safer, but currently requires verbose boilerplate and brittle, module-relative paths (e.g.,
../assets/...). Moving string-splitting and path-resolution logic into a compile-time procedural macro allows us to enforce embedding seamlessly without ruining ergonomics.Proposed API
Currently, developers have to do this:
Behavior
ply-macrosprocedural macro crate inside the root directory.graphic!andfont!macros cleanly insideply_engine::prelude.CARGO_MANIFEST_DIRso that macros function reliably regardless of which deeply nested source module invokes them.GraphicAsset::PathandFontAsset::Pathshould be marked as#[deprecated]