Merge pull request #135 from napi-rs/docs-rs

build: try fix docs-rs build
This commit is contained in:
LongYinan 2020-08-16 16:19:56 +08:00 committed by GitHub
commit 16bdce56c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View file

@ -32,3 +32,6 @@ optional = true
[build-dependencies] [build-dependencies]
napi-build = { version = "0.2", path = "../build" } napi-build = { version = "0.2", path = "../build" }
[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]

View file

@ -10,9 +10,6 @@ license = "MIT"
keywords = ["NodeJS", "FFI", "NAPI", "n-api"] keywords = ["NodeJS", "FFI", "NAPI", "n-api"]
include = ["src/**/*", "Cargo.toml", "build.rs", ".node-headers/**/*"] include = ["src/**/*", "Cargo.toml", "build.rs", ".node-headers/**/*"]
[features]
docs-rs = []
[target.'cfg(windows)'.build-dependencies] [target.'cfg(windows)'.build-dependencies]
flate2 = "1.0" flate2 = "1.0"
reqwest = { version = "0.10", features = ["native-tls", "blocking"] } reqwest = { version = "0.10", features = ["native-tls", "blocking"] }
@ -30,4 +27,4 @@ regex = "1.3"
semver = "0.10" semver = "0.10"
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["docs-rs"] rustc-args = ["--cfg", "docsrs"]

View file

@ -14,7 +14,7 @@ use std::env;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
#[cfg(not(any(target_os = "windows", feature = "docs-rs")))] #[cfg(not(any(target_os = "windows", docsrs)))]
const NODE_PRINT_EXEC_PATH: &'static str = "console.log(process.execPath)"; const NODE_PRINT_EXEC_PATH: &'static str = "console.log(process.execPath)";
fn main() { fn main() {
@ -55,7 +55,7 @@ fn main() {
.expect("Unable to write napi bindings"); .expect("Unable to write napi bindings");
} }
#[cfg(all(target_os = "windows", not(feature = "docs-rs")))] #[cfg(all(target_os = "windows", not(docsrs)))]
fn find_node_include_path(node_full_version: &str) -> PathBuf { fn find_node_include_path(node_full_version: &str) -> PathBuf {
let mut out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let mut out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
out_path.push(format!("node-headers-{}.tar.gz", node_full_version)); out_path.push(format!("node-headers-{}.tar.gz", node_full_version));
@ -81,14 +81,14 @@ fn find_node_include_path(node_full_version: &str) -> PathBuf {
header_dist_path header_dist_path
} }
#[cfg(feature = "docs-rs")] #[cfg(docsrs)]
fn find_node_include_path(_node_full_version: &str) -> PathBuf { fn find_node_include_path(_node_full_version: &str) -> PathBuf {
let mut current = env::current_dir().unwrap(); let mut current = env::current_dir().unwrap();
current.push(".node-headers"); current.push(".node-headers");
current current
} }
#[cfg(not(any(target_os = "windows", feature = "docs-rs")))] #[cfg(not(any(target_os = "windows", docsrs)))]
fn find_node_include_path(_node_full_version: &str) -> PathBuf { fn find_node_include_path(_node_full_version: &str) -> PathBuf {
let node_exec_path = String::from_utf8( let node_exec_path = String::from_utf8(
Command::new("node") Command::new("node")