build(sys): make cargo docs work
This commit is contained in:
parent
517f383b0e
commit
d141edb02d
3 changed files with 14 additions and 4 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -155,3 +155,5 @@ Temporary Items
|
|||
|
||||
# End of https://www.gitignore.io/api/macos
|
||||
scripts
|
||||
|
||||
sys/.node-headers
|
|
@ -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 = []
|
||||
|
|
15
sys/build.rs
15
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(
|
||||
|
|
Loading…
Reference in a new issue