No description
Find a file
Harbor dbc2b1c4d6 feat: 模块依赖声明系统(depends 字段)+ 双模式迁移
- 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
2026-07-17 10:20:33 +08:00
.opencode/plans docs: 更新 SKILL.md 反映 cmake-mappings、模块重新生成、跨模块 include 目录等变化 2026-07-15 14:56:23 +08:00
ctx feat: 模块依赖声明系统(depends 字段)+ 双模式迁移 2026-07-17 10:20:33 +08:00
docs feat: 模块依赖声明系统(depends 字段)+ 双模式迁移 2026-07-17 10:20:33 +08:00
rtdb feat: 重构生成器架构,新增 pack/ninja 生成器模块,补全 rtdb 示例项目 2026-07-07 15:28:59 +08:00
test_workpath fix: ctx pack 注册到父项目而非主项目, 根CMakeLists.txt重新生成 2026-07-07 16:02:50 +08:00
.gitignore feat: 将模板重写为 ctx CLI 工具 2026-07-03 01:00:50 +08:00
pyproject.toml feat: 将模板重写为 ctx CLI 工具 2026-07-03 01:00:50 +08:00
README.md feat: 重构生成器架构,新增 pack/ninja 生成器模块,补全 rtdb 示例项目 2026-07-07 15:28:59 +08:00
setup.py feat: 将模板重写为 ctx CLI 工具 2026-07-03 01:00:50 +08:00

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