mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 21:58:20 +00:00
Allow preconfiguring WASMER_DIR at build time
This commit is contained in:
@@ -10,6 +10,7 @@ license = "MIT"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
default-run = "wasmer"
|
default-run = "wasmer"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "wasmer"
|
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,10 +45,16 @@ impl Config {
|
|||||||
}
|
}
|
||||||
fn inner_execute(&self) -> Result<()> {
|
fn inner_execute(&self) -> Result<()> {
|
||||||
let key = "WASMER_DIR";
|
let key = "WASMER_DIR";
|
||||||
let wasmer_dir = env::var(key).context(format!(
|
let wasmer_dir = env::var(key)
|
||||||
"failed to retrieve the {} environment variables",
|
.or_else(|e| {
|
||||||
key
|
option_env!("WASMER_INSTALL_PREFIX")
|
||||||
))?;
|
.map(str::to_string)
|
||||||
|
.ok_or(e)
|
||||||
|
})
|
||||||
|
.context(format!(
|
||||||
|
"failed to retrieve the {} environment variables",
|
||||||
|
key
|
||||||
|
))?;
|
||||||
|
|
||||||
let prefix = PathBuf::from(wasmer_dir);
|
let prefix = PathBuf::from(wasmer_dir);
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,13 @@ fn generate_header(header_file_src: &[u8]) -> anyhow::Result<()> {
|
|||||||
|
|
||||||
fn get_wasmer_dir() -> anyhow::Result<PathBuf> {
|
fn get_wasmer_dir() -> anyhow::Result<PathBuf> {
|
||||||
Ok(PathBuf::from(
|
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