Writing sibling assets



If a library needs certain assets (such as images), what’s the recommended way to automatically output that alongside the compiled executable? I don’t want to embed the assets into the executable, I’d ideally have them written in the same folder as the executable.

Actual Use-Case

CEF (the Chromium Embedded Framework, which Servo broke its support for :frowning: ) takes a path to a slave executable. Right now I’m include_bytes!ing the slave into the main executable, then writing it to a temporary file on startup, which is okay because it’s only 12KB, but it’s definitely not ideal.


I don’t think there’s any built-in solution in Rust/Cargo.

If you include both bin and lib targets in your Cargo project, then they will end up being built in the same target subdirectory, but that isn’t guaranteed to always be the case (e.g. if the library itself is used as a dependency of another library, only lib target will be built).

You’ll need a separate post build step to package the library the way you want.