Allow preconfiguring WASMER_DIR at build time

This commit is contained in:
Julius Michaelis
2021-02-22 13:27:00 +09:00
parent 8041f03bc4
commit 80ec06ffab
4 changed files with 22 additions and 5 deletions

View File

@@ -155,7 +155,13 @@ fn generate_header(header_file_src: &[u8]) -> anyhow::Result<()> {
fn get_wasmer_dir() -> anyhow::Result<PathBuf> {
Ok(PathBuf::from(
env::var("WASMER_DIR").context("Trying to read env var `WASMER_DIR`")?,
env::var("WASMER_DIR")
.or_else(|e| {
option_env!("WASMER_INSTALL_PREFIX")
.map(str::to_string)
.ok_or(e)
})
.context("Trying to read env var `WASMER_DIR`")?,
))
}