mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 06:08:29 +00:00
Allow preconfiguring WASMER_DIR at build time
This commit is contained in:
@@ -10,6 +10,7 @@ license = "MIT"
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
default-run = "wasmer"
|
||||
build = "build.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "wasmer"
|
||||
|
||||
4
lib/cli/build.rs
Normal file
4
lib/cli/build.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
pub fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-env-changed=WASMER_INSTALL_PREFIX");
|
||||
}
|
||||
@@ -45,7 +45,13 @@ impl Config {
|
||||
}
|
||||
fn inner_execute(&self) -> Result<()> {
|
||||
let key = "WASMER_DIR";
|
||||
let wasmer_dir = env::var(key).context(format!(
|
||||
let wasmer_dir = env::var(key)
|
||||
.or_else(|e| {
|
||||
option_env!("WASMER_INSTALL_PREFIX")
|
||||
.map(str::to_string)
|
||||
.ok_or(e)
|
||||
})
|
||||
.context(format!(
|
||||
"failed to retrieve the {} environment variables",
|
||||
key
|
||||
))?;
|
||||
|
||||
@@ -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`")?,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user