llama_cpp_bindings_build/
build_error.rs1use std::env::VarError;
2use std::io;
3use std::path::PathBuf;
4
5#[derive(Debug, thiserror::Error)]
6pub enum BuildError {
7 #[error("environment variable {name} could not be read: {source}")]
8 Environment {
9 name: &'static str,
10 #[source]
11 source: VarError,
12 },
13 #[error("unsupported target operating system: {cargo_cfg_target_os}")]
14 UnsupportedTargetOs { cargo_cfg_target_os: String },
15 #[error("Android NDK not found for target {target_triple}. Set ANDROID_NDK_HOME.")]
16 AndroidNdkRootNotConfigured {
17 target_triple: String,
18 #[source]
19 source: VarError,
20 },
21 #[error("Android NDK path does not exist: {path}")]
22 AndroidNdkRootMissing { path: PathBuf },
23 #[error("Android NDK toolchain file not found: {path}")]
24 AndroidNdkToolchainFileMissing { path: PathBuf },
25 #[error("Android NDK toolchain not found at: {path}")]
26 AndroidNdkToolchainDirectoryMissing { path: PathBuf },
27 #[error("Unsupported host platform for Android NDK")]
28 AndroidNdkUnsupportedHostPlatform,
29 #[error("Unsupported Android target architecture: {cargo_cfg_target_arch}")]
30 UnsupportedAndroidTarget { cargo_cfg_target_arch: String },
31 #[error("ANDROID_PLATFORM is set but could not be read: {source}")]
32 AndroidPlatformUnreadable {
33 #[source]
34 source: VarError,
35 },
36 #[error("Android NDK Clang directory could not be listed at {path}: {source}")]
37 AndroidNdkClangDirectoryUnreadable {
38 path: PathBuf,
39 #[source]
40 source: io::Error,
41 },
42 #[error("Android NDK Clang version directory was not found at {path}")]
43 AndroidNdkClangVersionDirectoryMissing { path: PathBuf },
44 #[error(
45 "Android NDK Clang directory {path} holds more than one version directory: {candidates:?}"
46 )]
47 AndroidNdkClangVersionDirectoryAmbiguous {
48 path: PathBuf,
49 candidates: Vec<PathBuf>,
50 },
51 #[error("Android NDK Clang built-in include directory was not found at {path}")]
52 AndroidNdkClangBuiltinIncludesMissing { path: PathBuf },
53 #[error("bindgen failed: {0}")]
54 Bindgen(#[source] bindgen::BindgenError),
55 #[error(
56 "bindgen never saw field {type_name}::{field_name}, so it can no longer be kept private"
57 )]
58 PrivatizedFieldMissing {
59 type_name: &'static str,
60 field_name: &'static str,
61 },
62 #[error("generated bindings could not be written: {0}")]
63 BindingsWrite(#[source] io::Error),
64 #[error("native wrapper compilation failed: {0}")]
65 NativeWrapper(#[source] cc::Error),
66 #[error("filesystem operation failed for {path}: {source}")]
67 Filesystem {
68 path: PathBuf,
69 #[source]
70 source: io::Error,
71 },
72 #[error("environment path {name} does not name a directory: {path}")]
73 EnvironmentDirectory { name: &'static str, path: PathBuf },
74 #[error("cargo directives could not be written: {0}")]
75 DirectiveWrite(#[source] io::Error),
76 #[error("the CMake file API reply directory {path} could not be listed: {source}")]
77 CmakeFileApiReplyDirectoryUnreadable {
78 path: PathBuf,
79 #[source]
80 source: io::Error,
81 },
82 #[error("CMake wrote no file API reply index into {path}")]
83 CmakeFileApiReplyIndexMissing { path: PathBuf },
84 #[error("the CMake file API reply file {path} could not be read: {source}")]
85 CmakeFileApiReplyFileUnreadable {
86 path: PathBuf,
87 #[source]
88 source: io::Error,
89 },
90 #[error("the CMake file API reply file {path} is not the reply this crate queried: {source}")]
91 CmakeFileApiReplyFileInvalid {
92 path: PathBuf,
93 #[source]
94 source: serde_json::Error,
95 },
96 #[error("the CMake cache has no entry {name}")]
97 CmakeCacheEntryMissing { name: String },
98 #[error("the CMake cache entry {name} is {value}, neither ON nor OFF")]
99 CmakeCacheEntryNotASwitch { name: String, value: String },
100 #[error(
101 "ggml needs the OpenMP runtime {libraries:?}, which Apple's linker cannot link by its \
102 exact file name"
103 )]
104 OpenmpRuntimeUnlinkableOnApple { libraries: Vec<PathBuf> },
105 #[error("the OpenMP runtime library {library} names no file")]
106 OpenmpRuntimeLibraryWithoutFileName { library: PathBuf },
107}