1use std::io::Error as IoError;
2use std::num::ParseIntError;
3use std::path::PathBuf;
4use std::process::Command;
5use thiserror::Error;
6
7#[derive(Debug, Error)]
8pub enum NdkError {
9 #[error(
10 "Android SDK is not found. \
11 Please set the path to the Android SDK with the $ANDROID_HOME \
12 environment variable."
13 )]
14 SdkNotFound,
15 #[error(
16 "Android NDK is not found. \
17 Please set the path to the Android NDK with $ANDROID_NDK_ROOT \
18 environment variable."
19 )]
20 NdkNotFound,
21 #[error("GNU toolchain binary `{gnu_bin}` nor LLVM toolchain binary `{llvm_bin}` found in `{toolchain_path:?}`.")]
22 ToolchainBinaryNotFound {
23 toolchain_path: PathBuf,
24 gnu_bin: String,
25 llvm_bin: String,
26 },
27 #[error("Path `{0:?}` doesn't exist.")]
28 PathNotFound(PathBuf),
29 #[error("Command `{0}` not found.")]
30 CmdNotFound(String),
31 #[error("Android SDK has no build tools.")]
32 BuildToolsNotFound,
33 #[error("Android SDK has no platforms installed.")]
34 NoPlatformFound,
35 #[error("Platform `{0}` is not installed.")]
36 PlatformNotFound(u32),
37 #[error("Target is not supported.")]
38 UnsupportedTarget,
39 #[error("Host `{0}` is not supported.")]
40 UnsupportedHost(String),
41 #[error(transparent)]
42 Io(#[from] IoError),
43 #[error("IoError on `{0:?}`: {1}")]
44 IoPathError(PathBuf, #[source] IoError),
45 #[error("Invalid semver")]
46 InvalidSemver,
47 #[error("Command `{}` had a non-zero exit code.", format!("{:?}", .0).replace('"', ""))]
48 CmdFailed(Command),
49 #[error(transparent)]
50 Serialize(#[from] quick_xml::de::DeError),
51 #[error("String `{1}` is not a UID")]
52 NotAUid(#[source] ParseIntError, String),
53 #[error("Could not find `package:{package}` in output `{output}`")]
54 PackageNotInOutput { package: String, output: String },
55 #[error("Could not find `uid:` in output `{0}`")]
56 UidNotInOutput(String),
57}