Closed roblabla closed 3 years ago
Does the current master
branch (at least 0e2520188990221e7b95e5f7f76ab40b2230199e) work for you? It just always adds $OUT_DIR
to the include path, which I think is preferable for 99% of use-cases, and I'm not too too hot on adding another overload to compile()
or parsing an environment variable, until that's actually needed, at least.
Yeah, that's probably enough for my use-case. Thanks!
Cool, released in v1.6.0
!
Can confirm it works!
windres, rc and llvm-rc (through the C preprocessor) all have the ability to pass additional include paths to be used by the preprocessor, e.g.
windres -I path
orrc /I path
. Exposing this to the command line would be useful to allow users to generate header files that they could then use in theirresource.rc
.This would allow some more sophisticated resource files to get embedded. Here, for instance, we generate a
cargo.h
that contains defines for various environment variables cargo gives us, and an RC file that includes it and uses it to generate a VS_VERSION_INFO section with the correct version.RC file
```c #includebuild.rs files
```rust fn main() { // Generate cargo.h, included by resources.rc let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap()); std::fs::write(out_dir.join("cargo.h"), format!(r#" #define CARGO_PKG_VERSION "{}" #define CARGO_PKG_VERSION_MAJOR {} #define CARGO_PKG_VERSION_MINOR {} #define CARGO_PKG_VERSION_PATCH {} #define CARGO_PKG_VERSION_PRE {}"#, std::env::var("CARGO_PKG_VERSION").unwrap(), std::env::var("CARGO_PKG_VERSION_MAJOR").unwrap(), std::env::var("CARGO_PKG_VERSION_MINOR").unwrap(), std::env::var("CARGO_PKG_VERSION_PATCH").unwrap(), std::env::var("CARGO_PKG_VERSION_PRE").unwrap(), )).unwrap(); embed_resource::compile("resources/resources.rc", &[&out_dir]); } ```