//! Persistent caches and guest builds shared by the host integration modules. use std::{ path::{Path, PathBuf}, sync::OnceLock, }; pub const CACHE: &str = concat!(env!("CARGO_TARGET_TMPDIR"), "/cache"); pub fn build(package: &str, binary: &str) -> PathBuf { let root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(); let target = Path::new(concat!(env!("CARGO_TARGET_TMPDIR"), "/guests")); assert!( std::process::Command::new("cargo") .args([ "build", "--offline", "--target", "wasm32-wasip2", "--manifest-path" ]) .arg(root.join(package).join("Cargo.toml")) .arg("--target-dir") .arg(target) .status() .unwrap() .success() ); target .join("wasm32-wasip2/debug") .join(format!("{binary}.wasm")) } pub fn probe() -> PathBuf { static WASM: OnceLock = OnceLock::new(); WASM.get_or_init(|| build("cli/tests/plugins/probe", "probe")) .clone() } pub fn sdk_probe() -> PathBuf { static WASM: OnceLock = OnceLock::new(); WASM.get_or_init(|| build("sdk/tests/plugins/probe", "sdk-probe")) .clone() }