diff --git a/.rules/no-println.yaml b/.rules/no-println.yaml new file mode 100644 index 0000000..80d2ee1 --- /dev/null +++ b/.rules/no-println.yaml @@ -0,0 +1,11 @@ +id: no_println +message: Do not use println! use `tracing::info`/`tracing::trace`/`tracing::debug` instead +severity: warning +language: Rust +rule: + all: + - kind: macro_invocation + - pattern: println!($$$ITEMS) +fix: tracing::info!($$$ITEMS) +ignores: + - ./*build.rs diff --git a/.rules/no-unwrap.yml b/.rules/no-unwrap.yml new file mode 100644 index 0000000..048d613 --- /dev/null +++ b/.rules/no-unwrap.yml @@ -0,0 +1,8 @@ +id: no_unwrap +message: Do not use unwrap +description: Do not use unwrap +severity: warning +language: Rust +rule: + pattern: $ITEM.unwrap() +exclude: ./*build.rs diff --git a/deny.toml b/deny.toml index ee453ec..1e7ddbc 100644 --- a/deny.toml +++ b/deny.toml @@ -88,7 +88,7 @@ ignore = [ # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. -allow = ["MIT", "Apache-2.0", "BSD-3-Clause", "ISC", "Unicode-DFS-2016"] +allow = ["MIT", "Apache-2.0", "BSD-3-Clause", "ISC", "Unicode-DFS-2016", "Zlib"] # The confidence threshold for detecting a license from license text. # The higher the value, the more closely the license text must be to the # canonical license text of a valid SPDX license file. diff --git a/flake.nix b/flake.nix index dc8bde4..ff4f96d 100644 --- a/flake.nix +++ b/flake.nix @@ -160,34 +160,34 @@ partitionType = "count"; cargoExtraArgs = "-p mnn-sys"; }); - mnn-lints = sgLib.scan ./.; - mnn-asan = let - rustPlatform = pkgs.makeRustPlatform { - cargo = nightlyToolchain; - rustc = nightlyToolchain; - }; - in - rustPlatform.buildRustPackage ( - commonArgs - // { - inherit src; - name = "mnn-leaks"; - cargoLock = { - lockFile = ./Cargo.lock; - outputHashes = { - "cmake-0.1.50" = "sha256-GM2D7dpb2i2S6qYVM4HYk5B40TwKCmGQnUPfXksyf0M="; - }; - }; - - buildPhase = '' - cargo test --target aarch64-apple-darwin - ''; - RUSTFLAGS = "-Zsanitizer=address"; - ASAN_OPTIONS = "detect_leaks=1"; - # MNN_COMPILE = "NO"; - # MNN_LIB_DIR = "${pkgs.mnn}/lib"; - } - ); + # mnn-lints = sgLib.scan ./.; + # mnn-asan = let + # rustPlatform = pkgs.makeRustPlatform { + # cargo = nightlyToolchain; + # rustc = nightlyToolchain; + # }; + # in + # rustPlatform.buildRustPackage ( + # commonArgs + # // { + # inherit src; + # name = "mnn-leaks"; + # cargoLock = { + # lockFile = ./Cargo.lock; + # outputHashes = { + # "cmake-0.1.50" = "sha256-GM2D7dpb2i2S6qYVM4HYk5B40TwKCmGQnUPfXksyf0M="; + # }; + # }; + # + # buildPhase = '' + # cargo test --target aarch64-apple-darwin + # ''; + # RUSTFLAGS = "-Zsanitizer=address"; + # ASAN_OPTIONS = "detect_leaks=1"; + # # MNN_COMPILE = "NO"; + # # MNN_LIB_DIR = "${pkgs.mnn}/lib"; + # } + # ); }; packages = rec { diff --git a/mnn-sys/build.rs b/mnn-sys/build.rs index 525318b..5eb6364 100644 --- a/mnn-sys/build.rs +++ b/mnn-sys/build.rs @@ -111,12 +111,10 @@ fn main() -> Result<()> { "cargo:rustc-link-search=native={}", install_dir.join("lib").display() ); + } else if let core::result::Result::Ok(lib_dir) = std::env::var("MNN_LIB_DIR") { + println!("cargo:rustc-link-search=native={}", lib_dir); } else { - if let Some(lib_dir) = std::env::var("MNN_LIB_DIR").ok() { - println!("cargo:rustc-link-search=native={}", lib_dir); - } else { - panic!("MNN_LIB_DIR not set while MNN_COMPILE is false"); - } + panic!("MNN_LIB_DIR not set while MNN_COMPILE is false"); } mnn_c_build(PathBuf::from(MANIFEST_DIR).join("mnn_c"), &vendor)