caxe (cx) πͺ
caxe (pronounced "c-axe") is a modern project manager for C and C++ designed to cut through the complexity of legacy build systems.
It provides a unified workflow for scaffolding, building, testing, formatting, and managing dependenciesβgiving C/C++ developers the modern experience they deserve.
Zero Configuration. Lightning Fast. Batteries Included.
β¨ Features
- β‘ Zero Config Start: Create a Hello World C/C++ project in seconds.
- π§ Automatic Toolchain Discovery: Detects MSVC, Clang-CL, Clang++, and GCC without relying on PATH. Uses
vswhereon Windows. - π¦ Smart Dependency Management:
- Git Libraries: Auto-download from GitHub. Supports Pinning (Tag/Branch/Commit) for stability.
- System Packages: Native support for
pkg-config(e.g., GTK, OpenSSL). - Vendor Mode:
cx vendorto copy dependencies locally for offline builds.
- π High-Performance Builds:
- Lock-free Parallel Compilation: Utilizes all CPU cores.
- Caching: CCache integration, incremental builds, and PCH support.
- LTO: Link Time Optimization for release builds.
- π§ͺ Smart Testing:
- Auto-links project sources for unit testing internals.
- Test filtering (
--filter) and binary caching.
- π Insights:
cx statsfor code metrics andcx treefor dependency graphs. - π WebAssembly:
cx build --wasm(via Emscripten) support out of the box. - π€ Arduino/IoT: Auto-detect
.inofiles, build and upload viaarduino-cli. - π― Cross-Platform Targets: Manage build targets (Windows, Linux, macOS, WebAssembly, ESP32).
- π‘οΈ Safety:
cx build --sanitizefor Address/Undefined Behavior sanitizers. - π¨ Code Formatting: Built-in
cx fmtcommand (viaclang-format) with--checkfor CI. - π― Build Profiles: Custom profiles with inheritance for cross-compilation (
--profile esp32). - π€ Automation: Generators for Docker, GitHub Actions, and VSCode configs.
π¦ Installation
Automatic Script (Recommended)
Windows (PowerShell):
iwr https://raw.githubusercontent.com/dhimasardinata/caxe/main/install.ps1 -useb | iex
Unix (Linux/macOS):
|
Option 2: Install via Cargo
π Quick Start
Interactive Mode
Simply run cx or cx new without given name to start the wizard.
# ? What is your project name? βΊ my-app
# ? Select a template: βΊ console
# ? Select language: βΊ cpp
CLI Arguments Mode
# Default (Hello World)
# Web Server (cpp-httplib)
# Raylib Game Config
# SDL3 Game (Modern API)
π CLI Reference
Project Management
cx new <name>: Create a new project.cx init: Initializecx.tomlin an existing directory (imports CMake/Makefile projects!).cx info: Show system, cache, and toolchain info.cx doctor: Diagnose system issues (missing tools, compilers).cx stats: Show project code metrics (LOC, files).
Build & Run
cx run: Build and run the project.cx build: Compile only.--release: Optimize for speed (-O3//O2).--profile <name>: Use a named profile (e.g.,--profile esp32).--wasm: Compile to WebAssembly (requires Emscripten).--lto: Enable Link Time Optimization.--sanitize=<check>: Enable runtime sanitizers (e.g.,address,undefined).--trace: Generate build trace (.cx/build/build_trace.jsonfor Chrome Tracing).
cx watch: Rebuild on file save.cx clean: Remove build artifacts.cx package: Create a distribution archive (ZIP) containing the executable, DLLs, and assets.
Arduino/IoT
cx build --arduino: Build Arduino sketch (auto-detected if.inofiles present).cx upload -p COM3: Upload sketch to Arduino board.cx new myproject --template arduino: Create Arduino project.
Cross-Platform
cx target list: Show available cross-compilation targets.cx target add <name>: Add a target to your project.cx target remove <name>: Remove a target.cx generate cmake: Generate CMakeLists.txt from cx.toml.cx generate ninja: Generate build.ninja from cx.toml.
Dependencies
cx add <lib>: Add a library from registry or Git URL.cx remove <lib>: Remove a dependency.cx update: Update dependencies to latest versions.cx vendor: Copy all dependencies intovendor/for commit/offline use.cx lock: Managecx.lockfile (--check,--update).cx sync: Synchronize dependencies withcx.lockto ensure reproducible builds.cx tree: Visualize the dependency graph.
Testing & Quality
cx test: Run unit tests intests/.--filter <name>: Run specific tests.
cx fmt: Format code withclang-format.--check: Verify formatting without modifying (for CI).
cx check: Static analysis (clang-tidy/cppcheck).
Ecosystem
cx toolchain: Manage C/C++ compilers.list: Show detected compilers.select: Choose active compiler interactively.install: Interactive wizard to install toolchains and dev tools.update: Check for and install toolchain updates.
cx docker: Generate a Dockerfile.cx ci: Generate a GitHub Actions workflow.cx setup-ide: Generate VSCode configuration (.vscode/).
βοΈ Configuration (cx.toml)
[]
= "my-awesome-app"
= "0.1.0"
= "c++20"
[]
= "app" # Output: app.exe
= "clang" # Options: msvc, clang, clang-cl, g++
= ["-O2", "-Wall", "-Wextra"]
= ["pthread", "m"]
= "src/pch.hpp" # Precompiled Header (Optional)
[]
# 1. Simple Git (HEAD)
= "https://github.com/fmtlib/fmt.git"
# 2. Pinned Version (Recommended for production)
= { = "https://github.com/nlohmann/json.git", = "v3.11.2" }
# 3. System Dependency (pkg-config)
= { = "gtk4" }
# Build Profiles (for cross-compilation)
[]
= "release" # Inherit from release
= "xtensa-esp32-elf-g++"
= ["-mcpu=esp32", "-ffunction-sections"]
[]
= "arduino:avr:uno" # or "esp32:esp32:esp32"
= "COM3" # optional, for upload
ποΈ Architecture
caxe is organized into modular components for maintainability:
src/
βββ main.rs # CLI entry point & routing (~980 lines)
βββ commands/ # CLI command handlers
β βββ toolchain.rs # cx toolchain commands
β βββ target.rs # cx target commands
β βββ generate.rs # cx generate cmake/ninja
β βββ doctor.rs # cx doctor, lock, sync
βββ build/ # Core build system
β βββ core.rs # Parallel compilation engine
β βββ utils.rs # Toolchain detection, std flags
β βββ test.rs # Test runner
β βββ arduino.rs # Arduino/IoT support
β βββ feedback.rs # Error message analysis
βββ deps/ # Dependency management
β βββ fetch.rs # Git clone, prebuilt downloads
β βββ manage.rs # Add/remove dependencies
β βββ vendor.rs # Vendor command
βββ toolchain/ # Compiler detection
β βββ windows.rs # MSVC/vswhere discovery
β βββ install.rs # Toolchain installation wizard
βββ config.rs # cx.toml parsing
βββ lock.rs # cx.lock file handling
βββ registry.rs # Library registry lookups
βββ [utilities] # cache, ci, docker, ide, doc, etc.
Key Design Principles:
- Zero-config: Sensible defaults, automatic toolchain detection
- Progressive disclosure: Simple commands β advanced options
- Parallel by default: Lock-free compilation using rayon
- Safety: No panics, all errors handled with anyhow
π§ͺ Running Tests
# Run all tests (unit + integration)
# Run only unit tests
# Run only integration tests
Test categories:
config.rs- Config parsing, BuildConfig, Dependenciesbuild/utils.rs- MSVC/GCC standard flag generationbuild/feedback.rs- Compiler error message parsingintegration_test.rs- End-to-end build scenarios
π€ Contributing
Contributions are welcome! Here's how to get started:
-
Fork & Clone
-
Build & Test
-
Code Style
- Run
cargo fmtbefore committing - All new code should have tests
- Use
anyhow::Resultfor error handling
- Run
-
Pull Request
- Keep PRs focused on a single feature/fix
- Update documentation if needed
π Sponsors
If you find caxe useful, consider supporting its development:
πͺ Crypto Donations
| Network | Address |
|---|---|
| Ethereum/Polygon/BSC | 0x7e1a1a8c46817f297be14c14b587a0fa4b9e484b |
| Solana | Bek24ZEPWHUJeTHQmDHtC7uHaHiH7TX8FmfYqtQu3Tt |
| Bitcoin | bc1q4rm4e007u0f44vje694f422dy423dfc2caqz9z |
Your sponsorship helps with:
- π§ Continued development and new features
- π Better documentation and examples
- π Faster bug fixes and support
- π Community growth
π License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Made with β€οΈ for the C/C++ community