Skip to main content

llama_cpp_wrapper_sources/
vendored_source_paths.rs

1use std::path::Path;
2use std::path::PathBuf;
3
4use crate::constants::VENDORED_SOURCES;
5
6#[must_use]
7pub fn vendored_source_paths(llama_cpp_dir: &Path) -> Vec<PathBuf> {
8    VENDORED_SOURCES
9        .iter()
10        .map(|vendored_source| llama_cpp_dir.join(vendored_source))
11        .collect()
12}
13
14#[cfg(test)]
15mod tests {
16    use std::path::Path;
17    use std::path::PathBuf;
18
19    use super::vendored_source_paths;
20
21    #[test]
22    fn every_vendored_source_is_resolved_against_the_llama_cpp_dir() {
23        assert_eq!(
24            vendored_source_paths(Path::new("/repo/llama-cpp-native/llama.cpp")),
25            [
26                PathBuf::from("/repo/llama-cpp-native/llama.cpp/tools/server/server-common.cpp"),
27                PathBuf::from("/repo/llama-cpp-native/llama.cpp/tools/server/server-decision.cpp"),
28            ]
29        );
30    }
31}