Files
VoiletCStudio/README.md
虾哥 1f7328174b v1.1: 修复 Windows 跨平台兼容性 & 按钮高对比度配色
【跨平台修复】
- cmakegenerator.cpp: CMAKE_C_COMPILER / CMAKE_MAKE_PROGRAM 提前到 project() 之前设置,避免 CMake 在 Windows 回退 NMake
- cmakegenerator.cpp: MinGW 编译器路径下自动推导 mingw32-make.exe
- mainwindow.cpp: generateCMake() 在 Windows 下添加 -G 'MinGW Makefiles'
- mainwindow.cpp: compileProject() cmake 添加生成器参数 & mingw32-make 替代 make

【UI 改进】
- 全部操作按钮升级为 Material Design 高对比度配色(Darker 系列)
- 按钮添加圆角和内边距,提升可读性和视觉层次

【工程规范】
- 新增 .gitignore,排除编译产物 (.o / moc_*.cpp / Makefile / 二进制)
- README.md 重写,补充 Windows 编译指南和技术要点
- 需求规格说明书更新至 v1.1
2026-04-28 18:26:10 +08:00

183 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# VoiletCStudio - 紫罗兰 C 工具箱
Qt5 跨平台 C 工程配置器,自动生成 CMakeLists.txt
> 版本v1.1 · 2026-04-28
---
## 🚀 功能特性
### 1. 工程配置管理
- ✅ JSON 格式配置文件
- ✅ 新建/打开/保存工程
- ✅ 拖拽 JSON 文件打开
- ✅ Ctrl+S 快速保存
### 2. 编译工具链配置
- ✅ 编译器路径选择
- ✅ 汇编器路径选择
- ✅ 链接器路径选择
- ✅ 支持 MinGW / GCC / Clang
- ✅ Windows 下自动识别 MinGW 工具链
### 3. 文件管理
- ✅ 虚拟目录(类似 MDK
- ✅ .c 源文件分类管理
- ✅ .h 包含目录管理
- ✅ 库文件管理(.a/.so/.lib
### 4. 编译配置
- ✅ 编译宏定义
- ✅ 自定义编译选项
- ✅ Debug / Release 模式
### 5. CMake 生成
- ✅ 自动生成 CMakeLists.txt
- ✅ 编译器路径在 `project()` 之前设置,避免默认回退到 NMake
- ✅ Windows 下自动指定 `-G "MinGW Makefiles"` 生成器
- ✅ 内置一键编译Debug / Release
---
## 📋 使用方法
### 编译 VoiletCStudio
**Linux**
```bash
cd VoiletCStudio
qmake
make
```
**Windows (MSYS2/MinGW)**
```bash
cd VoiletCStudio
qmake
mingw32-make
```
### 运行
```bash
./VoiletCStudio # Linux
VoiletCStudio.exe # Windows
```
### 使用流程
1. 新建工程 → 输入工程名
2. 配置编译器路径Windows 选 `gcc.exe`
3. 添加虚拟目录和 .c 源文件
4. 添加包含目录和库文件
5. 添加编译宏和选项
6. 保存工程JSON
7. 点击「生成 CMake」→ 自动生成 CMakeLists.txt
8. 点击「编译 Debug / Release」→ 一键编译
---
## 🛠️ CMake 使用
```bash
# Linux / macOS
cmake -B build
make debug # 编译 Debug
make release # 编译 Release
# Windows (MinGW)
cmake -G "MinGW Makefiles" -B build
mingw32-make debug
mingw32-make release
```
---
## 📁 项目结构
```
VoiletCStudio/
├── src/
│ ├── main.cpp # 主程序入口
│ ├── mainwindow.cpp/h # 主窗口(含编译流程)
│ ├── projectconfig.cpp/h # 配置管理
│ └── cmakegenerator.cpp/h # CMake 生成
├── VoiletCStudio.pro # Qt 项目文件
├── README.md # 说明文档
└── 需求规格说明书.md # 详细需求文档
```
---
## 💻 跨平台支持
| 平台 | 编译器 | 生成器 | 状态 |
|------|--------|--------|------|
| Windows | MinGW (MSYS2) | MinGW Makefiles | ✅ |
| Windows | MSVC | NMake | ⚠️ 未测试 |
| Linux | GCC | Unix Makefiles | ✅ |
| macOS | Clang | Unix Makefiles | ✅ |
### Windows 特别注意
- 必须安装 **MSYS2** 并安装 `mingw-w64-gcc``mingw-w64-cmake`
- 编译器路径示例:`C:/msys2/mingw64/bin/gcc.exe`
- CMake 生成时程序自动使用 `-G "MinGW Makefiles"`
- 构建时使用 `mingw32-make` 而非 `make`
---
## 📝 配置文件格式
```json
{
"projectName": "MyProject",
"projectPath": "/path/to/project",
"outputDir": "./build",
"compilerPath": "/usr/bin/gcc",
"assemblerPath": "/usr/bin/gcc",
"linkerPath": "/usr/bin/gcc",
"virtualDirs": {
"App": {
"name": "App",
"files": ["src/main.c"]
}
},
"includeDirs": ["./include"],
"libraries": ["libmylib.a"],
"defines": ["DEBUG"],
"compilerOptions": ["-Wall"]
}
```
---
## 🔧 技术要点
### 编译器设置顺序
CMakeLists.txt 中 `CMAKE_C_COMPILER` **必须在 `project()` 之前设置**,否则 CMake 会在 `project()` 时自动检测编译器并可能回退到不存在的 NMake。
### Windows 生成器
程序通过 `#ifdef Q_OS_WIN32` 编译期检测平台,在 Windows 上自动:
- CMake 添加 `-G "MinGW Makefiles"` 参数
- 构建时使用 `mingw32-make` 替代 `make`
- 自动从编译器路径推导 `CMAKE_MAKE_PROGRAM`
---
## 🎯 特色
- **类 MDK 虚拟目录**:像 Keil MDK 一样管理源文件
- **一键生成 CMake**:自动生成完整的 CMakeLists.txt
- **真正跨平台**Windows (MinGW) / Linux / macOS 全支持,自动化平台适配
- **轻量级**:纯 Qt5 实现,无额外依赖
---
## 📄 许可证
MIT License
---
**作者:虾哥**
**日期2026-04-09 · 更新2026-04-28**