Conversation
Paths in deltachat.pc are passed via env variables to build.rs. With this fix, the pc will be regenerated if these env variables change. This came up when building via CMake: the paths depend on CMAKE_INSTALL_PREFIX, if the CMAKE_INSTALL_PREFIX changes during a reconfigure, deltachat.pc should have the corresponding paths adjusted.
| prefix = env::var("PREFIX").unwrap_or_else(|_| "/usr/local".to_string()), | ||
| libdir = env::var("LIBDIR").unwrap_or_else(|_| "/usr/local/lib".to_string()), | ||
| includedir = env::var("INCLUDEDIR").unwrap_or_else(|_| "/usr/local/include".to_string()), | ||
| prefix = option_env!("PREFIX").unwrap_or_else(|| "/usr/local"), |
There was a problem hiding this comment.
The disadvantage of this is that this builds the value itself into the build script executable (as a static str), so the build script will have to be rebuilt every time. It looks like option_env! is meant for the source code of the programs rather than build scripts.
A better way is probably to add println!("cargo:rerun-if-changed=PREFIX") to the build script: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-env-changed
There was a problem hiding this comment.
Before I tried it and to me it looked like the build script only got re executed when the env variable actually changed (which is what we want)
There was a problem hiding this comment.
I think the build script is also rebuilt because the value is built into the binary produced from build.rs, which is unnecessary.
There was a problem hiding this comment.
Not a big deal because compiling build.rs is very cheap (compared to compiling the library).
Paths in deltachat.pc are passed via env variables to build.rs. With this fix, the pc will be regenerated if these env variables change.
This came up when building via CMake: the paths depend on CMAKE_INSTALL_PREFIX, if the CMAKE_INSTALL_PREFIX changes during a reconfigure, deltachat.pc should have the corresponding paths adjusted.