pub mod backend;
mod builder;
mod config;
pub mod documentation;
pub use builder::{Builder, Package};
pub use config::ConfigFile;
#[cfg(feature = "simplelog")]
pub use simplelog::LevelFilter;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum GodotVersion {
Version32,
Version33,
Version34,
Version35,
}
impl TryFrom<&str> for GodotVersion {
type Error = Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"3.2" => Ok(Self::Version32),
"3.3" => Ok(Self::Version33),
"3.4" => Ok(Self::Version34),
"3.5" => Ok(Self::Version35),
_ => Err(Error::InvalidGodotVersion(String::from(value))),
}
}
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Toml(#[from] toml::de::Error),
#[error("Error at {0}: {1}")]
Io(std::path::PathBuf, std::io::Error),
#[error("{0}")]
Syn(#[from] syn::Error),
#[error("{0}")]
Metadata(#[from] cargo_metadata::Error),
#[error("No crate matched the name '{0}'")]
NoMatchingCrate(String),
#[error(
r"Multiple crates were found with a 'cdylib' target: {0:?}
Please select the one you want via either:
- The '-p' flag on the command line
- The `package` method of `Builder`
"
)]
MultipleCandidateCrate(Vec<String>),
#[error("No crate was found with a 'cdylib' target")]
NoCandidateCrate,
#[error("Invalid or unsupported godot version: {0}")]
InvalidGodotVersion(String),
#[cfg(feature = "simplelog")]
#[error("Logger initialization failed: {0}")]
InitLogger(#[from] log::SetLoggerError),
}
#[cfg(feature = "simplelog")]
pub fn init_logger(level: LevelFilter) -> Result<(), Error> {
simplelog::TermLogger::init(
level,
simplelog::Config::default(),
simplelog::TerminalMode::Stderr,
simplelog::ColorChoice::Auto,
)?;
Ok(())
}