fix: search path

This commit is contained in:
2025-03-15 14:18:02 +01:00
parent 4e1d4faf91
commit 2cab4b7ae3

View File

@@ -1,21 +1,23 @@
use make_cmd;
use std::env; use std::env;
use std::path::{Path, PathBuf}; use std::path::PathBuf;
fn main() { fn main() {
// This is the directory where the `c` library is located. // This is the directory where the `c` library is located.
let libdir_path = PathBuf::from("mlkem-native/mlkem") let libdir_path = PathBuf::from("mlkem-native")
// Canonicalize the path as `rustc-link-search` requires an absolute // Canonicalize the path as `rustc-link-search` requires an absolute
// path. // path.
.canonicalize() .canonicalize()
.expect("cannot canonicalize path"); .expect("cannot canonicalize path");
// This is the path to the `c` headers file. // This is the path to the `c` headers file.
let headers_path = libdir_path.join("mlkem_native.h"); let headers_path = libdir_path.join("mlkem/mlkem_native.h");
let headers_path_str = headers_path.to_str().expect("Path is not a valid string"); let headers_path_str = headers_path.to_str().expect("Path is not a valid string");
// Tell cargo to look for shared libraries in the specified directory // Tell cargo to look for shared libraries in the specified directory
println!("cargo:rustc-link-search={}", libdir_path.to_str().unwrap()); println!(
"cargo:rustc-link-search={}",
libdir_path.join("examples/build").to_str().unwrap()
);
// Tell cargo to tell rustc to link our `hello` library. Cargo will // Tell cargo to tell rustc to link our `hello` library. Cargo will
// automatically know it must look for a `libhello.a` file. // automatically know it must look for a `libhello.a` file.