app
KiCad - the KiCad Bridge
Public Made by Adomby adom
Drive your own KiCad from an AI, in the background: open every editor, read the whole board as data (the EDA Bridge Standard board model), stack-up, part heights, netlists, place, route, pour, DRC and exports.
master
John Lauer
rust: workspace with kicad-platform (windows, macos, linux), kicad-core, kicad-bridge; 13 headless verbs; alpha.2
51525a8
2mo ago
//! Find KiCad. The OS layer lists candidates; this sorts them and picks the primary.
use serde::Serialize;
pub use kicad_platform::KicadInstall;
#[derive(Clone, Debug, Default, Serialize)]
pub struct KicadInfo {
pub installed: bool,
pub version: String,
pub installs: Vec<KicadInstall>,
}
impl KicadInfo {
pub fn summary(&self) -> String {
if !self.installed {
return "KiCad: not found".into();
}
let i = &self.installs[0];
format!("KiCad {} at {} ({})", i.cli_version, i.base_dir, i.source)
}
pub fn primary(&self) -> Option<&KicadInstall> {
self.installs.first()
}
}
fn version_key(v: &str) -> (u32, u32, u32) {
let mut it = v.split('.').map(|p| p.trim().parse::<u32>().unwrap_or(0));
(it.next().unwrap_or(0), it.next().unwrap_or(0), it.next().unwrap_or(0))
}
pub fn detect() -> KicadInfo {
let mut installs = kicad_platform::native().find_installs();
installs.sort_by(|a, b| version_key(&b.cli_version).cmp(&version_key(&a.cli_version)));
let installed = !installs.is_empty();
let version = installs.first().map(|i| i.cli_version.clone()).unwrap_or_default();
KicadInfo { installed, version, installs }
}
pub fn config_dir(version: &str) -> Option<std::path::PathBuf> {
kicad_platform::native().config_dir(version)
}