initial commit

This commit is contained in:
2026-03-22 11:16:14 -05:00
commit b9b35f3f0f
8 changed files with 509 additions and 0 deletions

49
src/config.rs Normal file
View File

@@ -0,0 +1,49 @@
#[derive(serde::Deserialize, serde::Serialize)]
pub struct Config {
/// The name of the output binary
pub name: String,
/// The default build to use
pub default_build: String,
/// Build configs
pub build: Vec<BuildConf>,
}
impl Config {
pub fn new(name: &str) -> Self {
Self {
name: name.to_owned(),
default_build: "debug".to_owned(),
build: vec![BuildConf::debug(), BuildConf::release()],
}
}
pub fn get_or_default(&self, mode: Option<String>) -> Option<&BuildConf> {
if let Some(mode) = mode {
self.build.iter().find(|bc| bc.name == mode)
} else {
self.build.iter().find(|bc| bc.name == self.default_build)
}
}
}
#[derive(serde::Deserialize, serde::Serialize)]
pub struct BuildConf {
pub name: String,
pub args: Vec<String>,
}
impl BuildConf {
fn debug() -> Self {
Self {
name: "debug".to_owned(),
args: vec!["-g".to_owned(), "-O0".to_owned()],
}
}
fn release() -> Self {
Self {
name: "release".to_owned(),
args: vec!["-DNDEBUG".to_owned(), "-O3".to_owned()],
}
}
}