mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
chore: clippy fix (#2144)
This commit is contained in:
parent
14d88997d7
commit
ea623903d8
@ -1,4 +1,5 @@
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
#![allow(clippy::zero_repeat_side_effects)]
|
||||
#![allow(deprecated)]
|
||||
|
||||
#[macro_use]
|
||||
|
||||
@ -2,7 +2,7 @@ use napi::{CallContext, JsExternal, JsObject, JsString};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct QueryEngine {
|
||||
pub datamodel: String,
|
||||
pub _datamodel: String,
|
||||
}
|
||||
|
||||
unsafe impl Sync for QueryEngine {}
|
||||
@ -40,7 +40,7 @@ fn new_engine(ctx: CallContext) -> napi::Result<napi::JsExternal> {
|
||||
let a = ctx.get::<JsString>(0)?.into_utf8()?;
|
||||
let model = a.into_owned()?;
|
||||
let model_len = model.len();
|
||||
let qe = QueryEngine { datamodel: model };
|
||||
let qe = QueryEngine { _datamodel: model };
|
||||
ctx.env.create_external(qe, Some(model_len as i64))
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
mod android;
|
||||
mod macos;
|
||||
mod wasi;
|
||||
mod windows;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn setup() {
|
||||
println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE");
|
||||
@ -18,51 +18,11 @@ pub fn setup() {
|
||||
Ok("wasi") => {
|
||||
wasi::setup();
|
||||
}
|
||||
Ok("windows") => {
|
||||
if let Ok("gnu") = env::var("CARGO_CFG_TARGET_ENV").as_deref() {
|
||||
windows::setup_gnu();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if env::var("CARGO_CFG_TARGET_ENV").unwrap().contains("gnu") {
|
||||
let target_triple = env::var("TARGET").unwrap();
|
||||
if target_triple.contains("windows") {
|
||||
let libnode_path = search_libnode_path();
|
||||
if let Some(libnode_dir) = libnode_path {
|
||||
let node_lib_path = libnode_dir.join("libnode.dll");
|
||||
if node_lib_path.exists() {
|
||||
println!("cargo:rustc-link-search=native={}", libnode_dir.display());
|
||||
println!("cargo:rustc-link-lib=node");
|
||||
} else {
|
||||
panic!("libnode.dll not found in {}", libnode_dir.display());
|
||||
}
|
||||
} else {
|
||||
panic!("libnode.dll not found in any search path");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn search_libnode_path() -> Option<PathBuf> {
|
||||
if let Ok(path) = env::var("LIBNODE_PATH") {
|
||||
let libnode_dir = PathBuf::from(path);
|
||||
if libnode_dir.exists() {
|
||||
return Some(libnode_dir);
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(paths) = env::var("LIBPATH") {
|
||||
for path in env::split_paths(&paths) {
|
||||
if path.join("libnode.dll").exists() {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(paths) = env::var("PATH") {
|
||||
for path in env::split_paths(&paths) {
|
||||
if path.join("libnode.dll").exists() {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
44
crates/build/src/windows.rs
Normal file
44
crates/build/src/windows.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn setup_gnu() {
|
||||
let libnode_path = search_libnode_path();
|
||||
if let Some(libnode_dir) = libnode_path {
|
||||
let node_lib_path = libnode_dir.join("libnode.dll");
|
||||
if node_lib_path.exists() {
|
||||
println!("cargo:rustc-link-search=native={}", libnode_dir.display());
|
||||
println!("cargo:rustc-link-lib=node");
|
||||
} else {
|
||||
panic!("libnode.dll not found in {}", libnode_dir.display());
|
||||
}
|
||||
} else {
|
||||
panic!("libnode.dll not found in any search path");
|
||||
}
|
||||
}
|
||||
|
||||
fn search_libnode_path() -> Option<PathBuf> {
|
||||
if let Ok(path) = env::var("LIBNODE_PATH") {
|
||||
let libnode_dir = PathBuf::from(path);
|
||||
if libnode_dir.exists() {
|
||||
return Some(libnode_dir);
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(paths) = env::var("LIBPATH") {
|
||||
for path in env::split_paths(&paths) {
|
||||
if path.join("libnode.dll").exists() {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(paths) = env::var("PATH") {
|
||||
for path in env::split_paths(&paths) {
|
||||
if path.join("libnode.dll").exists() {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
@ -101,4 +101,4 @@ optional = true
|
||||
version = "2"
|
||||
|
||||
[build-dependencies]
|
||||
napi-build = {path = "../build"}
|
||||
napi-build = { path = "../build" }
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
extern crate napi_build;
|
||||
|
||||
fn main() {
|
||||
napi_build::setup();
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();
|
||||
if target_os == "windows" && target_env == "gnu" {
|
||||
napi_build::setup();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::{ptr, usize};
|
||||
use std::ptr;
|
||||
|
||||
use super::{FromNapiValue, ToNapiValue, TypeName, Unknown, ValidateNapiValue};
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ pub fn call_function_with_this(ctx: CallContext) -> Result<JsNull> {
|
||||
let js_this: JsObject = ctx.this_unchecked();
|
||||
let js_func = ctx.get::<Function<()>>(0)?;
|
||||
|
||||
js_func.apply(&js_this, ())?;
|
||||
js_func.apply(js_this, ())?;
|
||||
|
||||
ctx.env.get_null()
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#![allow(unused_variables)]
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
#![allow(clippy::zero_repeat_side_effects)]
|
||||
#![allow(deprecated)]
|
||||
|
||||
#[macro_use]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user