forked from 1b-agent/fieldcraft-upstream
cargo xtask app-icon computes an isometric L bracket with a bolt hole and a structured hexahedral mesh (O-grid around the hole), draws it with vectorcraft-cli and writes icon.svg/png, small-size artwork, the iconset, icns, ico, an Icon Composer ModelCraft.icon (floor grid Default/Dark, part, mesh) and its actool Assets.car. The desktop app uses the 256 px export as its window icon, falling back to eframe's default if it cannot be decoded. Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
1.8 KiB
Rust
63 lines
1.8 KiB
Rust
//! `cargo xtask assets`: every non-code asset in the repository must have a row in
|
|
//! ATTRIBUTION.md (author, source, licence), toolbar icons (`assets/icons`) included.
|
|
|
|
use std::path::Path;
|
|
|
|
const ASSET_EXT: &[&str] = &[
|
|
"png",
|
|
"jpg",
|
|
"jpeg",
|
|
"svg",
|
|
"ico",
|
|
"icns",
|
|
"car",
|
|
"ttf",
|
|
"otf",
|
|
"woff",
|
|
"woff2",
|
|
"gif",
|
|
"bmp",
|
|
"webp",
|
|
"wav",
|
|
"mp3",
|
|
"stl",
|
|
"step",
|
|
"stp",
|
|
"obj",
|
|
"vectorcraft",
|
|
"solidcraft",
|
|
];
|
|
const SKIP_DIRS: &[&str] = &["target", ".git", "plan", "dist"];
|
|
|
|
fn walk(dir: &Path, root: &Path, out: &mut Vec<String>) {
|
|
let Ok(rd) = std::fs::read_dir(dir) else { return };
|
|
for e in rd.flatten() {
|
|
let p = e.path();
|
|
let name = e.file_name().to_string_lossy().to_string();
|
|
if p.is_dir() {
|
|
if !SKIP_DIRS.contains(&name.as_str()) && !name.starts_with('.') {
|
|
walk(&p, root, out);
|
|
}
|
|
} else if let Some(ext) = p.extension().map(|x| x.to_string_lossy().to_ascii_lowercase())
|
|
&& ASSET_EXT.contains(&ext.as_str())
|
|
&& let Ok(rel) = p.strip_prefix(root)
|
|
{
|
|
out.push(rel.to_string_lossy().replace('\\', "/"));
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn run(root: &Path) -> Result<(), String> {
|
|
let attribution = std::fs::read_to_string(root.join("ATTRIBUTION.md")).map_err(|e| format!("ATTRIBUTION.md: {e}"))?;
|
|
let mut files = Vec::new();
|
|
walk(root, root, &mut files);
|
|
files.sort();
|
|
let missing: Vec<&String> = files.iter().filter(|f| !attribution.contains(f.as_str())).collect();
|
|
if missing.is_empty() {
|
|
println!("assets: {} asset file(s), all attributed", files.len());
|
|
Ok(())
|
|
} else {
|
|
Err(format!("assets missing from ATTRIBUTION.md:\n{}", missing.iter().map(|m| format!(" {m}")).collect::<Vec<_>>().join("\n")))
|
|
}
|
|
}
|