# ๐ ๏ธ Rust Project Utility Scripts
This directory contains cross-platform **developer utility scripts** shared across all Rust projects.
They provide unified build checks, quality assurance, and resource verification tools.
> ๐ฆ Intended for use as a private Git submodule, e.g.:
> ```bash
> git submodule add git@github.com:umpire274/rust_dev_scripts.git tools_private
> ```
---
## ๐ Available Scripts
| **build_check.ps1** | Windows (PowerShell) | Full build + QA pipeline for Rust projects |
| **build_check.sh** | Linux / macOS | POSIX-compliant version of the same pipeline |
| **check_icon.ps1** | Windows (PowerShell) | Verifies if an `.exe` file contains embedded icon resources |
| **check_icon.sh** | Linux / macOS | Checks for embedded icons in ELF or Mach-O binaries using `rcedit`, `file`, or `otool` where available |
| **magick_tools.ps1** | Windows (PowerShell) | ImageMagick utility script for batch image processing tasks |
| **magick_tools.sh** | Linux / macOS | POSIX version of the ImageMagick utility script |
---
## ๐ Build Pipeline Scripts (`build_check.*`)
These scripts execute a standardized series of Rust project quality checks:
| ๐งน **cargo clean** | Cleans old build artifacts (optional) |
| ๐๏ธ **cargo build** | Builds the project (debug or release) |
| โจ **cargo fmt** | Checks code formatting |
| ๐ **cargo clippy** | Runs linting checks with all warnings treated as errors |
| ๐งช **cargo test** | Executes the test suite (optional) |
### Common CLI Options
| `--release` | Build and test in release mode |
| `--skip-tests` | Skip running the test suite |
| `--quiet` | Suppress detailed command output |
| `--no-clean` | Skip the initial `cargo clean` step |
### Examples
#### ๐ช Windows (PowerShell or CMD)
```powershell
# Full pipeline
.\build_check.ps1
# Release mode, no clean, skip tests
.\build_check.ps1 --release --skip-tests --no-clean
```
#### ๐ง Linux / macOS
```bash
./build_check.sh
./build_check.sh --release --skip-tests --no-clean --quiet
```
### Exit Codes
| 0 | All steps completed successfully |
| 1 | One or more steps failed |
---
## ๐ผ๏ธ Icon Verification Scripts (`check_icon.*`)
These scripts verify that a compiled binary includes embedded icon resources (typically used to confirm correct
packaging for Windows .exe or macOS .app bundles).
| check_icon.ps1 | Uses PowerShell + Get-Command or rcedit to inspect .exe metadata. |
| check_icon.sh | Uses file, otool, or rcedit (if installed) to inspect binary icons. |
### Example
#### ๐ช Windows (PowerShell)
```powershell
# Windows
.\check_icon.ps1 -Path ".\target\release\rbackup.exe"
```
#### ๐ง Linux / macOS
```bash
# Linux / macOS
./check_icon.sh ./target/release/rbackup
```
If the icon is correctly embedded, the script prints a โ
confirmation message; otherwise, it displays a โ ๏ธ warning
suggesting to check your .rc or build.rs setup.
---
## ๐ผ๏ธ ImageMagick Utility Scripts (`magick_tools.*`)
Cross-platform wrapper around ImageMagick 7+ for common asset-processing operations.
| magick_tools.ps1 | PowerShell script for batch image processing |
| magick_tools.sh | POSIX shell version for Linux / macOS |
### โจ Available Actions
| identify | Show image metadata (dimensions, format, channels) |
| convert | Convert file between formats (output inferred by extension) |
| resize | Resize image (--width ร --height) |
| optimize | Strip metadata, set interlacing, recompress (quality 85%) |
| make-ico | Create multi-size .ico from a single source image |
| extract | Extract all icon layers into separate files |
### โ๏ธ Common Options
| --input <path> | Input file |
| --output <path> | Output file or directory |
| --width, --height | Resize dimensions |
| --sizes <list> | Comma-separated list of icon sizes (e.g. 16,32,48) |
| --colors <n> | Palette quantization for ICO generation |
| --no-dither | Disable dithering when using --colors |
| --prefix <name> | Prefix for extracted layer filenames |
| --format <ext> | Output format for extraction (png, jpg, webp) |
| --magick <path> | Custom path to magick.exe or magick binary |
| --verbose | Enable verbose logging |
| --help | Display usage and exit |
### Example Usage
#### ๐ช Windows (PowerShell)
```powershell
# Identify
pwsh magick_tools.ps1 --action identify --input assets/logo.ico
# Convert PNG to WEBP
pwsh magick_tools.ps1 --action convert --input logo.png --output logo.webp
# Resize
pwsh magick_tools.ps1 --action resize --input img.png --output img_256.png --width 256
# Optimize JPEG
pwsh magick_tools.ps1 --action optimize --input photo.jpg --output photo_opt.jpg
# Build multi-size ICO
pwsh magick_tools.ps1 --action make-ico --input logo.png --output favicon.ico --sizes 16,32,48,64 --colors 256 --no-dither
# Extract all icon layers as WEBP
pwsh magick_tools.ps1 --action extract --input favicon.ico --output layers --prefix icon --format webp
```
#### ๐ง Linux / macOS
```bash
# Identify
./magick_tools.sh --action identify --input assets/logo.ico
# Convert PNG to WEBP
./magick_tools.sh --action convert --input logo.png --output logo.webp
# Resize
./magick_tools.sh --action resize --input img.png --output img_256.png --width 256
# Optimize JPEG
./magick_tools.sh --action optimize --input photo.jpg --output photo_opt.jpg
# Build multi-size ICO
./magick_tools.sh --action make-ico --input logo.png --output favicon.ico --sizes 16,32,48,64 --colors 256 --no-dither
# Extract all icon layers as WEBP
./magick_tools.sh --action extract --input favicon.ico --output layers --prefix icon --format webp
```
---
## โ๏ธ Cross-Platform Consistency
All scripts follow these conventions:
- UTF-8 encoding with Unicode emoji for visual clarity
- Identical parameter names and behavior across platforms
- Colorless emoji output (safe for legacy terminals)
- Clean exit on first failure (set -e or errorlevel checks)
- Human-readable output suitable for CI logs
---
## ๐ง Recommended Usage
1. Add this submodule under tools_private/scripts/.
2. Run the appropriate script before every commit or CI push:
```bash
./tools_private/scripts/build_check.sh --release
```
3. For Windows projects, verify your icons:
```powershell
.\tools_private\scripts\check_icon.ps1 -Path .\target\release\myapp.exe
```
---
## ๐ License & Credits
All scripts ยฉ 2025 **Alessandro Maestri**.
Released under the MIT License for educational and private use across personal Rust projects.