diff --git a/.gitignore b/.gitignore index 72be4be1..76557bf1 100644 --- a/.gitignore +++ b/.gitignore @@ -155,3 +155,5 @@ Temporary Items # End of https://www.gitignore.io/api/macos scripts + +sys/.node-headers \ No newline at end of file diff --git a/sys/Cargo.toml b/sys/Cargo.toml index e2b03118..d3e2d849 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -8,6 +8,7 @@ description = "NodeJS N-API raw binding" repository = "https://github.com/napi-rs/napi-rs" license = "MIT" keywords = ["NodeJS", "FFI", "NAPI", "n-api"] +include = ["src/**/*", "Cargo.toml", "build.rs", ".node-headers/**/*"] [features] docs-rs = [] diff --git a/sys/build.rs b/sys/build.rs index 7f795763..36123927 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -1,11 +1,11 @@ extern crate bindgen; -#[cfg(any(target_os = "windows", feature = "docs-rs"))] +#[cfg(target_os = "windows")] extern crate flate2; extern crate glob; -#[cfg(any(target_os = "windows", feature = "docs-rs"))] +#[cfg(target_os = "windows")] extern crate reqwest; extern crate semver; -#[cfg(any(target_os = "windows", feature = "docs-rs"))] +#[cfg(target_os = "windows")] extern crate tar; use glob::glob; @@ -55,7 +55,7 @@ fn main() { .expect("Unable to write napi bindings"); } -#[cfg(any(target_os = "windows", feature = "docs-rs"))] +#[cfg(all(target_os = "windows", not(feature = "docs-rs")))] fn find_node_include_path(node_full_version: &str) -> PathBuf { let mut out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); out_path.push(format!("node-headers-{}.tar.gz", node_full_version)); @@ -81,6 +81,13 @@ fn find_node_include_path(node_full_version: &str) -> PathBuf { header_dist_path } +#[cfg(feature = "docs-rs")] +fn find_node_include_path(_node_full_version: &str) -> PathBuf { + let mut current = env::current_dir().unwrap(); + current.push(".node-headers"); + current +} + #[cfg(not(any(target_os = "windows", feature = "docs-rs")))] fn find_node_include_path(_node_full_version: &str) -> PathBuf { let node_exec_path = String::from_utf8(