Skip to main content

copy_res_to_output_dir

Function copy_res_to_output_dir 

Source
pub fn copy_res_to_output_dir() -> Result<(), Box<dyn Error>>
Expand description

Copies everything matching res/* in the calling crate into a res/ folder next to the built executable, so binaries can load assets through plain relative paths (e.g. ./res/textures/smug.png) no matter how they’re started.

Meant to be called from a crate’s build.rs; it relies on the CARGO_MANIFEST_DIR and OUT_DIR variables Cargo sets for build scripts. Does nothing if the crate has no res/ directory.