Skip to content

Commit

Permalink
Add build file to handle wasmstan feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sd2k committed Nov 7, 2024
1 parent 16bb34b commit 5d8dc21
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions crates/augurs-prophet/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,32 @@ fn handle_cmdstan() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(feature = "wasmstan")]
fn copy_wasmstan() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
let prophet_path = std::path::PathBuf::from(concat!(
env!("CARGO_MANIFEST_DIR"),
"/prophet-wasmstan.wasm"
))
.canonicalize()?;
let wasmstan_path = out_dir.join("prophet-wasmstan.wasm");
std::fs::copy(&prophet_path, &wasmstan_path)?;
eprintln!(
"Copied prophet-wasmstan.wasm from {} to {}",
prophet_path.display(),
wasmstan_path.display(),
);
Ok(())
}

fn handle_wasmstan() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "wasmstan")]
copy_wasmstan()?;
Ok(())
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
handle_cmdstan()?;
handle_wasmstan()?;
Ok(())
}

0 comments on commit 5d8dc21

Please sign in to comment.