Commit Graph

11 Commits

Author SHA1 Message Date
zzy
51869bf081 feat(pproc): 改进宏处理器以支持括号嵌套和GNU扩展
- 实现了括号深度跟踪来正确分割带括号的宏参数
- 添加了对 GNU 扩展中 `##` 操作符逗号删除的支持
- 新增辅助函数 `got_left_non_blank` 和 `got_right_non_blank`
  来优化查找非空白 token 的逻辑
- 改进了错误消息以显示预期但得到的实际值类型

fix(pproc): 修复条件编译和包含文件路径的错误消息

- 在 `scc_pproc_parse_if_condition` 中改进错误消息格式
- 修复 `switch_file_stack` 函数中的日志字符串格式问题

test(pproc): 添加宏处理相关的单元测试

- 增加了连接操作符、嵌套宏、括号处理等测试用例
- 添加了 C99 标准示例和 GNU 变参宏删除逗号的测试
- 包含了复杂的宏展开场景测试

chore(justfile): 更新构建脚本添加调试目标

- 为 `test-scc` 目标添加了 `debug-scc` 调试版本
- 更新构建命令以支持开发模式

feat(cbuild): 添加 dry-run 模式和改进编译器参数

- 为编译器类添加 dry-run 功能,只打印命令不执行
- 改进 scc 编译器的包含路径处理逻辑
- 为命令行解析器添加 dry-run 参数选项

refactor(log): 重命名 static_assert 为 StaticAssert 避免冲突

- 为了避免与标准库冲突,将自定义 static_assert 重命名为 StaticAssert

style(scc_core): 移除未使用的预定义宏定义

- 删除了不再需要的基础类型前缀宏定义

fix(scc_core): 初始化 ring 测试中的未初始化变量

- 为测试函数中的字符变量添加初始化值避免未定义行为
2026-02-21 23:53:44 +08:00
zzy
4940b652eb feat(cbuild): 添加SCC编译器支持并更新构建脚本
添加了新的SccCompiler类以支持SCC编译器,包括编译和链接功能。
更新了justfile中的构建任务,添加了clean、build、build-install和test-scc等新任务。
同时修复了异常处理语法错误并将wc.py工具文件移除。
2026-02-21 16:02:53 +08:00
zzy
6c801fbb92 refactor(lexer): 移除未使用的期望函数并修复内存分配错误
移除了 scc_lexer_tok_expect 函数,因为它不再被使用。
在 lexer_stream_extend 函数中添加了返回语句,以在内存重新分配失败时正确处理错误。

BREAKING CHANGE: 移除了 scc_lexer_tok_expect 函数
2026-01-10 17:43:31 +08:00
zzy
ce8031b21f feat(parse): implement # and ## operator handling in macro expansion
- Add support for # (stringify) and ## (concatenation) operators in macro replacement lists
- Implement scc_pp_expand_string_unsafe() to process operator tokens during macro expansion
- Add helper macros to identify blank, stringify, and concatenation tokens in replacement lists
- Include missing headers (ctype.h, string.h) for character handling functions
- Update object macro expansion to use new string expansion function instead of simple concatenation
- Improve whitespace handling in macro replacement parsing to prevent interference with operator processing
2025-12-13 18:29:21 +08:00
zzy
897ef449fb feat: add atomic profile update flag and update clean command
- Add `-fprofile-update=atomic` flag to both GCC and Clang compiler configurations for thread-safe coverage data updates
- Change `--all` argument in clean command to default to True and add `-a` short option for consistency with common CLI patterns
2025-12-11 17:30:33 +08:00
zzy
35c13ee30a feat: add internationalization support with Chinese translations
- Introduce Translator class for simple i18n with English and Chinese locales
- Add concurrent.futures, os, and locale imports for parallel execution and language detection
- Implement automatic language detection based on system locale
- Provide translation keys for build messages, test results, and command outputs
- Support dynamic language switching via set_language method
2025-12-11 12:27:11 +08:00
zzy
098e41d3e5 feat(cbuild): refactor and enhance C build system with new features
- Refactor logging system with simplified ColorFormatter and improved output formatting
- Add test command with regex pattern matching and timeout support
- Implement file size formatting utility for build output
- Remove unused imports and streamline code structure
- Update .gitignore to exclude external/ directory
- Improve error handling and subprocess management in test execution
- Optimize build dependency resolution with topological sorting
- Enhance configuration parsing and target management

The changes focus on code quality improvements, adding testing capabilities, and optimizing the build process for better performance and maintainability.
2025-12-10 22:21:37 +08:00
zzy
1ab07a5815 feat(cbuild): 重构依赖解析器并新增依赖树打印功能
- 修改 `DependencyResolver.resolve` 方法返回类型为 `None`,不再返回依赖映射副本
- 新增 `print_tree` 方法用于打印格式化的依赖树结构
- 调整 `get_sorted_dependencies` 和 `get_all_contexts` 返回值类型为 `PackageConfig` 列表
- 在 `CPackageBuilder.tree` 中调用新的 `print_tree` 方法以简化逻辑
- 添加 `DummyCompiler` 类作为占位编译器实现
- 优化 argparse 命令行参数结构,将通用参数移到子命令中
- 改进编译器初始化逻辑,增加对参数存在性的检查
- 移除 clean 子命令中的 --all 参数选项
2025-11-27 15:25:45 +08:00
zzy
ed829bdc21 feat(cbuild): 重构依赖解析器并增强命令行功能
- 将 `resolved_deps` 重命名为 `deps` 并新增 `dep_map` 用于存储依赖关系
- 新增 `get_dependencies_of` 方法以获取指定包的直接依赖列表
- 实现递归打印依赖树的功能,优化 `tree` 命令展示效果
- 引入分层命令行参数解析,支持子命令及更多选项(如 --record、--args 等)
- 改进日志输出与构建模式提示信息,使其更准确反映当前构建状态
- 编译器类中增加命令记录机制,便于调试和回溯执行过程
2025-11-27 12:15:45 +08:00
zzy
67af0c6bf2 feat(cbuild): 引入构建缓存机制与编译模式支持
新增了基于文件修改时间和内容哈希的构建缓存功能,能够有效避免不必要的重复编译。同时增加了多种编译模式(如 debug、release、test 等)及其对应的默认编译选项,提升了构建过程的灵活性和效率。

- 添加 `BuildCache` 类用于管理缓存逻辑
- 支持通过 `CompilerBuildMode` 枚举选择不同构建模式
- 在 `CPackageBuilder` 中集成缓存判断与更新流程
- 优化日志输出及部分代码结构以提升可读性
2025-11-22 17:03:48 +08:00
zzy
63f6f13883 feat(cbuild): 重构构建系统并迁移至 tools/cbuild
将 `cbuild.py` 迁移至 `tools/cbuild/` 并进行大量功能增强。引入依赖解析器、支持颜色日志输出、
改进包配置默认值处理、完善构建目标识别与拓扑排序依赖管理。同时添加 `.gitignore` 和
`pyproject.toml` 以支持标准 Python 包结构,并更新 README 文档。

新增命令支持:tree(显示依赖树)、clean(带文件统计)、test(运行测试)等,
优化了 Windows 平台下的可执行文件扩展名处理逻辑。

移除了旧的 `wc.py` 行数统计脚本。
2025-11-22 15:08:49 +08:00