Let's say I have the command OPENSSL_STATIC=1 OPENSSL_LIB_DIR=<some-pkg-config-command> cargo b that builds a binary (link openssl statically). Can I just call cargo b and deal with environment files inside the build.rs?
I tried Build Scripts - The Cargo Book (not working or may be I am holding it wrong), and std::env::set_var inside build.rs (didn't work).
Ideally, I'd prefer not to use another script/tool to set environment variables, e.g., OPENSSL_LIB_DIR, which is fetched using pkg-config. before I call cargo b. I do have Justfile in my build pipeline though.
This looks promising. Examples show static environment variables only. I guess I can't set this variable during build time? I need to call pkg-config to get include path of openssl and set an environment variable. The only place I know that is called at build-time is build.rs.
Another option is to streamline the pipeline using cargo-xtask.
the former only sets envars when building your crate, not it's dependencies. the latter only affects that build script, not any processes cargo invokes after reading the output of that build script, such as rustc.