chore(M0): 建立 CLion/CMake 工程骨架与测试框架
- CMake 多目标工程:shs_core 静态库 + smart_home 可执行 + shs_tests 测试 - CMakePresets.json:debug/release/asan/coverage 四个预设(debug 告警即错误) - 自研零依赖测试框架 tests/framework/test_framework.h + 运行器(套件过滤、CTest 集成) - 工具:tools/header_check.sh 头文件独立编译检查(接口冻结门) - 已实现公共层:errors / string_utils / num_utils,main 启动自检 - 实测:debug 预设 0 告警、ctest 3/3 通过(45 项断言)
This commit is contained in:
commit
578a770737
36 files changed
+2914
No files matched your search
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# ============================================================================
|
||||
# tools/header_check.sh —— 头文件独立编译检查
|
||||
# 作用:把每个 include/shs/*.h 单独编译一次,确保:
|
||||
# 1) 头文件自包含(不依赖包含顺序);
|
||||
# 2) 语法正确、声明与宏无冲突。
|
||||
# 用法:bash tools/header_check.sh (返回码 0 = 全部通过)
|
||||
# ============================================================================
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
CC="${CC:-cc}"
|
||||
FAILED=0
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
for header in "$ROOT"/include/shs/*.h; do
|
||||
name="$(basename "$header")"
|
||||
printf '#include "shs/%s"\nint main(void){return 0;}\n' "$name" > "$TMP/check.c"
|
||||
if out=$("$CC" -std=c17 -Wall -Wextra -Wpedantic -Werror -fsyntax-only \
|
||||
-I "$ROOT/include" "$TMP/check.c" 2>&1); then
|
||||
printf ' [OK] %s\n' "$name"
|
||||
else
|
||||
printf ' [FAIL] %s\n%s\n' "$name" "$out"
|
||||
FAILED=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$FAILED" -eq 0 ]; then
|
||||
echo "头文件检查:全部通过"
|
||||
else
|
||||
echo "头文件检查:存在失败"
|
||||
fi
|
||||
exit "$FAILED"
|
||||
Reference in new issue
Block a user