diff --git a/lib/runtime-c-api/build.rs b/lib/runtime-c-api/build.rs index f78c5cf6920..5b05670bacc 100644 --- a/lib/runtime-c-api/build.rs +++ b/lib/runtime-c-api/build.rs @@ -1,7 +1,7 @@ #[cfg(feature = "generate-c-api-headers")] extern crate cbindgen; -use std::env; +use std::{env, path::Path}; static CAPI_ENV_VAR: &str = "WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS"; @@ -14,6 +14,12 @@ fn main() { #[cfg(feature = "generate-c-api-headers")] fn build() { let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let out_dir = env::var("OUT_DIR").unwrap(); + let out_path = Path::new(&out_dir); + let mut wasmer_h = out_path.to_path_buf(); + wasmer_h.push("wasmer.h"); + let mut wasmer_hh = out_path.to_path_buf(); + wasmer_hh.push("wasmer.hh"); use cbindgen::Language; cbindgen::Builder::new() @@ -22,7 +28,7 @@ fn build() { .with_include_guard("WASMER_H") .generate() .expect("Unable to generate C bindings") - .write_to_file("wasmer.h"); + .write_to_file(wasmer_h); cbindgen::Builder::new() .with_crate(crate_dir) @@ -30,7 +36,7 @@ fn build() { .with_include_guard("WASMER_H") .generate() .expect("Unable to generate C++ bindings") - .write_to_file("wasmer.hh"); + .write_to_file(wasmer_hh); } #[cfg(not(feature = "generate-c-api-headers"))]