No description
- config.py: modules 类型改为 dict[str, Any],支持 depends: list[str] - exceptions.py: 新增 ConfigError - cmake_gen.py: 双模式架构 - Flat 模型(向后兼容):任一模块缺少 depends 时使用 - Depends 模型:全部模块声明 depends 后启用,精确控制 include/link - 循环依赖检测(DFS) - SHARED 存在时自动设置 CMAKE_POSITION_INDEPENDENT_CODE ON |
||
|---|---|---|
| .opencode/plans | ||
| ctx | ||
| docs | ||
| rtdb | ||
| test_workpath | ||
| .gitignore | ||
| pyproject.toml | ||
| README.md | ||
| setup.py | ||
ctx — Modern C++ Project Scaffolder
A CLI tool that combines Cargo-like project management with Conan's package management power.
Install
pip install ctx
Or from source:
git clone <repo>
cd ctx
pip install .
Usage
Create a new project
ctx new my-app
# Interactive prompts: C++ standard, build system, compiler
cd my-app
Build & run
ctx build # Debug build (default)
ctx build --profile release
ctx run # Build + run
ctx test # Build + run tests
ctx clean # Clean build artifacts
Manage dependencies
ctx deps list # List all dependencies
ctx deps add fmt=12.1.0 # Add a dependency
ctx deps add gtest --dev # Add dev dependency
ctx deps add cmake --tool # Add tool dependency
ctx deps remove fmt # Remove a dependency
ctx deps tree # Show dependency tree (Conan)
Manage compilers
ctx compiler list # Detect installed compilers
ctx compiler use gcc-13 # Switch project compiler
ctx compiler add my-toolchain --cc /path/to/gcc --cxx /path/to/g++
Conan profiles
ctx profile list # List Conan profiles
ctx profile detect # Auto-detect host profile
Code quality
ctx fmt # Format code (clang-format)
ctx lint # Static analysis (clang-tidy)
cpps.toml
The project configuration file (cpps.toml) is the single source of truth:
[project]
name = "my-app"
version = "0.1.0"
cpp_std = "20"
namespace = "my_app"
[build]
system = "cmake" # cmake | ninja | make
[profile]
compiler = "gcc"
compiler.version = "13"
compiler.libcxx = "libstdc++11"
[dependencies]
fmt = "12.1.0"
[dev-dependencies]
gtest = "1.17.0"
[tool-requires]
cmake = "3.31.11"
How it works
cpps.toml
│
▼
ctx generates ├── conanfile.py ← Conan 2.x package config
├── CMakeLists.txt ← CMake build
├── CMakePresets.json
└── source templates
│
▼
User runs ├── ctx build → conan install + cmake configure + cmake build
├── ctx test → build + ctest
└── ctx deps → manage dependencies in cpps.toml
Commands reference
| Command | Description |
|---|---|
ctx new <name> |
Create a new C++ project |
ctx build |
Build the project |
ctx run |
Build and run |
ctx test |
Build and run tests |
ctx clean |
Clean build artifacts |
ctx fmt |
Format source code |
ctx lint |
Static analysis |
ctx deps add <pkg> |
Add a dependency |
ctx deps remove <pkg> |
Remove a dependency |
ctx deps list |
List dependencies |
ctx deps tree |
Show dependency tree |
ctx compiler list |
List available compilers |
ctx compiler use <name> |
Switch compiler |
ctx compiler add <name> |
Register custom toolchain |
ctx profile list |
List Conan profiles |
ctx profile detect |
Auto-detect Conan profile |