I have a library crate that assumes some config directory will be present at the cargo manifest level of a consuming binary package. I'd like to be able to include the contents of the files in that config directory in the binary, e.g. with include_str, so that they are accessible within the library crate.
Sorry, that’s not what I mean. I want the library to be able to load them from the consuming binary. The contract would be that the files exist at compile time. I don’t want to have to load them in the binary and pass them as arguments.
I’ve been looking at build.rs in the lib but it doesn’t seem possible to access the source of the binary application. Similarly with build.rs in the binary, I can’t inject the files into the out directory and include them in the lib.
When you say a build script, were you meaning build.rs or some custom setup?
I think the issue I have is that the library is really also the application. The binary is used to provide some customisation through traits and the main entry point.
Maybe I just need to rethink the architecture of this.
I was thinking a build script in the library rather than the binary yes. From a perspective of hermeticity I'd expect that to be the most common build workflow of a library, but I really never got into complex build patterns and haven't fully grasped what the contents of the file is you need when building your library. It does sound like the border between lib and binary is rather vague and cross-cutting and might be better abstracted in some way, maybe a macro or something?