This guide will help you set up a development environment for GCodeKit5.
| Software | Minimum Version | Purpose |
|---|---|---|
| Rust | 1.70+ | Compiler and cargo |
| GTK4 | 4.6+ | UI framework |
| libadwaita | 1.2+ | Modern GTK widgets |
| pkg-config | - | Library discovery |
| Git | 2.0+ | Version control |
# Install development tools
sudo dnf groupinstall "Development Tools"
# Install GTK4 and dependencies
sudo dnf install gtk4-devel libadwaita-devel \
glib2-devel cairo-devel pango-devel \
gdk-pixbuf2-devel graphene-devel \
openssl-devel sqlite-devel pkg-config
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env# Install development tools
sudo apt update
sudo apt install build-essential
# Install GTK4 and dependencies
sudo apt install libgtk-4-dev libadwaita-1-dev \
libglib2.0-dev libcairo2-dev libpango1.0-dev \
libgdk-pixbuf-2.0-dev libgraphene-1.0-dev \
libssl-dev libsqlite3-dev pkg-config
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install GTK4 and dependencies
brew install gtk4 libadwaita pkg-config
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/envSee docs/MACOS_BUILD.md for detailed macOS instructions.
See docs/WINDOWS_BUILD.md for Windows setup using MSYS2.
git clone https://github.com/thawkins/gcodekit5.git
cd gcodekit5# Enable pre-commit hooks for code quality
git config core.hooksPath .githooks# Debug build (faster compilation, includes debug symbols)
cargo build
# Release build (optimized, slower to compile)
cargo build --releaseNote: First build downloads dependencies and may take 5-10 minutes. Subsequent builds are much faster due to incremental compilation.
# Check that the binary runs
cargo run --release -- --version# Run with debug logging
RUST_LOG=debug cargo run
# Run with trace logging (very verbose)
RUST_LOG=trace cargo run
# Run specific module logging
RUST_LOG=gcodekit5_communication=debug cargo runcargo run --releaseIf you have Podman installed, you can use the development container:
# Build and enter the container
podman build -t gcodekit5-dev .devcontainer/
podman run -it --rm \
--userns=keep-id \
--security-opt label=disable \
-v "$(pwd):/workspace:Z" \
gcodekit5-dev
# Inside container
cargo build
cargo runOr open in VS Code with the Dev Containers extension (set "dev.containers.dockerPath": "podman" in settings).
# Run all tests
cargo test
# Run with output visible
cargo test -- --nocapture
# Run with longer timeout (some tests are slow)
timeout 600 cargo test# Run tests for a specific crate
cargo test -p gcodekit5-core
# Run a specific test by name
cargo test test_grbl_status_parser
# Run tests matching a pattern
cargo test gcode# Library tests only (skip integration tests)
cargo test --lib
# Integration tests only
cargo test --test '*'
# Doc tests only
cargo test --doc# Format all code
cargo fmt
# Check formatting without changes
cargo fmt --check# Run Clippy linter
cargo clippy
# Clippy with all warnings as errors
cargo clippy -- -D warnings
# Fix auto-fixable issues
cargo clippy --fixThe git hooks run automatically, but you can run them manually:
# Run the same checks as pre-commit
cargo fmt --check && cargo clippy && cargo test --libgcodekit5/
├── Cargo.toml # Workspace root
├── src/ # Main binary
│ └── main.rs
├── crates/ # Library crates
│ ├── gcodekit5-core/ # Core types, traits, events
│ ├── gcodekit5-communication/ # Serial, firmware protocols
│ ├── gcodekit5-gcodeeditor/ # G-code text editing
│ ├── gcodekit5-visualizer/ # 2D/3D rendering
│ ├── gcodekit5-designer/ # CAD/CAM tools
│ ├── gcodekit5-camtools/ # Box maker, puzzle, etc.
│ ├── gcodekit5-devicedb/ # Device profiles
│ ├── gcodekit5-settings/ # App configuration
│ └── gcodekit5-ui/ # GTK4 UI components
├── docs/ # Documentation
├── assets/ # Icons, images
├── flatpak/ # Flatpak packaging
└── scripts/ # Build/utility scripts
RUST_BACKTRACE=1 cargo run
RUST_BACKTRACE=full cargo run # Full backtrace with source locations# Levels: error, warn, info, debug, trace
RUST_LOG=debug cargo run
# Multiple modules with different levels
RUST_LOG=gcodekit5=debug,gcodekit5_communication=trace cargo run
# All modules at debug except noisy ones
RUST_LOG=debug,hyper=warn cargo run- Install the "CodeLLDB" extension
- Create/update
.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug GCodeKit5",
"cargo": {
"args": ["build", "--bin=gcodekit5", "--package=gcodekit5"],
"filter": {
"name": "gcodekit5",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}",
"env": {
"RUST_LOG": "debug",
"RUST_BACKTRACE": "1"
}
}
]
}- Set breakpoints and press F5 to debug
# Build debug binary
cargo build
# Debug with GDB
gdb target/debug/gcodekit5
# Debug with LLDB
lldb target/debug/gcodekit5Enable the GTK Inspector to debug UI:
GTK_DEBUG=interactive cargo runPress Ctrl+Shift+I in the running application to open the inspector.
Error: Package gtk4 was not found
Solution: Install GTK4 development packages (see Prerequisites above)
# Fedora
sudo dnf install gtk4-devel
# Ubuntu
sudo apt install libgtk-4-devError: pkg-config: command not found
Solution:
# Fedora
sudo dnf install pkg-config
# Ubuntu
sudo apt install pkg-config
# macOS
brew install pkg-configError: Various linker errors about missing symbols
Solution: Ensure PKG_CONFIG_PATH is set:
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"Add to your ~/.zshrc or ~/.bashrc for persistence.
Error: Tests hang or timeout
Solution: Some tests may need more time:
# Increase timeout
timeout 600 cargo test
# Or skip slow tests during development
cargo test --lib # Only unit tests, skip integrationError: Permission denied when connecting to CNC controller
Solution: Add your user to the dialout group:
sudo usermod -aG dialout $USER
# Log out and back in for changes to take effectError: Application appears unstyled or broken
Solution: Ensure libadwaita is installed and you're running in a GTK-compatible desktop:
# Check libadwaita
pkg-config --modversion libadwaita-1
# Force a theme (if needed)
GTK_THEME=Adwaita:dark cargo runError: Flatpak manifest errors
Solution: Install flatpak-builder:
# Fedora
sudo dnf install flatpak-builder
# Ubuntu
sudo apt install flatpak-builder- Issues: GitHub Issues
- Documentation: See
docs/folder - Architecture: See docs/adr/ for design decisions
- Coordinate System: See docs/COORDINATE_SYSTEM.md
- Read the Architecture Decision Records to understand design choices
- Explore the crate structure in
crates/ - Run the application and explore the UI
- Pick an issue labeled "good first issue" to start contributing