Skip to main content

llama_cpp_sys_2/
lib.rs

1//! See [llama-cpp-2](https://crates.io/crates/llama-cpp-2) for a documented and safe API.
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#![allow(unpredictable_function_pointer_comparisons)]
7
8include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
9
10#[cfg(test)]
11mod tests {
12    #[test]
13    fn cxx_stdlib_link_directive_is_not_duplicated() {
14        let out_dir = env!("OUT_DIR");
15        let output_path = std::path::Path::new(out_dir)
16            .parent()
17            .expect("OUT_DIR should have a parent build directory")
18            .join("output");
19        let output = std::fs::read_to_string(&output_path).unwrap_or_else(|err| {
20            panic!(
21                "failed to read build script output {}: {err}",
22                output_path.display()
23            );
24        });
25        let cxx_link_count = output
26            .lines()
27            .filter(|line| *line == "cargo:rustc-link-lib=c++")
28            .count();
29        assert!(
30            cxx_link_count <= 1,
31            "build.rs emitted cargo:rustc-link-lib=c++ {cxx_link_count} times; \
32             the cc crate auto-link plus the explicit Apple println must not both fire"
33        );
34        #[cfg(target_os = "macos")]
35        assert_eq!(
36            cxx_link_count, 1,
37            "macOS must still link libc++ exactly once via the explicit Apple directive"
38        );
39    }
40}