实现 12.3 toml 读取:schema 校验、文件集合、工程哈希。

- Project.h/cpp:toml++ 解析 + 字段白名单(未知键带行号报错)、name/entry/cycle_limit/dt_ms/files.st 必填、io 条目完整性、entry 必须 program MAIN
- compile_files:files.st ∪ gvl.file 去重;compute_project_hash:路径排序后 FNV-1a 64 增量,缺文件报 file missing
- STCompiler <project.toml>:打印文件列表与哈希,失败退出码 1,--help
- compiler 私有链接 toml++ v3.4.0;测试固化 compiler_toml(35 断言,line1 哈希冻结 0xc3fe4ae74ad45900)
This commit is contained in:
2026-08-21 00:32:53 +08:00
parent 6df3465b37
commit c076c25368
6 changed files with 682 additions and 5 deletions
+43 -4
View File
@@ -2,14 +2,53 @@
* @file main.cpp
* @brief STCompiler 可执行入口
* @author
* @date 2026-08-19
* @date 2026-08-21
*/
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include "compiler/Project.h"
namespace {
void usage() {
std::printf("usage: STCompiler <project.toml>\n"
" 解析工程并打印文件集合与工程哈希(12.3 阶段)\n"
" --help 打印本帮助\n");
}
}
int main(int argc, char** argv) {
(void)argc;
(void)argv;
std::printf("STCompiler 0.1\n");
if (argc < 2) {
std::printf("STCompiler 0.1\n");
usage();
return 0;
}
if (std::strcmp(argv[1], "--help") == 0) {
usage();
return 0;
}
compiler::Project proj;
std::string err;
if (!compiler::parse_project(argv[1], &proj, &err)) {
std::fprintf(stderr, "error: %s\n", err.c_str());
return 1;
}
const std::vector<std::string> files = compiler::compile_files(proj);
uint64_t hash = 0;
if (!compiler::compute_project_hash(proj, &hash, &err)) {
std::fprintf(stderr, "error: %s\n", err.c_str());
return 1;
}
std::printf("project: %s\n", proj.name.c_str());
std::printf("files:\n");
for (const std::string& f : files) {
std::printf(" %s\n", f.c_str());
}
std::printf("hash: 0x%016llx\n", static_cast<unsigned long long>(hash));
return 0;
}