(manifest_dir: &Path, out_dir: &Path)
| 60 | .unwrap_or_else(|_| panic!("shared theme color `{name}` is not hexadecimal")); |
| 61 | let constant = name.replace('-', "_").to_ascii_uppercase(); |
| 62 | writeln!( |
| 63 | code, |
| 64 | "pub const {constant}: Color32 = Color32::from_rgb(0x{:02X}, 0x{:02X}, 0x{:02X});", |
| 65 | (rgb >> 16) & 0xFF, |
| 66 | (rgb >> 8) & 0xFF, |
| 67 | rgb & 0xFF |
| 68 | ) |
| 69 | .expect("write theme constant"); |
| 70 | colors += 1; |
| 71 | } |
| 72 | |
| 73 | assert!(colors >= 20, "shared theme palette is unexpectedly small"); |
| 74 | fs::write(out_dir.join("theme_palette.rs"), code).expect("write generated theme palette"); |
| 75 | } |
| 76 | |
| 77 | fn collect_rs_files(dir: &Path, files: &mut Vec<PathBuf>) { |
| 78 | if let Ok(entries) = fs::read_dir(dir) { |
| 79 | for entry in entries.flatten() { |
| 80 | let path = entry.path(); |
| 81 | if path.is_dir() { |
| 82 | collect_rs_files(&path, files); |
| 83 | } else if path.extension().and_then(|ext| ext.to_str()) == Some("rs") { |
| 84 | files.push(path); |
| 85 | } |
no test coverage detected